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