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