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