blob: a2e3688822262513982f64b9654468778514f649 [file] [log] [blame]
Don Newton98fd8812019-09-23 15:15:02 -04001// Copyright 2009,2010 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// Darwin system calls.
6// This file is compiled as ordinary Go code,
7// but it is also input to mksyscall,
8// which parses the //sys lines and generates system call stubs.
9// Note that sometimes we use a lowercase //sys name and wrap
10// it in our own nicer implementation, either here or in
11// syscall_bsd.go or syscall_unix.go.
12
13package unix
14
15import (
16 "errors"
17 "syscall"
18 "unsafe"
19)
20
21const ImplementsGetwd = true
22
23func Getwd() (string, error) {
24 buf := make([]byte, 2048)
25 attrs, err := getAttrList(".", attrList{CommonAttr: attrCmnFullpath}, buf, 0)
26 if err == nil && len(attrs) == 1 && len(attrs[0]) >= 2 {
27 wd := string(attrs[0])
28 // Sanity check that it's an absolute path and ends
29 // in a null byte, which we then strip.
30 if wd[0] == '/' && wd[len(wd)-1] == 0 {
31 return wd[:len(wd)-1], nil
32 }
33 }
34 // If pkg/os/getwd.go gets ENOTSUP, it will fall back to the
35 // slow algorithm.
36 return "", ENOTSUP
37}
38
39// SockaddrDatalink implements the Sockaddr interface for AF_LINK type sockets.
40type SockaddrDatalink struct {
41 Len uint8
42 Family uint8
43 Index uint16
44 Type uint8
45 Nlen uint8
46 Alen uint8
47 Slen uint8
48 Data [12]int8
49 raw RawSockaddrDatalink
50}
51
52// Translate "kern.hostname" to []_C_int{0,1,2,3}.
53func nametomib(name string) (mib []_C_int, err error) {
54 const siz = unsafe.Sizeof(mib[0])
55
56 // NOTE(rsc): It seems strange to set the buffer to have
57 // size CTL_MAXNAME+2 but use only CTL_MAXNAME
58 // as the size. I don't know why the +2 is here, but the
59 // kernel uses +2 for its own implementation of this function.
60 // I am scared that if we don't include the +2 here, the kernel
61 // will silently write 2 words farther than we specify
62 // and we'll get memory corruption.
63 var buf [CTL_MAXNAME + 2]_C_int
64 n := uintptr(CTL_MAXNAME) * siz
65
66 p := (*byte)(unsafe.Pointer(&buf[0]))
67 bytes, err := ByteSliceFromString(name)
68 if err != nil {
69 return nil, err
70 }
71
72 // Magic sysctl: "setting" 0.3 to a string name
73 // lets you read back the array of integers form.
74 if err = sysctl([]_C_int{0, 3}, p, &n, &bytes[0], uintptr(len(name))); err != nil {
75 return nil, err
76 }
77 return buf[0 : n/siz], nil
78}
79
Don Newtone0d34a82019-11-14 10:58:06 -050080//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
Don Newton98fd8812019-09-23 15:15:02 -040081func PtraceAttach(pid int) (err error) { return ptrace(PT_ATTACH, pid, 0, 0) }
82func PtraceDetach(pid int) (err error) { return ptrace(PT_DETACH, pid, 0, 0) }
83
84const (
85 attrBitMapCount = 5
86 attrCmnFullpath = 0x08000000
87)
88
89type attrList struct {
90 bitmapCount uint16
91 _ uint16
92 CommonAttr uint32
93 VolAttr uint32
94 DirAttr uint32
95 FileAttr uint32
96 Forkattr uint32
97}
98
99func getAttrList(path string, attrList attrList, attrBuf []byte, options uint) (attrs [][]byte, err error) {
100 if len(attrBuf) < 4 {
101 return nil, errors.New("attrBuf too small")
102 }
103 attrList.bitmapCount = attrBitMapCount
104
105 var _p0 *byte
106 _p0, err = BytePtrFromString(path)
107 if err != nil {
108 return nil, err
109 }
110
111 if err := getattrlist(_p0, unsafe.Pointer(&attrList), unsafe.Pointer(&attrBuf[0]), uintptr(len(attrBuf)), int(options)); err != nil {
112 return nil, err
113 }
114 size := *(*uint32)(unsafe.Pointer(&attrBuf[0]))
115
116 // dat is the section of attrBuf that contains valid data,
117 // without the 4 byte length header. All attribute offsets
118 // are relative to dat.
119 dat := attrBuf
120 if int(size) < len(attrBuf) {
121 dat = dat[:size]
122 }
123 dat = dat[4:] // remove length prefix
124
125 for i := uint32(0); int(i) < len(dat); {
126 header := dat[i:]
127 if len(header) < 8 {
128 return attrs, errors.New("truncated attribute header")
129 }
130 datOff := *(*int32)(unsafe.Pointer(&header[0]))
131 attrLen := *(*uint32)(unsafe.Pointer(&header[4]))
132 if datOff < 0 || uint32(datOff)+attrLen > uint32(len(dat)) {
133 return attrs, errors.New("truncated results; attrBuf too small")
134 }
135 end := uint32(datOff) + attrLen
136 attrs = append(attrs, dat[datOff:end])
137 i = end
138 if r := i % 4; r != 0 {
139 i += (4 - r)
140 }
141 }
142 return
143}
144
145//sys getattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error)
146
Don Newton98fd8812019-09-23 15:15:02 -0400147//sysnb pipe() (r int, w int, err error)
148
149func Pipe(p []int) (err error) {
150 if len(p) != 2 {
151 return EINVAL
152 }
153 p[0], p[1], err = pipe()
154 return
155}
156
157func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
158 var _p0 unsafe.Pointer
159 var bufsize uintptr
160 if len(buf) > 0 {
161 _p0 = unsafe.Pointer(&buf[0])
162 bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
163 }
164 return getfsstat(_p0, bufsize, flags)
165}
166
167func xattrPointer(dest []byte) *byte {
168 // It's only when dest is set to NULL that the OS X implementations of
169 // getxattr() and listxattr() return the current sizes of the named attributes.
170 // An empty byte array is not sufficient. To maintain the same behaviour as the
171 // linux implementation, we wrap around the system calls and pass in NULL when
172 // dest is empty.
173 var destp *byte
174 if len(dest) > 0 {
175 destp = &dest[0]
176 }
177 return destp
178}
179
180//sys getxattr(path string, attr string, dest *byte, size int, position uint32, options int) (sz int, err error)
181
182func Getxattr(path string, attr string, dest []byte) (sz int, err error) {
183 return getxattr(path, attr, xattrPointer(dest), len(dest), 0, 0)
184}
185
186func Lgetxattr(link string, attr string, dest []byte) (sz int, err error) {
187 return getxattr(link, attr, xattrPointer(dest), len(dest), 0, XATTR_NOFOLLOW)
188}
189
190//sys fgetxattr(fd int, attr string, dest *byte, size int, position uint32, options int) (sz int, err error)
191
192func Fgetxattr(fd int, attr string, dest []byte) (sz int, err error) {
193 return fgetxattr(fd, attr, xattrPointer(dest), len(dest), 0, 0)
194}
195
196//sys setxattr(path string, attr string, data *byte, size int, position uint32, options int) (err error)
197
198func Setxattr(path string, attr string, data []byte, flags int) (err error) {
199 // The parameters for the OS X implementation vary slightly compared to the
200 // linux system call, specifically the position parameter:
201 //
202 // linux:
203 // int setxattr(
204 // const char *path,
205 // const char *name,
206 // const void *value,
207 // size_t size,
208 // int flags
209 // );
210 //
211 // darwin:
212 // int setxattr(
213 // const char *path,
214 // const char *name,
215 // void *value,
216 // size_t size,
217 // u_int32_t position,
218 // int options
219 // );
220 //
221 // position specifies the offset within the extended attribute. In the
222 // current implementation, only the resource fork extended attribute makes
223 // use of this argument. For all others, position is reserved. We simply
224 // default to setting it to zero.
225 return setxattr(path, attr, xattrPointer(data), len(data), 0, flags)
226}
227
228func Lsetxattr(link string, attr string, data []byte, flags int) (err error) {
229 return setxattr(link, attr, xattrPointer(data), len(data), 0, flags|XATTR_NOFOLLOW)
230}
231
232//sys fsetxattr(fd int, attr string, data *byte, size int, position uint32, options int) (err error)
233
234func Fsetxattr(fd int, attr string, data []byte, flags int) (err error) {
235 return fsetxattr(fd, attr, xattrPointer(data), len(data), 0, 0)
236}
237
238//sys removexattr(path string, attr string, options int) (err error)
239
240func Removexattr(path string, attr string) (err error) {
241 // We wrap around and explicitly zero out the options provided to the OS X
242 // implementation of removexattr, we do so for interoperability with the
243 // linux variant.
244 return removexattr(path, attr, 0)
245}
246
247func Lremovexattr(link string, attr string) (err error) {
248 return removexattr(link, attr, XATTR_NOFOLLOW)
249}
250
251//sys fremovexattr(fd int, attr string, options int) (err error)
252
253func Fremovexattr(fd int, attr string) (err error) {
254 return fremovexattr(fd, attr, 0)
255}
256
257//sys listxattr(path string, dest *byte, size int, options int) (sz int, err error)
258
259func Listxattr(path string, dest []byte) (sz int, err error) {
260 return listxattr(path, xattrPointer(dest), len(dest), 0)
261}
262
263func Llistxattr(link string, dest []byte) (sz int, err error) {
264 return listxattr(link, xattrPointer(dest), len(dest), XATTR_NOFOLLOW)
265}
266
267//sys flistxattr(fd int, dest *byte, size int, options int) (sz int, err error)
268
269func Flistxattr(fd int, dest []byte) (sz int, err error) {
270 return flistxattr(fd, xattrPointer(dest), len(dest), 0)
271}
272
273func setattrlistTimes(path string, times []Timespec, flags int) error {
274 _p0, err := BytePtrFromString(path)
275 if err != nil {
276 return err
277 }
278
279 var attrList attrList
280 attrList.bitmapCount = ATTR_BIT_MAP_COUNT
281 attrList.CommonAttr = ATTR_CMN_MODTIME | ATTR_CMN_ACCTIME
282
283 // order is mtime, atime: the opposite of Chtimes
284 attributes := [2]Timespec{times[1], times[0]}
285 options := 0
286 if flags&AT_SYMLINK_NOFOLLOW != 0 {
287 options |= FSOPT_NOFOLLOW
288 }
289 return setattrlist(
290 _p0,
291 unsafe.Pointer(&attrList),
292 unsafe.Pointer(&attributes),
293 unsafe.Sizeof(attributes),
294 options)
295}
296
297//sys setattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error)
298
299func utimensat(dirfd int, path string, times *[2]Timespec, flags int) error {
300 // Darwin doesn't support SYS_UTIMENSAT
301 return ENOSYS
302}
303
304/*
305 * Wrapped
306 */
307
308//sys kill(pid int, signum int, posix int) (err error)
309
310func Kill(pid int, signum syscall.Signal) (err error) { return kill(pid, int(signum), 1) }
311
312//sys ioctl(fd int, req uint, arg uintptr) (err error)
313
Don Newtone0d34a82019-11-14 10:58:06 -0500314// ioctl itself should not be exposed directly, but additional get/set
315// functions for specific types are permissible.
316
317// IoctlSetInt performs an ioctl operation which sets an integer value
318// on fd, using the specified request number.
319func IoctlSetInt(fd int, req uint, value int) error {
320 return ioctl(fd, req, uintptr(value))
321}
322
323func ioctlSetWinsize(fd int, req uint, value *Winsize) error {
324 return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
325}
326
327func ioctlSetTermios(fd int, req uint, value *Termios) error {
328 return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
329}
330
331// IoctlGetInt performs an ioctl operation which gets an integer value
332// from fd, using the specified request number.
333func IoctlGetInt(fd int, req uint) (int, error) {
334 var value int
335 err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
336 return value, err
337}
338
339func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
340 var value Winsize
341 err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
342 return &value, err
343}
344
345func IoctlGetTermios(fd int, req uint) (*Termios, error) {
346 var value Termios
347 err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
348 return &value, err
349}
350
Don Newton98fd8812019-09-23 15:15:02 -0400351func Uname(uname *Utsname) error {
352 mib := []_C_int{CTL_KERN, KERN_OSTYPE}
353 n := unsafe.Sizeof(uname.Sysname)
354 if err := sysctl(mib, &uname.Sysname[0], &n, nil, 0); err != nil {
355 return err
356 }
357
358 mib = []_C_int{CTL_KERN, KERN_HOSTNAME}
359 n = unsafe.Sizeof(uname.Nodename)
360 if err := sysctl(mib, &uname.Nodename[0], &n, nil, 0); err != nil {
361 return err
362 }
363
364 mib = []_C_int{CTL_KERN, KERN_OSRELEASE}
365 n = unsafe.Sizeof(uname.Release)
366 if err := sysctl(mib, &uname.Release[0], &n, nil, 0); err != nil {
367 return err
368 }
369
370 mib = []_C_int{CTL_KERN, KERN_VERSION}
371 n = unsafe.Sizeof(uname.Version)
372 if err := sysctl(mib, &uname.Version[0], &n, nil, 0); err != nil {
373 return err
374 }
375
376 // The version might have newlines or tabs in it, convert them to
377 // spaces.
378 for i, b := range uname.Version {
379 if b == '\n' || b == '\t' {
380 if i == len(uname.Version)-1 {
381 uname.Version[i] = 0
382 } else {
383 uname.Version[i] = ' '
384 }
385 }
386 }
387
388 mib = []_C_int{CTL_HW, HW_MACHINE}
389 n = unsafe.Sizeof(uname.Machine)
390 if err := sysctl(mib, &uname.Machine[0], &n, nil, 0); err != nil {
391 return err
392 }
393
394 return nil
395}
396
397func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
398 if raceenabled {
399 raceReleaseMerge(unsafe.Pointer(&ioSync))
400 }
401 var length = int64(count)
402 err = sendfile(infd, outfd, *offset, &length, nil, 0)
403 written = int(length)
404 return
405}
406
407//sys sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error)
408
409/*
410 * Exposed directly
411 */
412//sys Access(path string, mode uint32) (err error)
413//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
414//sys Chdir(path string) (err error)
415//sys Chflags(path string, flags int) (err error)
416//sys Chmod(path string, mode uint32) (err error)
417//sys Chown(path string, uid int, gid int) (err error)
418//sys Chroot(path string) (err error)
419//sys ClockGettime(clockid int32, time *Timespec) (err error)
420//sys Close(fd int) (err error)
421//sys Dup(fd int) (nfd int, err error)
422//sys Dup2(from int, to int) (err error)
423//sys Exchangedata(path1 string, path2 string, options int) (err error)
424//sys Exit(code int)
425//sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
426//sys Fchdir(fd int) (err error)
427//sys Fchflags(fd int, flags int) (err error)
428//sys Fchmod(fd int, mode uint32) (err error)
429//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
430//sys Fchown(fd int, uid int, gid int) (err error)
431//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
432//sys Flock(fd int, how int) (err error)
433//sys Fpathconf(fd int, name int) (val int, err error)
434//sys Fsync(fd int) (err error)
435//sys Ftruncate(fd int, length int64) (err error)
436//sys Getdtablesize() (size int)
437//sysnb Getegid() (egid int)
438//sysnb Geteuid() (uid int)
439//sysnb Getgid() (gid int)
440//sysnb Getpgid(pid int) (pgid int, err error)
441//sysnb Getpgrp() (pgrp int)
442//sysnb Getpid() (pid int)
443//sysnb Getppid() (ppid int)
444//sys Getpriority(which int, who int) (prio int, err error)
445//sysnb Getrlimit(which int, lim *Rlimit) (err error)
446//sysnb Getrusage(who int, rusage *Rusage) (err error)
447//sysnb Getsid(pid int) (sid int, err error)
448//sysnb Getuid() (uid int)
449//sysnb Issetugid() (tainted bool)
450//sys Kqueue() (fd int, err error)
451//sys Lchown(path string, uid int, gid int) (err error)
452//sys Link(path string, link string) (err error)
453//sys Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error)
454//sys Listen(s int, backlog int) (err error)
455//sys Mkdir(path string, mode uint32) (err error)
456//sys Mkdirat(dirfd int, path string, mode uint32) (err error)
457//sys Mkfifo(path string, mode uint32) (err error)
458//sys Mknod(path string, mode uint32, dev int) (err error)
459//sys Open(path string, mode int, perm uint32) (fd int, err error)
460//sys Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error)
461//sys Pathconf(path string, name int) (val int, err error)
462//sys Pread(fd int, p []byte, offset int64) (n int, err error)
463//sys Pwrite(fd int, p []byte, offset int64) (n int, err error)
464//sys read(fd int, p []byte) (n int, err error)
465//sys Readlink(path string, buf []byte) (n int, err error)
466//sys Readlinkat(dirfd int, path string, buf []byte) (n int, err error)
467//sys Rename(from string, to string) (err error)
468//sys Renameat(fromfd int, from string, tofd int, to string) (err error)
469//sys Revoke(path string) (err error)
470//sys Rmdir(path string) (err error)
471//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
472//sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error)
473//sys Setegid(egid int) (err error)
474//sysnb Seteuid(euid int) (err error)
475//sysnb Setgid(gid int) (err error)
476//sys Setlogin(name string) (err error)
477//sysnb Setpgid(pid int, pgid int) (err error)
478//sys Setpriority(which int, who int, prio int) (err error)
479//sys Setprivexec(flag int) (err error)
480//sysnb Setregid(rgid int, egid int) (err error)
481//sysnb Setreuid(ruid int, euid int) (err error)
482//sysnb Setrlimit(which int, lim *Rlimit) (err error)
483//sysnb Setsid() (pid int, err error)
484//sysnb Settimeofday(tp *Timeval) (err error)
485//sysnb Setuid(uid int) (err error)
486//sys Symlink(path string, link string) (err error)
487//sys Symlinkat(oldpath string, newdirfd int, newpath string) (err error)
488//sys Sync() (err error)
489//sys Truncate(path string, length int64) (err error)
490//sys Umask(newmask int) (oldmask int)
491//sys Undelete(path string) (err error)
492//sys Unlink(path string) (err error)
493//sys Unlinkat(dirfd int, path string, flags int) (err error)
494//sys Unmount(path string, flags int) (err error)
495//sys write(fd int, p []byte) (n int, err error)
496//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
497//sys munmap(addr uintptr, length uintptr) (err error)
498//sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
499//sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
500
501/*
502 * Unimplemented
503 */
504// Profil
505// Sigaction
506// Sigprocmask
507// Getlogin
508// Sigpending
509// Sigaltstack
510// Ioctl
511// Reboot
512// Execve
513// Vfork
514// Sbrk
515// Sstk
516// Ovadvise
517// Mincore
518// Setitimer
519// Swapon
520// Select
521// Sigsuspend
522// Readv
523// Writev
524// Nfssvc
525// Getfh
526// Quotactl
527// Mount
528// Csops
529// Waitid
530// Add_profil
531// Kdebug_trace
532// Sigreturn
533// Atsocket
534// Kqueue_from_portset_np
535// Kqueue_portset
536// Getattrlist
537// Setattrlist
538// Getdirentriesattr
539// Searchfs
540// Delete
541// Copyfile
542// Watchevent
543// Waitevent
544// Modwatch
545// Fsctl
546// Initgroups
547// Posix_spawn
548// Nfsclnt
549// Fhopen
550// Minherit
551// Semsys
552// Msgsys
553// Shmsys
554// Semctl
555// Semget
556// Semop
557// Msgctl
558// Msgget
559// Msgsnd
560// Msgrcv
561// Shmat
562// Shmctl
563// Shmdt
564// Shmget
565// Shm_open
566// Shm_unlink
567// Sem_open
568// Sem_close
569// Sem_unlink
570// Sem_wait
571// Sem_trywait
572// Sem_post
573// Sem_getvalue
574// Sem_init
575// Sem_destroy
576// Open_extended
577// Umask_extended
578// Stat_extended
579// Lstat_extended
580// Fstat_extended
581// Chmod_extended
582// Fchmod_extended
583// Access_extended
584// Settid
585// Gettid
586// Setsgroups
587// Getsgroups
588// Setwgroups
589// Getwgroups
590// Mkfifo_extended
591// Mkdir_extended
592// Identitysvc
593// Shared_region_check_np
594// Shared_region_map_np
595// __pthread_mutex_destroy
596// __pthread_mutex_init
597// __pthread_mutex_lock
598// __pthread_mutex_trylock
599// __pthread_mutex_unlock
600// __pthread_cond_init
601// __pthread_cond_destroy
602// __pthread_cond_broadcast
603// __pthread_cond_signal
604// Setsid_with_pid
605// __pthread_cond_timedwait
606// Aio_fsync
607// Aio_return
608// Aio_suspend
609// Aio_cancel
610// Aio_error
611// Aio_read
612// Aio_write
613// Lio_listio
614// __pthread_cond_wait
615// Iopolicysys
616// __pthread_kill
617// __pthread_sigmask
618// __sigwait
619// __disable_threadsignal
620// __pthread_markcancel
621// __pthread_canceled
622// __semwait_signal
623// Proc_info
624// sendfile
625// Stat64_extended
626// Lstat64_extended
627// Fstat64_extended
628// __pthread_chdir
629// __pthread_fchdir
630// Audit
631// Auditon
632// Getauid
633// Setauid
634// Getaudit
635// Setaudit
636// Getaudit_addr
637// Setaudit_addr
638// Auditctl
639// Bsdthread_create
640// Bsdthread_terminate
641// Stack_snapshot
642// Bsdthread_register
643// Workq_open
644// Workq_ops
645// __mac_execve
646// __mac_syscall
647// __mac_get_file
648// __mac_set_file
649// __mac_get_link
650// __mac_set_link
651// __mac_get_proc
652// __mac_set_proc
653// __mac_get_fd
654// __mac_set_fd
655// __mac_get_pid
656// __mac_get_lcid
657// __mac_get_lctx
658// __mac_set_lctx
659// Setlcid
660// Read_nocancel
661// Write_nocancel
662// Open_nocancel
663// Close_nocancel
664// Wait4_nocancel
665// Recvmsg_nocancel
666// Sendmsg_nocancel
667// Recvfrom_nocancel
668// Accept_nocancel
669// Fcntl_nocancel
670// Select_nocancel
671// Fsync_nocancel
672// Connect_nocancel
673// Sigsuspend_nocancel
674// Readv_nocancel
675// Writev_nocancel
676// Sendto_nocancel
677// Pread_nocancel
678// Pwrite_nocancel
679// Waitid_nocancel
680// Poll_nocancel
681// Msgsnd_nocancel
682// Msgrcv_nocancel
683// Sem_wait_nocancel
684// Aio_suspend_nocancel
685// __sigwait_nocancel
686// __semwait_signal_nocancel
687// __mac_mount
688// __mac_get_mount
689// __mac_getfsstat