1
2
3
4
5
6
7 package unix
8
9 import (
10 "syscall"
11 "unsafe"
12 )
13
14 const (
15
16
17
18
19 UTIME_OMIT = -0x2
20 )
21
22 func Openat(dirfd int, path string, flags int, perm uint32) (int, error) {
23 return syscall.Openat(dirfd, path, flags, perm)
24 }
25
26 func Readlinkat(dirfd int, path string, buf []byte) (int, error) {
27 var nwritten size
28 errno := path_readlink(
29 int32(dirfd),
30 unsafe.StringData(path),
31 size(len(path)),
32 &buf[0],
33 size(len(buf)),
34 &nwritten)
35 return int(nwritten), errnoErr(errno)
36
37 }
38
39 type (
40 size = uint32
41 )
42
43
44
45 func path_readlink(fd int32, path *byte, pathLen size, buf *byte, bufLen size, nwritten *size) syscall.Errno
46
47 func Mkdirat(dirfd int, path string, mode uint32) error {
48 if path == "" {
49 return syscall.EINVAL
50 }
51 return errnoErr(path_create_directory(
52 int32(dirfd),
53 unsafe.StringData(path),
54 size(len(path)),
55 ))
56 }
57
58
59
60 func path_create_directory(fd int32, path *byte, pathLen size) syscall.Errno
61
62 func errnoErr(errno syscall.Errno) error {
63 if errno == 0 {
64 return nil
65 }
66 return errno
67 }
68
View as plain text