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