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