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