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