Commit | Line | Data |
---|---|---|
84004dbf RS |
1 | /* |
2 | Copyright (C) 2010 by Ronnie Sahlberg <ronniesahlberg@gmail.com> | |
3 | ||
4 | This program is free software; you can redistribute it and/or modify | |
5 | it under the terms of the GNU Lesser General Public License as published by | |
6 | the Free Software Foundation; either version 2.1 of the License, or | |
7 | (at your option) any later version. | |
8 | ||
9 | This program is distributed in the hope that it will be useful, | |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | GNU Lesser General Public License for more details. | |
13 | ||
14 | You should have received a copy of the GNU Lesser General Public License | |
15 | along with this program; if not, see <http://www.gnu.org/licenses/>. | |
16 | */ | |
17 | /* | |
18 | * This is the highlevel interface to access NFS resources using a posix-like interface | |
19 | */ | |
20 | #include <stdint.h> | |
21 | ||
22 | struct nfs_context; | |
7f0242ca | 23 | struct rpc_context; |
84004dbf | 24 | |
eecdc4f3 RS |
25 | #if defined(WIN32) |
26 | struct statvfs { | |
27 | uint32_t f_bsize; | |
28 | uint32_t f_frsize; | |
29 | uint64_t f_blocks; | |
30 | uint64_t f_bfree; | |
31 | uint64_t f_bavail; | |
32 | uint32_t f_files; | |
33 | uint32_t f_ffree; | |
34 | uint32_t f_favail; | |
35 | uint32_t f_fsid; | |
36 | uint32_t f_flag; | |
37 | uint32_t f_namemax; | |
38 | }; | |
39 | struct utimbuf { | |
40 | time_t actime; | |
41 | time_t modtime; | |
42 | }; | |
43 | #define R_OK 4 | |
44 | #define W_OK 2 | |
45 | #define X_OK 1 | |
46 | #endif | |
47 | ||
84004dbf RS |
48 | /* |
49 | * Used for interfacing the async version of the api into an external eventsystem | |
50 | */ | |
51 | int nfs_get_fd(struct nfs_context *nfs); | |
52 | int nfs_which_events(struct nfs_context *nfs); | |
53 | int nfs_service(struct nfs_context *nfs, int revents); | |
54 | ||
55 | /* | |
56 | * Used if you need different credentials than the default for the current user. | |
57 | */ | |
58 | struct AUTH; | |
59 | void nfs_set_auth(struct nfs_context *nfs, struct AUTH *auth); | |
60 | ||
61 | ||
62 | /* | |
63 | * When an operation failed, this function can extract a detailed error string. | |
64 | */ | |
65 | char *nfs_get_error(struct nfs_context *nfs); | |
66 | ||
67 | ||
68 | /* | |
69 | * Callback for all ASYNC nfs functions | |
70 | */ | |
71 | typedef void (*nfs_cb)(int err, struct nfs_context *nfs, void *data, void *private_data); | |
72 | ||
7f0242ca RS |
73 | /* |
74 | * Callback for all ASYNC rpc functions | |
75 | */ | |
76 | typedef void (*rpc_cb)(struct rpc_context *rpc, int status, void *data, void *private_data); | |
84004dbf RS |
77 | |
78 | ||
79 | ||
80 | /* | |
81 | * NFS CONTEXT. | |
82 | */ | |
83 | /* | |
84 | * Create an NFS c, the context. | |
85 | * Function returns | |
86 | * NULL : Failed to create a context. | |
87 | * *nfs : A pointer to an nfs context. | |
88 | */ | |
89 | struct nfs_context *nfs_init_context(void); | |
90 | /* | |
91 | * Destroy an nfs context. | |
92 | */ | |
93 | void nfs_destroy_context(struct nfs_context *nfs); | |
94 | ||
95 | ||
96 | struct nfsfh; | |
97 | ||
17ef62fa RS |
98 | /* |
99 | * Get the maximum supported READ3 size by the server | |
100 | */ | |
101 | size_t nfs_get_readmax(struct nfs_context *nfs); | |
102 | ||
103 | /* | |
104 | * Get the maximum supported WRITE3 size by the server | |
105 | */ | |
106 | size_t nfs_get_writemax(struct nfs_context *nfs); | |
107 | ||
84004dbf RS |
108 | |
109 | /* | |
110 | * MOUNT THE EXPORT | |
111 | */ | |
112 | /* | |
113 | * Async nfs mount. | |
114 | * Function returns | |
115 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
116 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
117 | * | |
118 | * When the callback is invoked, status indicates the result: | |
119 | * 0 : Success. | |
120 | * data is NULL | |
121 | * -errno : An error occured. | |
122 | * data is the error string. | |
123 | */ | |
d6ced294 | 124 | int nfs_mount_async(struct nfs_context *nfs, const char *server, const char *exportname, nfs_cb cb, void *private_data); |
84004dbf RS |
125 | /* |
126 | * Sync nfs mount. | |
127 | * Function returns | |
128 | * 0 : The operation was successfull. | |
129 | * -errno : The command failed. | |
130 | */ | |
e2ba5764 | 131 | int nfs_mount(struct nfs_context *nfs, const char *server, const char *exportname); |
84004dbf RS |
132 | |
133 | ||
134 | ||
135 | ||
136 | /* | |
137 | * STAT() | |
138 | */ | |
139 | /* | |
140 | * Async stat(<filename>) | |
141 | * Function returns | |
142 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
143 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
144 | * | |
145 | * When the callback is invoked, status indicates the result: | |
146 | * 0 : Success. | |
147 | * data is struct stat * | |
148 | * -errno : An error occured. | |
149 | * data is the error string. | |
150 | */ | |
151 | struct stat; | |
152 | int nfs_stat_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data); | |
153 | /* | |
154 | * Sync stat(<filename>) | |
155 | * Function returns | |
156 | * 0 : The operation was successfull. | |
157 | * -errno : The command failed. | |
158 | */ | |
e2ba5764 | 159 | int nfs_stat(struct nfs_context *nfs, const char *path, struct stat *st); |
84004dbf RS |
160 | |
161 | ||
162 | /* | |
163 | * FSTAT() | |
164 | */ | |
165 | /* | |
166 | * Async fstat(nfsfh *) | |
167 | * Function returns | |
168 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
169 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
170 | * | |
171 | * When the callback is invoked, status indicates the result: | |
172 | * 0 : Success. | |
173 | * data is struct stat * | |
174 | * -errno : An error occured. | |
175 | * data is the error string. | |
176 | */ | |
177 | int nfs_fstat_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data); | |
178 | /* | |
179 | * Sync fstat(nfsfh *) | |
180 | * Function returns | |
181 | * 0 : The operation was successfull. | |
182 | * -errno : The command failed. | |
183 | */ | |
e2ba5764 | 184 | int nfs_fstat(struct nfs_context *nfs, struct nfsfh *nfsfh, struct stat *st); |
84004dbf RS |
185 | |
186 | ||
187 | ||
188 | /* | |
189 | * OPEN() | |
190 | */ | |
191 | /* | |
192 | * Async open(<filename>) | |
193 | * | |
194 | * mode is a combination of the flags : O_RDOLNY, O_WRONLY, O_RDWR , O_SYNC | |
195 | * | |
196 | * Function returns | |
197 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
198 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
199 | * | |
200 | * When the callback is invoked, status indicates the result: | |
201 | * 0 : Success. | |
202 | * data is a struct *nfsfh; | |
203 | * The nfsfh is close using nfs_close(). | |
204 | * -errno : An error occured. | |
205 | * data is the error string. | |
206 | */ | |
207 | int nfs_open_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data); | |
208 | /* | |
209 | * Sync stat(<filename>) | |
210 | * Function returns | |
211 | * 0 : The operation was successfull. *nfsfh is filled in. | |
212 | * -errno : The command failed. | |
213 | */ | |
e2ba5764 | 214 | int nfs_open(struct nfs_context *nfs, const char *path, int mode, struct nfsfh **nfsfh); |
84004dbf RS |
215 | |
216 | ||
217 | ||
218 | ||
219 | /* | |
220 | * CLOSE | |
221 | */ | |
222 | /* | |
223 | * Async close(nfsfh) | |
224 | * | |
225 | * Function returns | |
226 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
227 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
228 | * | |
229 | * When the callback is invoked, status indicates the result: | |
230 | * 0 : Success. | |
231 | * data is NULL. | |
232 | * -errno : An error occured. | |
233 | * data is the error string. | |
234 | */ | |
235 | int nfs_close_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data); | |
236 | /* | |
237 | * Sync close(nfsfh) | |
238 | * Function returns | |
239 | * 0 : The operation was successfull. | |
240 | * -errno : The command failed. | |
241 | */ | |
e2ba5764 | 242 | int nfs_close(struct nfs_context *nfs, struct nfsfh *nfsfh); |
84004dbf RS |
243 | |
244 | ||
245 | /* | |
246 | * PREAD() | |
247 | */ | |
248 | /* | |
249 | * Async pread() | |
250 | * | |
251 | * Function returns | |
252 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
253 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
254 | * | |
255 | * When the callback is invoked, status indicates the result: | |
256 | * >=0 : Success. | |
257 | * status is numer of bytes read. | |
258 | * data is a pointer to the returned data. | |
259 | * -errno : An error occured. | |
260 | * data is the error string. | |
261 | */ | |
262 | int nfs_pread_async(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, size_t count, nfs_cb cb, void *private_data); | |
263 | /* | |
264 | * Sync pread() | |
265 | * Function returns | |
266 | * >=0 : numer of bytes read. | |
267 | * -errno : An error occured. | |
268 | */ | |
e2ba5764 | 269 | int nfs_pread(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, size_t count, char *buf); |
84004dbf RS |
270 | |
271 | ||
272 | ||
273 | /* | |
274 | * READ() | |
275 | */ | |
276 | /* | |
277 | * Async read() | |
278 | * | |
279 | * Function returns | |
280 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
281 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
282 | * | |
283 | * When the callback is invoked, status indicates the result: | |
284 | * >=0 : Success. | |
285 | * status is numer of bytes read. | |
286 | * data is a pointer to the returned data. | |
287 | * -errno : An error occured. | |
288 | * data is the error string. | |
289 | */ | |
290 | int nfs_read_async(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count, nfs_cb cb, void *private_data); | |
291 | /* | |
292 | * Sync read() | |
293 | * Function returns | |
294 | * >=0 : numer of bytes read. | |
295 | * -errno : An error occured. | |
296 | */ | |
e2ba5764 | 297 | int nfs_read(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count, char *buf); |
84004dbf RS |
298 | |
299 | ||
300 | ||
301 | ||
302 | /* | |
303 | * PWRITE() | |
304 | */ | |
305 | /* | |
306 | * Async pwrite() | |
307 | * | |
308 | * Function returns | |
309 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
310 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
311 | * | |
312 | * When the callback is invoked, status indicates the result: | |
313 | * >=0 : Success. | |
314 | * status is numer of bytes written. | |
315 | * -errno : An error occured. | |
316 | * data is the error string. | |
317 | */ | |
318 | int nfs_pwrite_async(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, size_t count, char *buf, nfs_cb cb, void *private_data); | |
319 | /* | |
320 | * Sync pwrite() | |
321 | * Function returns | |
322 | * >=0 : numer of bytes written. | |
323 | * -errno : An error occured. | |
324 | */ | |
e2ba5764 | 325 | int nfs_pwrite(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, size_t count, char *buf); |
84004dbf RS |
326 | |
327 | ||
328 | /* | |
329 | * WRITE() | |
330 | */ | |
331 | /* | |
332 | * Async write() | |
333 | * | |
334 | * Function returns | |
335 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
336 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
337 | * | |
338 | * When the callback is invoked, status indicates the result: | |
339 | * >=0 : Success. | |
340 | * status is numer of bytes written. | |
341 | * -errno : An error occured. | |
342 | * data is the error string. | |
343 | */ | |
344 | int nfs_write_async(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count, char *buf, nfs_cb cb, void *private_data); | |
345 | /* | |
346 | * Sync write() | |
347 | * Function returns | |
348 | * >=0 : numer of bytes written. | |
349 | * -errno : An error occured. | |
350 | */ | |
e2ba5764 | 351 | int nfs_write(struct nfs_context *nfs, struct nfsfh *nfsfh, size_t count, char *buf); |
84004dbf RS |
352 | |
353 | ||
354 | /* | |
355 | * LSEEK() | |
356 | */ | |
357 | /* | |
358 | * Async lseek() | |
359 | * | |
360 | * Function returns | |
361 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
362 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
363 | * | |
364 | * When the callback is invoked, status indicates the result: | |
365 | * >=0 : Success. | |
366 | * data is off_t * for the current position. | |
367 | * -errno : An error occured. | |
368 | * data is the error string. | |
369 | */ | |
370 | int nfs_lseek_async(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, int whence, nfs_cb cb, void *private_data); | |
371 | /* | |
372 | * Sync lseek() | |
373 | * Function returns | |
374 | * >=0 : numer of bytes read. | |
375 | * -errno : An error occured. | |
376 | */ | |
e2ba5764 | 377 | int nfs_lseek(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t offset, int whence, off_t *current_offset); |
84004dbf RS |
378 | |
379 | ||
380 | /* | |
381 | * FSYNC() | |
382 | */ | |
383 | /* | |
384 | * Async fsync() | |
385 | * | |
386 | * Function returns | |
387 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
388 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
389 | * | |
390 | * When the callback is invoked, status indicates the result: | |
391 | * 0 : Success. | |
392 | * -errno : An error occured. | |
393 | * data is the error string. | |
394 | */ | |
395 | int nfs_fsync_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data); | |
396 | /* | |
397 | * Sync fsync() | |
398 | * Function returns | |
399 | * 0 : Success | |
400 | * -errno : An error occured. | |
401 | */ | |
e2ba5764 | 402 | int nfs_fsync(struct nfs_context *nfs, struct nfsfh *nfsfh); |
84004dbf RS |
403 | |
404 | ||
405 | ||
406 | /* | |
407 | * TRUNCATE() | |
408 | */ | |
409 | /* | |
410 | * Async truncate() | |
411 | * | |
412 | * Function returns | |
413 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
414 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
415 | * | |
416 | * When the callback is invoked, status indicates the result: | |
417 | * 0 : Success. | |
418 | * -errno : An error occured. | |
419 | * data is the error string. | |
420 | */ | |
421 | int nfs_truncate_async(struct nfs_context *nfs, const char *path, off_t length, nfs_cb cb, void *private_data); | |
422 | /* | |
423 | * Sync truncate() | |
424 | * Function returns | |
425 | * 0 : Success | |
426 | * -errno : An error occured. | |
427 | */ | |
e2ba5764 | 428 | int nfs_truncate(struct nfs_context *nfs, const char *path, off_t length); |
84004dbf RS |
429 | |
430 | ||
431 | ||
432 | /* | |
433 | * FTRUNCATE() | |
434 | */ | |
435 | /* | |
436 | * Async ftruncate() | |
437 | * | |
438 | * Function returns | |
439 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
440 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
441 | * | |
442 | * When the callback is invoked, status indicates the result: | |
443 | * 0 : Success. | |
444 | * -errno : An error occured. | |
445 | * data is the error string. | |
446 | */ | |
447 | int nfs_ftruncate_async(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t length, nfs_cb cb, void *private_data); | |
448 | /* | |
449 | * Sync ftruncate() | |
450 | * Function returns | |
451 | * 0 : Success | |
452 | * -errno : An error occured. | |
453 | */ | |
e2ba5764 | 454 | int nfs_ftruncate(struct nfs_context *nfs, struct nfsfh *nfsfh, off_t length); |
84004dbf RS |
455 | |
456 | ||
457 | ||
458 | ||
459 | ||
460 | ||
461 | /* | |
462 | * MKDIR() | |
463 | */ | |
464 | /* | |
465 | * Async mkdir() | |
466 | * | |
467 | * Function returns | |
468 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
469 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
470 | * | |
471 | * When the callback is invoked, status indicates the result: | |
472 | * 0 : Success. | |
473 | * -errno : An error occured. | |
474 | * data is the error string. | |
475 | */ | |
476 | int nfs_mkdir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data); | |
477 | /* | |
478 | * Sync mkdir() | |
479 | * Function returns | |
480 | * 0 : Success | |
481 | * -errno : An error occured. | |
482 | */ | |
e2ba5764 | 483 | int nfs_mkdir(struct nfs_context *nfs, const char *path); |
84004dbf RS |
484 | |
485 | ||
486 | ||
487 | /* | |
488 | * RMDIR() | |
489 | */ | |
490 | /* | |
491 | * Async rmdir() | |
492 | * | |
493 | * Function returns | |
494 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
495 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
496 | * | |
497 | * When the callback is invoked, status indicates the result: | |
498 | * 0 : Success. | |
499 | * -errno : An error occured. | |
500 | * data is the error string. | |
501 | */ | |
502 | int nfs_rmdir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data); | |
503 | /* | |
504 | * Sync rmdir() | |
505 | * Function returns | |
506 | * 0 : Success | |
507 | * -errno : An error occured. | |
508 | */ | |
e2ba5764 | 509 | int nfs_rmdir(struct nfs_context *nfs, const char *path); |
84004dbf RS |
510 | |
511 | ||
512 | ||
513 | ||
514 | /* | |
515 | * CREAT() | |
516 | */ | |
517 | /* | |
518 | * Async creat() | |
519 | * | |
520 | * Function returns | |
521 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
522 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
523 | * | |
524 | * When the callback is invoked, status indicates the result: | |
525 | * 0 : Success. | |
526 | * data is a struct *nfsfh; | |
527 | * -errno : An error occured. | |
528 | * data is the error string. | |
529 | */ | |
530 | int nfs_creat_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data); | |
531 | /* | |
532 | * Sync creat() | |
533 | * Function returns | |
534 | * 0 : Success | |
535 | * -errno : An error occured. | |
536 | */ | |
e2ba5764 | 537 | int nfs_creat(struct nfs_context *nfs, const char *path, int mode, struct nfsfh **nfsfh); |
84004dbf RS |
538 | |
539 | ||
540 | ||
541 | ||
542 | ||
543 | /* | |
544 | * UNLINK() | |
545 | */ | |
546 | /* | |
547 | * Async unlink() | |
548 | * | |
549 | * Function returns | |
550 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
551 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
552 | * | |
553 | * When the callback is invoked, status indicates the result: | |
554 | * 0 : Success. | |
555 | * data is NULL | |
556 | * -errno : An error occured. | |
557 | * data is the error string. | |
558 | */ | |
559 | int nfs_unlink_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data); | |
560 | /* | |
561 | * Sync unlink() | |
562 | * Function returns | |
563 | * 0 : Success | |
564 | * -errno : An error occured. | |
565 | */ | |
e2ba5764 | 566 | int nfs_unlink(struct nfs_context *nfs, const char *path); |
84004dbf RS |
567 | |
568 | ||
569 | ||
570 | ||
571 | /* | |
572 | * OPENDIR() | |
573 | */ | |
574 | struct nfsdir; | |
575 | /* | |
576 | * Async opendir() | |
577 | * | |
578 | * Function returns | |
579 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
580 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
581 | * | |
582 | * When struct nfsdir * is returned, this resource is closed/freed by calling nfs_closedir() | |
583 | * | |
584 | * When the callback is invoked, status indicates the result: | |
585 | * 0 : Success. | |
586 | * data is struct nfsdir * | |
587 | * -errno : An error occured. | |
588 | * data is the error string. | |
589 | */ | |
590 | int nfs_opendir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data); | |
591 | /* | |
592 | * Sync opendir() | |
593 | * Function returns | |
594 | * 0 : Success | |
595 | * -errno : An error occured. | |
596 | */ | |
e2ba5764 | 597 | int nfs_opendir(struct nfs_context *nfs, const char *path, struct nfsdir **nfsdir); |
84004dbf RS |
598 | |
599 | ||
600 | ||
601 | /* | |
602 | * READDIR() | |
603 | */ | |
604 | struct nfsdirent { | |
605 | struct nfsdirent *next; | |
606 | char *name; | |
607 | uint64_t inode; | |
608 | }; | |
609 | /* | |
610 | * nfs_readdir() never blocks, so no special sync/async versions are available | |
611 | */ | |
612 | struct nfsdirent *nfs_readdir(struct nfs_context *nfs, struct nfsdir *nfsdir); | |
613 | ||
614 | ||
615 | ||
616 | /* | |
617 | * READDIR() | |
618 | */ | |
619 | /* | |
620 | * nfs_closedir() never blocks, so no special sync/async versions are available | |
621 | */ | |
622 | void nfs_closedir(struct nfs_context *nfs, struct nfsdir *nfsdir); | |
623 | ||
624 | ||
625 | ||
626 | /* | |
627 | * STATVFS() | |
628 | */ | |
629 | /* | |
630 | * Async statvfs(<dirname>) | |
631 | * Function returns | |
632 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
633 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
634 | * | |
635 | * When the callback is invoked, status indicates the result: | |
636 | * 0 : Success. | |
637 | * data is struct statvfs * | |
638 | * -errno : An error occured. | |
639 | * data is the error string. | |
640 | */ | |
641 | struct statvfs; | |
642 | int nfs_statvfs_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data); | |
643 | /* | |
644 | * Sync statvfs(<dirname>) | |
645 | * Function returns | |
646 | * 0 : The operation was successfull. | |
647 | * -errno : The command failed. | |
648 | */ | |
e2ba5764 | 649 | int nfs_statvfs(struct nfs_context *nfs, const char *path, struct statvfs *svfs); |
84004dbf RS |
650 | |
651 | ||
652 | /* | |
653 | * READLINK() | |
654 | */ | |
655 | /* | |
656 | * Async readlink(<name>) | |
657 | * Function returns | |
658 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
659 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
660 | * | |
661 | * When the callback is invoked, status indicates the result: | |
662 | * 0 : Success. | |
663 | * data is a char * | |
664 | * data is only valid during the callback and is automatically freed when the callback returns. | |
665 | * -errno : An error occured. | |
666 | * data is the error string. | |
667 | */ | |
668 | struct statvfs; | |
669 | int nfs_readlink_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data); | |
670 | /* | |
671 | * Sync readlink(<name>) | |
672 | * Function returns | |
673 | * 0 : The operation was successfull. | |
674 | * -errno : The command failed. | |
675 | */ | |
e2ba5764 | 676 | int nfs_readlink(struct nfs_context *nfs, const char *path, char *buf, int bufsize); |
84004dbf RS |
677 | |
678 | ||
679 | ||
680 | /* | |
681 | * CHMOD() | |
682 | */ | |
683 | /* | |
684 | * Async chmod(<name>) | |
685 | * Function returns | |
686 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
687 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
688 | * | |
689 | * When the callback is invoked, status indicates the result: | |
690 | * 0 : Success. | |
691 | * data is NULL | |
692 | * -errno : An error occured. | |
693 | * data is the error string. | |
694 | */ | |
695 | int nfs_chmod_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data); | |
696 | /* | |
697 | * Sync chmod(<name>) | |
698 | * Function returns | |
699 | * 0 : The operation was successfull. | |
700 | * -errno : The command failed. | |
701 | */ | |
e2ba5764 | 702 | int nfs_chmod(struct nfs_context *nfs, const char *path, int mode); |
84004dbf RS |
703 | |
704 | ||
705 | ||
706 | /* | |
707 | * FCHMOD() | |
708 | */ | |
709 | /* | |
710 | * Async fchmod(<handle>) | |
711 | * Function returns | |
712 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
713 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
714 | * | |
715 | * When the callback is invoked, status indicates the result: | |
716 | * 0 : Success. | |
717 | * data is NULL | |
718 | * -errno : An error occured. | |
719 | * data is the error string. | |
720 | */ | |
721 | int nfs_fchmod_async(struct nfs_context *nfs, struct nfsfh *nfsfh, int mode, nfs_cb cb, void *private_data); | |
722 | /* | |
723 | * Sync fchmod(<handle>) | |
724 | * Function returns | |
725 | * 0 : The operation was successfull. | |
726 | * -errno : The command failed. | |
727 | */ | |
e2ba5764 | 728 | int nfs_fchmod(struct nfs_context *nfs, struct nfsfh *nfsfh, int mode); |
84004dbf RS |
729 | |
730 | ||
731 | ||
732 | /* | |
733 | * CHOWN() | |
734 | */ | |
735 | /* | |
736 | * Async chown(<name>) | |
737 | * Function returns | |
738 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
739 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
740 | * | |
741 | * When the callback is invoked, status indicates the result: | |
742 | * 0 : Success. | |
743 | * data is NULL | |
744 | * -errno : An error occured. | |
745 | * data is the error string. | |
746 | */ | |
747 | int nfs_chown_async(struct nfs_context *nfs, const char *path, int uid, int gid, nfs_cb cb, void *private_data); | |
748 | /* | |
749 | * Sync chown(<name>) | |
750 | * Function returns | |
751 | * 0 : The operation was successfull. | |
752 | * -errno : The command failed. | |
753 | */ | |
e2ba5764 | 754 | int nfs_chown(struct nfs_context *nfs, const char *path, int uid, int gid); |
84004dbf RS |
755 | |
756 | ||
757 | ||
758 | /* | |
759 | * FCHOWN() | |
760 | */ | |
761 | /* | |
762 | * Async fchown(<handle>) | |
763 | * Function returns | |
764 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
765 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
766 | * | |
767 | * When the callback is invoked, status indicates the result: | |
768 | * 0 : Success. | |
769 | * data is NULL | |
770 | * -errno : An error occured. | |
771 | * data is the error string. | |
772 | */ | |
773 | int nfs_fchown_async(struct nfs_context *nfs, struct nfsfh *nfsfh, int uid, int gid, nfs_cb cb, void *private_data); | |
774 | /* | |
775 | * Sync fchown(<handle>) | |
776 | * Function returns | |
777 | * 0 : The operation was successfull. | |
778 | * -errno : The command failed. | |
779 | */ | |
e2ba5764 | 780 | int nfs_fchown(struct nfs_context *nfs, struct nfsfh *nfsfh, int uid, int gid); |
84004dbf RS |
781 | |
782 | ||
783 | ||
784 | ||
785 | /* | |
786 | * UTIMES() | |
787 | */ | |
788 | /* | |
789 | * Async utimes(<path>) | |
790 | * Function returns | |
791 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
792 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
793 | * | |
794 | * When the callback is invoked, status indicates the result: | |
795 | * 0 : Success. | |
796 | * data is NULL | |
797 | * -errno : An error occured. | |
798 | * data is the error string. | |
799 | */ | |
800 | int nfs_utimes_async(struct nfs_context *nfs, const char *path, struct timeval *times, nfs_cb cb, void *private_data); | |
801 | /* | |
802 | * Sync utimes(<path>) | |
803 | * Function returns | |
804 | * 0 : The operation was successfull. | |
805 | * -errno : The command failed. | |
806 | */ | |
e2ba5764 | 807 | int nfs_utimes(struct nfs_context *nfs, const char *path, struct timeval *times); |
84004dbf RS |
808 | |
809 | ||
810 | /* | |
811 | * UTIME() | |
812 | */ | |
813 | /* | |
814 | * Async utime(<path>) | |
815 | * Function returns | |
816 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
817 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
818 | * | |
819 | * When the callback is invoked, status indicates the result: | |
820 | * 0 : Success. | |
821 | * data is NULL | |
822 | * -errno : An error occured. | |
823 | * data is the error string. | |
824 | */ | |
825 | struct utimbuf; | |
826 | int nfs_utime_async(struct nfs_context *nfs, const char *path, struct utimbuf *times, nfs_cb cb, void *private_data); | |
827 | /* | |
828 | * Sync utime(<path>) | |
829 | * Function returns | |
830 | * 0 : The operation was successfull. | |
831 | * -errno : The command failed. | |
832 | */ | |
e2ba5764 | 833 | int nfs_utime(struct nfs_context *nfs, const char *path, struct utimbuf *times); |
84004dbf RS |
834 | |
835 | ||
836 | ||
837 | ||
838 | /* | |
839 | * ACCESS() | |
840 | */ | |
841 | /* | |
842 | * Async access(<path>) | |
843 | * Function returns | |
844 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
845 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
846 | * | |
847 | * When the callback is invoked, status indicates the result: | |
848 | * 0 : Success. | |
849 | * data is NULL | |
850 | * -errno : An error occured. | |
851 | * data is the error string. | |
852 | */ | |
853 | int nfs_access_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data); | |
854 | /* | |
855 | * Sync access(<path>) | |
856 | * Function returns | |
857 | * 0 : The operation was successfull. | |
858 | * -errno : The command failed. | |
859 | */ | |
e2ba5764 | 860 | int nfs_access(struct nfs_context *nfs, const char *path, int mode); |
84004dbf RS |
861 | |
862 | ||
863 | ||
864 | ||
865 | /* | |
866 | * SYMLINK() | |
867 | */ | |
868 | /* | |
869 | * Async symlink(<path>) | |
870 | * Function returns | |
871 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
872 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
873 | * | |
874 | * When the callback is invoked, status indicates the result: | |
875 | * 0 : Success. | |
876 | * data is NULL | |
877 | * -errno : An error occured. | |
878 | * data is the error string. | |
879 | */ | |
880 | int nfs_symlink_async(struct nfs_context *nfs, const char *oldpath, const char *newpath, nfs_cb cb, void *private_data); | |
881 | /* | |
882 | * Sync symlink(<path>) | |
883 | * Function returns | |
884 | * 0 : The operation was successfull. | |
885 | * -errno : The command failed. | |
886 | */ | |
e2ba5764 | 887 | int nfs_symlink(struct nfs_context *nfs, const char *oldpath, const char *newpath); |
84004dbf RS |
888 | |
889 | ||
890 | /* | |
891 | * RENAME() | |
892 | */ | |
893 | /* | |
894 | * Async rename(<oldpath>, <newpath>) | |
895 | * Function returns | |
896 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
897 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
898 | * | |
899 | * When the callback is invoked, status indicates the result: | |
900 | * 0 : Success. | |
901 | * data is NULL | |
902 | * -errno : An error occured. | |
903 | * data is the error string. | |
904 | */ | |
905 | int nfs_rename_async(struct nfs_context *nfs, const char *oldpath, const char *newpath, nfs_cb cb, void *private_data); | |
906 | /* | |
907 | * Sync rename(<oldpath>, <newpath>) | |
908 | * Function returns | |
909 | * 0 : The operation was successfull. | |
910 | * -errno : The command failed. | |
911 | */ | |
e2ba5764 | 912 | int nfs_rename(struct nfs_context *nfs, const char *oldpath, const char *newpath); |
84004dbf RS |
913 | |
914 | ||
915 | ||
916 | /* | |
917 | * LINK() | |
918 | */ | |
919 | /* | |
920 | * Async link(<oldpath>, <newpath>) | |
921 | * Function returns | |
922 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
923 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
924 | * | |
925 | * When the callback is invoked, status indicates the result: | |
926 | * 0 : Success. | |
927 | * data is NULL | |
928 | * -errno : An error occured. | |
929 | * data is the error string. | |
930 | */ | |
931 | int nfs_link_async(struct nfs_context *nfs, const char *oldpath, const char *newpath, nfs_cb cb, void *private_data); | |
932 | /* | |
933 | * Sync link(<oldpath>, <newpath>) | |
934 | * Function returns | |
935 | * 0 : The operation was successfull. | |
936 | * -errno : The command failed. | |
937 | */ | |
e2ba5764 | 938 | int nfs_link(struct nfs_context *nfs, const char *oldpath, const char *newpath); |
84004dbf RS |
939 | |
940 | ||
7f0242ca RS |
941 | /* |
942 | * GETEXPORTS() | |
943 | */ | |
944 | /* | |
945 | * Async getexports() | |
946 | * NOTE: You must include 'libnfs-raw-mount.h' to get the definitions of the | |
947 | * returned structures. | |
948 | * | |
949 | * This function will return the list of exports from an NFS server. | |
950 | * | |
951 | * Function returns | |
952 | * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked. | |
953 | * <0 : An error occured when trying to set up the operation. The callback will not be invoked. | |
954 | * | |
955 | * When the callback is invoked, status indicates the result: | |
956 | * 0 : Success. | |
957 | * data is a pointer to an exports pointer: | |
958 | * exports export = *(exports *)data; | |
959 | * -errno : An error occured. | |
960 | * data is the error string. | |
961 | */ | |
962 | int mount_getexports_async(struct rpc_context *rpc, const char *server, rpc_cb cb, void *private_data); | |
df5af25f RS |
963 | /* |
964 | * Sync getexports(<server>) | |
965 | * Function returns | |
966 | * NULL : something failed | |
967 | * exports export : a linked list of exported directories | |
968 | * | |
969 | * returned data must be freed by calling mount_free_export_list(exportnode); | |
970 | */ | |
e210bd2a | 971 | struct exportnode *mount_getexports(const char *server); |
7f0242ca | 972 | |
df5af25f | 973 | void mount_free_export_list(struct exportnode *exports); |
7f0242ca | 974 | |
84004dbf RS |
975 | |
976 | //qqq replace later with lseek(cur, 0) | |
977 | off_t nfs_get_current_offset(struct nfsfh *nfsfh); | |
552c7665 RS |
978 | |
979 | ||
980 | ||
9c4212bf RS |
981 | |
982 | ||
552c7665 RS |
983 | struct nfs_server_list { |
984 | struct nfs_server_list *next; | |
985 | char *addr; | |
986 | }; | |
987 | ||
9c4212bf RS |
988 | /* |
989 | * Sync find_local_servers(<server>) | |
990 | * This function will probe all local networks for NFS server. This function will | |
991 | * block for one second while awaiting for all nfs servers to respond. | |
992 | * | |
993 | * Function returns | |
994 | * NULL : something failed | |
995 | * | |
996 | * struct nfs_server_list : a linked list of all discovered servers | |
997 | * | |
998 | * returned data must be freed by nfs_free_srvr_list(srv); | |
999 | */ | |
552c7665 RS |
1000 | struct nfs_server_list *nfs_find_local_servers(void); |
1001 | void free_nfs_srvr_list(struct nfs_server_list *srv); |