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