1
2
3
4
5
6 package plan9
7
8 import "unsafe"
9
10
11
12 func fd2path(fd int, buf []byte) (err error) {
13 var _p0 unsafe.Pointer
14 if len(buf) > 0 {
15 _p0 = unsafe.Pointer(&buf[0])
16 } else {
17 _p0 = unsafe.Pointer(&_zero)
18 }
19 r0, _, e1 := Syscall(SYS_FD2PATH, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
20 if int32(r0) == -1 {
21 err = e1
22 }
23 return
24 }
25
26
27
28 func pipe(p *[2]int32) (err error) {
29 r0, _, e1 := Syscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0)
30 if int32(r0) == -1 {
31 err = e1
32 }
33 return
34 }
35
36
37
38 func await(s []byte) (n int, err error) {
39 var _p0 unsafe.Pointer
40 if len(s) > 0 {
41 _p0 = unsafe.Pointer(&s[0])
42 } else {
43 _p0 = unsafe.Pointer(&_zero)
44 }
45 r0, _, e1 := Syscall(SYS_AWAIT, uintptr(_p0), uintptr(len(s)), 0)
46 n = int(r0)
47 if int32(r0) == -1 {
48 err = e1
49 }
50 return
51 }
52
53
54
55 func open(path string, mode int) (fd int, err error) {
56 var _p0 *byte
57 _p0, err = BytePtrFromString(path)
58 if err != nil {
59 return
60 }
61 r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
62 fd = int(r0)
63 if int32(r0) == -1 {
64 err = e1
65 }
66 return
67 }
68
69
70
71 func create(path string, mode int, perm uint32) (fd int, err error) {
72 var _p0 *byte
73 _p0, err = BytePtrFromString(path)
74 if err != nil {
75 return
76 }
77 r0, _, e1 := Syscall(SYS_CREATE, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
78 fd = int(r0)
79 if int32(r0) == -1 {
80 err = e1
81 }
82 return
83 }
84
85
86
87 func remove(path string) (err error) {
88 var _p0 *byte
89 _p0, err = BytePtrFromString(path)
90 if err != nil {
91 return
92 }
93 r0, _, e1 := Syscall(SYS_REMOVE, uintptr(unsafe.Pointer(_p0)), 0, 0)
94 if int32(r0) == -1 {
95 err = e1
96 }
97 return
98 }
99
100
101
102 func stat(path string, edir []byte) (n int, err error) {
103 var _p0 *byte
104 _p0, err = BytePtrFromString(path)
105 if err != nil {
106 return
107 }
108 var _p1 unsafe.Pointer
109 if len(edir) > 0 {
110 _p1 = unsafe.Pointer(&edir[0])
111 } else {
112 _p1 = unsafe.Pointer(&_zero)
113 }
114 r0, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(edir)))
115 n = int(r0)
116 if int32(r0) == -1 {
117 err = e1
118 }
119 return
120 }
121
122
123
124 func bind(name string, old string, flag int) (err error) {
125 var _p0 *byte
126 _p0, err = BytePtrFromString(name)
127 if err != nil {
128 return
129 }
130 var _p1 *byte
131 _p1, err = BytePtrFromString(old)
132 if err != nil {
133 return
134 }
135 r0, _, e1 := Syscall(SYS_BIND, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flag))
136 if int32(r0) == -1 {
137 err = e1
138 }
139 return
140 }
141
142
143
144 func mount(fd int, afd int, old string, flag int, aname string) (err error) {
145 var _p0 *byte
146 _p0, err = BytePtrFromString(old)
147 if err != nil {
148 return
149 }
150 var _p1 *byte
151 _p1, err = BytePtrFromString(aname)
152 if err != nil {
153 return
154 }
155 r0, _, e1 := Syscall6(SYS_MOUNT, uintptr(fd), uintptr(afd), uintptr(unsafe.Pointer(_p0)), uintptr(flag), uintptr(unsafe.Pointer(_p1)), 0)
156 if int32(r0) == -1 {
157 err = e1
158 }
159 return
160 }
161
162
163
164 func wstat(path string, edir []byte) (err error) {
165 var _p0 *byte
166 _p0, err = BytePtrFromString(path)
167 if err != nil {
168 return
169 }
170 var _p1 unsafe.Pointer
171 if len(edir) > 0 {
172 _p1 = unsafe.Pointer(&edir[0])
173 } else {
174 _p1 = unsafe.Pointer(&_zero)
175 }
176 r0, _, e1 := Syscall(SYS_WSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(edir)))
177 if int32(r0) == -1 {
178 err = e1
179 }
180 return
181 }
182
183
184
185 func chdir(path string) (err error) {
186 var _p0 *byte
187 _p0, err = BytePtrFromString(path)
188 if err != nil {
189 return
190 }
191 r0, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
192 if int32(r0) == -1 {
193 err = e1
194 }
195 return
196 }
197
198
199
200 func Dup(oldfd int, newfd int) (fd int, err error) {
201 r0, _, e1 := Syscall(SYS_DUP, uintptr(oldfd), uintptr(newfd), 0)
202 fd = int(r0)
203 if int32(r0) == -1 {
204 err = e1
205 }
206 return
207 }
208
209
210
211 func Pread(fd int, p []byte, offset int64) (n int, err error) {
212 var _p0 unsafe.Pointer
213 if len(p) > 0 {
214 _p0 = unsafe.Pointer(&p[0])
215 } else {
216 _p0 = unsafe.Pointer(&_zero)
217 }
218 r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
219 n = int(r0)
220 if int32(r0) == -1 {
221 err = e1
222 }
223 return
224 }
225
226
227
228 func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
229 var _p0 unsafe.Pointer
230 if len(p) > 0 {
231 _p0 = unsafe.Pointer(&p[0])
232 } else {
233 _p0 = unsafe.Pointer(&_zero)
234 }
235 r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
236 n = int(r0)
237 if int32(r0) == -1 {
238 err = e1
239 }
240 return
241 }
242
243
244
245 func Close(fd int) (err error) {
246 r0, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
247 if int32(r0) == -1 {
248 err = e1
249 }
250 return
251 }
252
253
254
255 func Fstat(fd int, edir []byte) (n int, err error) {
256 var _p0 unsafe.Pointer
257 if len(edir) > 0 {
258 _p0 = unsafe.Pointer(&edir[0])
259 } else {
260 _p0 = unsafe.Pointer(&_zero)
261 }
262 r0, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(_p0), uintptr(len(edir)))
263 n = int(r0)
264 if int32(r0) == -1 {
265 err = e1
266 }
267 return
268 }
269
270
271
272 func Fwstat(fd int, edir []byte) (err error) {
273 var _p0 unsafe.Pointer
274 if len(edir) > 0 {
275 _p0 = unsafe.Pointer(&edir[0])
276 } else {
277 _p0 = unsafe.Pointer(&_zero)
278 }
279 r0, _, e1 := Syscall(SYS_FWSTAT, uintptr(fd), uintptr(_p0), uintptr(len(edir)))
280 if int32(r0) == -1 {
281 err = e1
282 }
283 return
284 }
285
View as plain text