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