Mercurial > yakumo_izuru > aya
comparison vendor/golang.org/x/sys/unix/syscall_linux.go @ 68:4b79810863f6 draft
Ready to release 0.6.0
Signed-off-by: Izuru Yakumo <yakumo.izuru@chaotic.ninja>
author | yakumo.izuru |
---|---|
date | Wed, 13 Sep 2023 10:49:50 +0000 |
parents | 787b5ee0289d |
children |
comparison
equal
deleted
inserted
replaced
67:4edfa07d5fe0 | 68:4b79810863f6 |
---|---|
11 | 11 |
12 package unix | 12 package unix |
13 | 13 |
14 import ( | 14 import ( |
15 "encoding/binary" | 15 "encoding/binary" |
16 "strconv" | |
16 "syscall" | 17 "syscall" |
17 "time" | 18 "time" |
18 "unsafe" | 19 "unsafe" |
19 ) | 20 ) |
20 | 21 |
231 } | 232 } |
232 | 233 |
233 func Futimes(fd int, tv []Timeval) (err error) { | 234 func Futimes(fd int, tv []Timeval) (err error) { |
234 // Believe it or not, this is the best we can do on Linux | 235 // Believe it or not, this is the best we can do on Linux |
235 // (and is what glibc does). | 236 // (and is what glibc does). |
236 return Utimes("/proc/self/fd/"+itoa(fd), tv) | 237 return Utimes("/proc/self/fd/"+strconv.Itoa(fd), tv) |
237 } | 238 } |
238 | 239 |
239 const ImplementsGetwd = true | 240 const ImplementsGetwd = true |
240 | 241 |
241 //sys Getcwd(buf []byte) (n int, err error) | 242 //sys Getcwd(buf []byte) (n int, err error) |
1539 msg.Name = (*byte)(ptr) | 1540 msg.Name = (*byte)(ptr) |
1540 msg.Namelen = uint32(salen) | 1541 msg.Namelen = uint32(salen) |
1541 var dummy byte | 1542 var dummy byte |
1542 var empty bool | 1543 var empty bool |
1543 if len(oob) > 0 { | 1544 if len(oob) > 0 { |
1544 empty := emptyIovecs(iov) | 1545 empty = emptyIovecs(iov) |
1545 if empty { | 1546 if empty { |
1546 var sockType int | 1547 var sockType int |
1547 sockType, err = GetsockoptInt(fd, SOL_SOCKET, SO_TYPE) | 1548 sockType, err = GetsockoptInt(fd, SOL_SOCKET, SO_TYPE) |
1548 if err != nil { | 1549 if err != nil { |
1549 return 0, err | 1550 return 0, err |
1889 return 0, err | 1890 return 0, err |
1890 } | 1891 } |
1891 return int(ret), nil | 1892 return int(ret), nil |
1892 } | 1893 } |
1893 | 1894 |
1894 // issue 1435. | |
1895 // On linux Setuid and Setgid only affects the current thread, not the process. | |
1896 // This does not match what most callers expect so we must return an error | |
1897 // here rather than letting the caller think that the call succeeded. | |
1898 | |
1899 func Setuid(uid int) (err error) { | 1895 func Setuid(uid int) (err error) { |
1900 return EOPNOTSUPP | 1896 return syscall.Setuid(uid) |
1901 } | 1897 } |
1902 | 1898 |
1903 func Setgid(uid int) (err error) { | 1899 func Setgid(gid int) (err error) { |
1904 return EOPNOTSUPP | 1900 return syscall.Setgid(gid) |
1901 } | |
1902 | |
1903 func Setreuid(ruid, euid int) (err error) { | |
1904 return syscall.Setreuid(ruid, euid) | |
1905 } | |
1906 | |
1907 func Setregid(rgid, egid int) (err error) { | |
1908 return syscall.Setregid(rgid, egid) | |
1909 } | |
1910 | |
1911 func Setresuid(ruid, euid, suid int) (err error) { | |
1912 return syscall.Setresuid(ruid, euid, suid) | |
1913 } | |
1914 | |
1915 func Setresgid(rgid, egid, sgid int) (err error) { | |
1916 return syscall.Setresgid(rgid, egid, sgid) | |
1905 } | 1917 } |
1906 | 1918 |
1907 // SetfsgidRetGid sets fsgid for current thread and returns previous fsgid set. | 1919 // SetfsgidRetGid sets fsgid for current thread and returns previous fsgid set. |
1908 // setfsgid(2) will return a non-nil error only if its caller lacks CAP_SETUID capability. | 1920 // setfsgid(2) will return a non-nil error only if its caller lacks CAP_SETUID capability. |
1909 // If the call fails due to other reasons, current fsgid will be returned. | 1921 // If the call fails due to other reasons, current fsgid will be returned. |
2238 func (fh *FileHandle) Bytes() []byte { | 2250 func (fh *FileHandle) Bytes() []byte { |
2239 n := fh.Size() | 2251 n := fh.Size() |
2240 if n == 0 { | 2252 if n == 0 { |
2241 return nil | 2253 return nil |
2242 } | 2254 } |
2243 return (*[1 << 30]byte)(unsafe.Pointer(uintptr(unsafe.Pointer(&fh.fileHandle.Type)) + 4))[:n:n] | 2255 return unsafe.Slice((*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(&fh.fileHandle.Type))+4)), n) |
2244 } | 2256 } |
2245 | 2257 |
2246 // NameToHandleAt wraps the name_to_handle_at system call; it obtains | 2258 // NameToHandleAt wraps the name_to_handle_at system call; it obtains |
2247 // a handle for a path name. | 2259 // a handle for a path name. |
2248 func NameToHandleAt(dirfd int, path string, flags int) (handle FileHandle, mountID int, err error) { | 2260 func NameToHandleAt(dirfd int, path string, flags int) (handle FileHandle, mountID int, err error) { |
2352 if err := setitimer(int(which), &it, &prev); err != nil { | 2364 if err := setitimer(int(which), &it, &prev); err != nil { |
2353 return Itimerval{}, err | 2365 return Itimerval{}, err |
2354 } | 2366 } |
2355 | 2367 |
2356 return prev, nil | 2368 return prev, nil |
2369 } | |
2370 | |
2371 //sysnb rtSigprocmask(how int, set *Sigset_t, oldset *Sigset_t, sigsetsize uintptr) (err error) = SYS_RT_SIGPROCMASK | |
2372 | |
2373 func PthreadSigmask(how int, set, oldset *Sigset_t) error { | |
2374 if oldset != nil { | |
2375 // Explicitly clear in case Sigset_t is larger than _C__NSIG. | |
2376 *oldset = Sigset_t{} | |
2377 } | |
2378 return rtSigprocmask(how, set, oldset, _C__NSIG/8) | |
2357 } | 2379 } |
2358 | 2380 |
2359 /* | 2381 /* |
2360 * Unimplemented | 2382 * Unimplemented |
2361 */ | 2383 */ |
2412 // Readv | 2434 // Readv |
2413 // RemapFilePages | 2435 // RemapFilePages |
2414 // RestartSyscall | 2436 // RestartSyscall |
2415 // RtSigaction | 2437 // RtSigaction |
2416 // RtSigpending | 2438 // RtSigpending |
2417 // RtSigprocmask | |
2418 // RtSigqueueinfo | 2439 // RtSigqueueinfo |
2419 // RtSigreturn | 2440 // RtSigreturn |
2420 // RtSigsuspend | 2441 // RtSigsuspend |
2421 // RtSigtimedwait | 2442 // RtSigtimedwait |
2422 // SchedGetPriorityMax | 2443 // SchedGetPriorityMax |