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