1
2
3
4
5
6
7 package unix
8
9 import "unsafe"
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
30 var ts *Timespec
31 if timeout != nil {
32 ts = &Timespec{Sec: timeout.Sec, Nsec: timeout.Usec * 1000}
33 }
34 return pselect6(nfd, r, w, e, ts, nil)
35 }
36
37
38
39
40
41
42
43 func Stat(path string, stat *Stat_t) (err error) {
44 return Fstatat(AT_FDCWD, path, stat, 0)
45 }
46
47 func Lchown(path string, uid int, gid int) (err error) {
48 return Fchownat(AT_FDCWD, path, uid, gid, AT_SYMLINK_NOFOLLOW)
49 }
50
51 func Lstat(path string, stat *Stat_t) (err error) {
52 return Fstatat(AT_FDCWD, path, stat, AT_SYMLINK_NOFOLLOW)
53 }
54
55
56
57
58
59 func Ustat(dev int, ubuf *Ustat_t) (err error) {
60 return ENOSYS
61 }
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82 func setTimespec(sec, nsec int64) Timespec {
83 return Timespec{Sec: sec, Nsec: nsec}
84 }
85
86 func setTimeval(sec, usec int64) Timeval {
87 return Timeval{Sec: sec, Usec: usec}
88 }
89
90 func futimesat(dirfd int, path string, tv *[2]Timeval) (err error) {
91 if tv == nil {
92 return utimensat(dirfd, path, nil, 0)
93 }
94
95 ts := []Timespec{
96 NsecToTimespec(TimevalToNsec(tv[0])),
97 NsecToTimespec(TimevalToNsec(tv[1])),
98 }
99 return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
100 }
101
102 func Time(t *Time_t) (Time_t, error) {
103 var tv Timeval
104 err := Gettimeofday(&tv)
105 if err != nil {
106 return 0, err
107 }
108 if t != nil {
109 *t = Time_t(tv.Sec)
110 }
111 return Time_t(tv.Sec), nil
112 }
113
114 func Utime(path string, buf *Utimbuf) error {
115 tv := []Timeval{
116 {Sec: buf.Actime},
117 {Sec: buf.Modtime},
118 }
119 return Utimes(path, tv)
120 }
121
122 func utimes(path string, tv *[2]Timeval) (err error) {
123 if tv == nil {
124 return utimensat(AT_FDCWD, path, nil, 0)
125 }
126
127 ts := []Timespec{
128 NsecToTimespec(TimevalToNsec(tv[0])),
129 NsecToTimespec(TimevalToNsec(tv[1])),
130 }
131 return utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
132 }
133
134 func (r *PtraceRegs) PC() uint64 { return r.Pc }
135
136 func (r *PtraceRegs) SetPC(pc uint64) { r.Pc = pc }
137
138 func (iov *Iovec) SetLen(length int) {
139 iov.Len = uint64(length)
140 }
141
142 func (msghdr *Msghdr) SetControllen(length int) {
143 msghdr.Controllen = uint64(length)
144 }
145
146 func (msghdr *Msghdr) SetIovlen(length int) {
147 msghdr.Iovlen = uint64(length)
148 }
149
150 func (cmsg *Cmsghdr) SetLen(length int) {
151 cmsg.Len = uint64(length)
152 }
153
154 func (rsa *RawSockaddrNFCLLCP) SetServiceNameLen(length int) {
155 rsa.Service_name_len = uint64(length)
156 }
157
158 func Pause() error {
159 _, err := ppoll(nil, 0, nil, nil)
160 return err
161 }
162
163 func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) {
164 return Renameat2(olddirfd, oldpath, newdirfd, newpath, 0)
165 }
166
167
168
169 func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error {
170 cmdlineLen := len(cmdline)
171 if cmdlineLen > 0 {
172
173
174
175 cmdlineLen++
176 }
177 return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags)
178 }
179
180
181
182 func RISCVHWProbe(pairs []RISCVHWProbePairs, set *CPUSet, flags uint) (err error) {
183 var setSize uintptr
184
185 if set != nil {
186 setSize = uintptr(unsafe.Sizeof(*set))
187 }
188 return riscvHWProbe(pairs, setSize, set, flags)
189 }
190
View as plain text