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