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