...
1
2
3
4
5
6
7 package unix
8
9 import (
10 "syscall"
11 "unsafe"
12 )
13
14 func Unlinkat(dirfd int, path string, flags int) error {
15 p, err := syscall.BytePtrFromString(path)
16 if err != nil {
17 return err
18 }
19
20 _, _, errno := syscall.Syscall(unlinkatTrap, uintptr(dirfd), uintptr(unsafe.Pointer(p)), uintptr(flags))
21 if errno != 0 {
22 return errno
23 }
24
25 return nil
26 }
27
28 func Openat(dirfd int, path string, flags int, perm uint32) (int, error) {
29 p, err := syscall.BytePtrFromString(path)
30 if err != nil {
31 return 0, err
32 }
33
34 fd, _, errno := syscall.Syscall6(openatTrap, uintptr(dirfd), uintptr(unsafe.Pointer(p)), uintptr(flags), uintptr(perm), 0, 0)
35 if errno != 0 {
36 return 0, errno
37 }
38
39 return int(fd), nil
40 }
41
View as plain text