[win32] - fixed bad number casting when using libnfs on 64bit win8 systems - force...
[deb_libnfs.git] / include / nfsc / libnfs.h
CommitLineData
84004dbf
RS
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>
252aa90d
CF
21#if defined(ANDROID)
22#include <sys/time.h>
23#endif
d7c6e9aa
RS
24#if defined(AROS)
25#include <sys/time.h>
26#endif
84004dbf
RS
27
28struct nfs_context;
7f0242ca 29struct rpc_context;
84004dbf 30
66ad6d84
RS
31#if defined(WIN32)
32#define EXTERN __declspec( dllexport )
33#else
34#define EXTERN
35#endif
36
eecdc4f3
RS
37#if defined(WIN32)
38struct 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};
51struct 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
84004dbf
RS
60/*
61 * Used for interfacing the async version of the api into an external eventsystem
62 */
66ad6d84
RS
63EXTERN int nfs_get_fd(struct nfs_context *nfs);
64EXTERN int nfs_which_events(struct nfs_context *nfs);
65EXTERN int nfs_service(struct nfs_context *nfs, int revents);
83aa785d 66EXTERN int nfs_queue_length(struct nfs_context *nfs);
84004dbf
RS
67
68/*
69 * Used if you need different credentials than the default for the current user.
70 */
67ba2239
RS
71struct AUTH;
72EXTERN void nfs_set_auth(struct nfs_context *nfs, struct AUTH *auth);
84004dbf
RS
73
74
75/*
76 * When an operation failed, this function can extract a detailed error string.
77 */
66ad6d84 78EXTERN char *nfs_get_error(struct nfs_context *nfs);
84004dbf
RS
79
80
81/*
82 * Callback for all ASYNC nfs functions
83 */
84typedef void (*nfs_cb)(int err, struct nfs_context *nfs, void *data, void *private_data);
85
7f0242ca
RS
86/*
87 * Callback for all ASYNC rpc functions
88 */
89typedef void (*rpc_cb)(struct rpc_context *rpc, int status, void *data, void *private_data);
84004dbf
RS
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 */
66ad6d84 102EXTERN struct nfs_context *nfs_init_context(void);
84004dbf
RS
103/*
104 * Destroy an nfs context.
105 */
66ad6d84 106EXTERN void nfs_destroy_context(struct nfs_context *nfs);
84004dbf
RS
107
108
109struct nfsfh;
110
17ef62fa
RS
111/*
112 * Get the maximum supported READ3 size by the server
113 */
183451cf 114EXTERN uint64_t nfs_get_readmax(struct nfs_context *nfs);
17ef62fa
RS
115
116/*
117 * Get the maximum supported WRITE3 size by the server
118 */
183451cf 119EXTERN uint64_t nfs_get_writemax(struct nfs_context *nfs);
17ef62fa 120
84004dbf
RS
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 */
66ad6d84 137EXTERN int nfs_mount_async(struct nfs_context *nfs, const char *server, const char *exportname, nfs_cb cb, void *private_data);
84004dbf
RS
138/*
139 * Sync nfs mount.
140 * Function returns
141 * 0 : The operation was successfull.
142 * -errno : The command failed.
143 */
66ad6d84 144EXTERN int nfs_mount(struct nfs_context *nfs, const char *server, const char *exportname);
84004dbf
RS
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 */
164struct stat;
66ad6d84 165EXTERN int nfs_stat_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
84004dbf
RS
166/*
167 * Sync stat(<filename>)
168 * Function returns
169 * 0 : The operation was successfull.
170 * -errno : The command failed.
171 */
be184101
M
172#ifdef WIN32
173EXTERN int nfs_stat(struct nfs_context *nfs, const char *path, struct __stat64 *st);
174#else
66ad6d84 175EXTERN int nfs_stat(struct nfs_context *nfs, const char *path, struct stat *st);
be184101 176#endif
84004dbf
RS
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 */
66ad6d84 193EXTERN int nfs_fstat_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data);
84004dbf
RS
194/*
195 * Sync fstat(nfsfh *)
196 * Function returns
197 * 0 : The operation was successfull.
198 * -errno : The command failed.
199 */
be184101
M
200#ifdef WIN32
201EXTERN int nfs_fstat(struct nfs_context *nfs, struct nfsfh *nfsfh, struct __stat64 *st);
202#else
66ad6d84 203EXTERN int nfs_fstat(struct nfs_context *nfs, struct nfsfh *nfsfh, struct stat *st);
be184101 204#endif
84004dbf
RS
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 */
66ad6d84 227EXTERN int nfs_open_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data);
84004dbf
RS
228/*
229 * Sync stat(<filename>)
230 * Function returns
231 * 0 : The operation was successfull. *nfsfh is filled in.
232 * -errno : The command failed.
233 */
66ad6d84 234EXTERN int nfs_open(struct nfs_context *nfs, const char *path, int mode, struct nfsfh **nfsfh);
84004dbf
RS
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 */
66ad6d84 255EXTERN int nfs_close_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data);
84004dbf
RS
256/*
257 * Sync close(nfsfh)
258 * Function returns
259 * 0 : The operation was successfull.
260 * -errno : The command failed.
261 */
66ad6d84 262EXTERN int nfs_close(struct nfs_context *nfs, struct nfsfh *nfsfh);
84004dbf
RS
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 */
183451cf 282EXTERN int nfs_pread_async(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offset, uint64_t count, nfs_cb cb, void *private_data);
84004dbf
RS
283/*
284 * Sync pread()
285 * Function returns
286 * >=0 : numer of bytes read.
287 * -errno : An error occured.
288 */
183451cf 289EXTERN int nfs_pread(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offset, uint64_t count, char *buf);
84004dbf
RS
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 */
183451cf 310EXTERN int nfs_read_async(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t count, nfs_cb cb, void *private_data);
84004dbf
RS
311/*
312 * Sync read()
313 * Function returns
314 * >=0 : numer of bytes read.
315 * -errno : An error occured.
316 */
183451cf 317EXTERN int nfs_read(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t count, char *buf);
84004dbf
RS
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 */
183451cf 338EXTERN 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);
84004dbf
RS
339/*
340 * Sync pwrite()
341 * Function returns
342 * >=0 : numer of bytes written.
343 * -errno : An error occured.
344 */
183451cf 345EXTERN int nfs_pwrite(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offset, uint64_t count, char *buf);
84004dbf
RS
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 */
183451cf 364EXTERN int nfs_write_async(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t count, char *buf, nfs_cb cb, void *private_data);
84004dbf
RS
365/*
366 * Sync write()
367 * Function returns
368 * >=0 : numer of bytes written.
369 * -errno : An error occured.
370 */
183451cf 371EXTERN int nfs_write(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t count, char *buf);
84004dbf
RS
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.
183451cf 386 * data is uint64_t * for the current position.
84004dbf
RS
387 * -errno : An error occured.
388 * data is the error string.
389 */
183451cf 390EXTERN int nfs_lseek_async(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offset, int whence, nfs_cb cb, void *private_data);
84004dbf
RS
391/*
392 * Sync lseek()
393 * Function returns
394 * >=0 : numer of bytes read.
395 * -errno : An error occured.
396 */
183451cf 397EXTERN int nfs_lseek(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offset, int whence, uint64_t *current_offset);
84004dbf
RS
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 */
66ad6d84 415EXTERN int nfs_fsync_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data);
84004dbf
RS
416/*
417 * Sync fsync()
418 * Function returns
419 * 0 : Success
420 * -errno : An error occured.
421 */
66ad6d84 422EXTERN int nfs_fsync(struct nfs_context *nfs, struct nfsfh *nfsfh);
84004dbf
RS
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 */
183451cf 441EXTERN int nfs_truncate_async(struct nfs_context *nfs, const char *path, uint64_t length, nfs_cb cb, void *private_data);
84004dbf
RS
442/*
443 * Sync truncate()
444 * Function returns
445 * 0 : Success
446 * -errno : An error occured.
447 */
183451cf 448EXTERN int nfs_truncate(struct nfs_context *nfs, const char *path, uint64_t length);
84004dbf
RS
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 */
183451cf 467EXTERN int nfs_ftruncate_async(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t length, nfs_cb cb, void *private_data);
84004dbf
RS
468/*
469 * Sync ftruncate()
470 * Function returns
471 * 0 : Success
472 * -errno : An error occured.
473 */
183451cf 474EXTERN int nfs_ftruncate(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t length);
84004dbf
RS
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 */
66ad6d84 496EXTERN int nfs_mkdir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
84004dbf
RS
497/*
498 * Sync mkdir()
499 * Function returns
500 * 0 : Success
501 * -errno : An error occured.
502 */
66ad6d84 503EXTERN int nfs_mkdir(struct nfs_context *nfs, const char *path);
84004dbf
RS
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 */
66ad6d84 522EXTERN int nfs_rmdir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
84004dbf
RS
523/*
524 * Sync rmdir()
525 * Function returns
526 * 0 : Success
527 * -errno : An error occured.
528 */
66ad6d84 529EXTERN int nfs_rmdir(struct nfs_context *nfs, const char *path);
84004dbf
RS
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 */
66ad6d84 550EXTERN int nfs_creat_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data);
84004dbf
RS
551/*
552 * Sync creat()
553 * Function returns
554 * 0 : Success
555 * -errno : An error occured.
556 */
66ad6d84 557EXTERN int nfs_creat(struct nfs_context *nfs, const char *path, int mode, struct nfsfh **nfsfh);
84004dbf
RS
558
559
1ec6b50a
RS
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 */
575EXTERN 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 */
582EXTERN int nfs_mknod(struct nfs_context *nfs, const char *path, int mode, int dev);
84004dbf
RS
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 */
66ad6d84 602EXTERN int nfs_unlink_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
84004dbf
RS
603/*
604 * Sync unlink()
605 * Function returns
606 * 0 : Success
607 * -errno : An error occured.
608 */
66ad6d84 609EXTERN int nfs_unlink(struct nfs_context *nfs, const char *path);
84004dbf
RS
610
611
612
613
614/*
615 * OPENDIR()
616 */
617struct 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 */
66ad6d84 633EXTERN int nfs_opendir_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
84004dbf
RS
634/*
635 * Sync opendir()
636 * Function returns
637 * 0 : Success
638 * -errno : An error occured.
639 */
66ad6d84 640EXTERN int nfs_opendir(struct nfs_context *nfs, const char *path, struct nfsdir **nfsdir);
84004dbf
RS
641
642
643
644/*
645 * READDIR()
646 */
647struct nfsdirent {
648 struct nfsdirent *next;
649 char *name;
650 uint64_t inode;
0804e67d
RS
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;
84004dbf
RS
659};
660/*
661 * nfs_readdir() never blocks, so no special sync/async versions are available
662 */
66ad6d84 663EXTERN struct nfsdirent *nfs_readdir(struct nfs_context *nfs, struct nfsdir *nfsdir);
84004dbf
RS
664
665
666
667/*
668 * READDIR()
669 */
670/*
671 * nfs_closedir() never blocks, so no special sync/async versions are available
672 */
66ad6d84 673EXTERN void nfs_closedir(struct nfs_context *nfs, struct nfsdir *nfsdir);
84004dbf
RS
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 */
692struct statvfs;
66ad6d84 693EXTERN int nfs_statvfs_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
84004dbf
RS
694/*
695 * Sync statvfs(<dirname>)
696 * Function returns
697 * 0 : The operation was successfull.
698 * -errno : The command failed.
699 */
66ad6d84 700EXTERN int nfs_statvfs(struct nfs_context *nfs, const char *path, struct statvfs *svfs);
84004dbf
RS
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 */
719struct statvfs;
66ad6d84 720EXTERN int nfs_readlink_async(struct nfs_context *nfs, const char *path, nfs_cb cb, void *private_data);
84004dbf
RS
721/*
722 * Sync readlink(<name>)
723 * Function returns
724 * 0 : The operation was successfull.
725 * -errno : The command failed.
726 */
66ad6d84 727EXTERN int nfs_readlink(struct nfs_context *nfs, const char *path, char *buf, int bufsize);
84004dbf
RS
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 */
66ad6d84 746EXTERN int nfs_chmod_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data);
84004dbf
RS
747/*
748 * Sync chmod(<name>)
749 * Function returns
750 * 0 : The operation was successfull.
751 * -errno : The command failed.
752 */
66ad6d84 753EXTERN int nfs_chmod(struct nfs_context *nfs, const char *path, int mode);
84004dbf
RS
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 */
66ad6d84 772EXTERN int nfs_fchmod_async(struct nfs_context *nfs, struct nfsfh *nfsfh, int mode, nfs_cb cb, void *private_data);
84004dbf
RS
773/*
774 * Sync fchmod(<handle>)
775 * Function returns
776 * 0 : The operation was successfull.
777 * -errno : The command failed.
778 */
66ad6d84 779EXTERN int nfs_fchmod(struct nfs_context *nfs, struct nfsfh *nfsfh, int mode);
84004dbf
RS
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 */
66ad6d84 798EXTERN int nfs_chown_async(struct nfs_context *nfs, const char *path, int uid, int gid, nfs_cb cb, void *private_data);
84004dbf
RS
799/*
800 * Sync chown(<name>)
801 * Function returns
802 * 0 : The operation was successfull.
803 * -errno : The command failed.
804 */
66ad6d84 805EXTERN int nfs_chown(struct nfs_context *nfs, const char *path, int uid, int gid);
84004dbf
RS
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 */
66ad6d84 824EXTERN int nfs_fchown_async(struct nfs_context *nfs, struct nfsfh *nfsfh, int uid, int gid, nfs_cb cb, void *private_data);
84004dbf
RS
825/*
826 * Sync fchown(<handle>)
827 * Function returns
828 * 0 : The operation was successfull.
829 * -errno : The command failed.
830 */
66ad6d84 831EXTERN int nfs_fchown(struct nfs_context *nfs, struct nfsfh *nfsfh, int uid, int gid);
84004dbf
RS
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 */
66ad6d84 851EXTERN int nfs_utimes_async(struct nfs_context *nfs, const char *path, struct timeval *times, nfs_cb cb, void *private_data);
84004dbf
RS
852/*
853 * Sync utimes(<path>)
854 * Function returns
855 * 0 : The operation was successfull.
856 * -errno : The command failed.
857 */
66ad6d84 858EXTERN int nfs_utimes(struct nfs_context *nfs, const char *path, struct timeval *times);
84004dbf
RS
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 */
876struct utimbuf;
66ad6d84 877EXTERN int nfs_utime_async(struct nfs_context *nfs, const char *path, struct utimbuf *times, nfs_cb cb, void *private_data);
84004dbf
RS
878/*
879 * Sync utime(<path>)
880 * Function returns
881 * 0 : The operation was successfull.
882 * -errno : The command failed.
883 */
66ad6d84 884EXTERN int nfs_utime(struct nfs_context *nfs, const char *path, struct utimbuf *times);
84004dbf
RS
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 */
66ad6d84 904EXTERN int nfs_access_async(struct nfs_context *nfs, const char *path, int mode, nfs_cb cb, void *private_data);
84004dbf
RS
905/*
906 * Sync access(<path>)
907 * Function returns
908 * 0 : The operation was successfull.
909 * -errno : The command failed.
910 */
66ad6d84 911EXTERN int nfs_access(struct nfs_context *nfs, const char *path, int mode);
84004dbf
RS
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 */
66ad6d84 931EXTERN int nfs_symlink_async(struct nfs_context *nfs, const char *oldpath, const char *newpath, nfs_cb cb, void *private_data);
84004dbf
RS
932/*
933 * Sync symlink(<path>)
934 * Function returns
935 * 0 : The operation was successfull.
936 * -errno : The command failed.
937 */
66ad6d84 938EXTERN int nfs_symlink(struct nfs_context *nfs, const char *oldpath, const char *newpath);
84004dbf
RS
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 */
66ad6d84 956EXTERN int nfs_rename_async(struct nfs_context *nfs, const char *oldpath, const char *newpath, nfs_cb cb, void *private_data);
84004dbf
RS
957/*
958 * Sync rename(<oldpath>, <newpath>)
959 * Function returns
960 * 0 : The operation was successfull.
961 * -errno : The command failed.
962 */
66ad6d84 963EXTERN int nfs_rename(struct nfs_context *nfs, const char *oldpath, const char *newpath);
84004dbf
RS
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 */
66ad6d84 982EXTERN int nfs_link_async(struct nfs_context *nfs, const char *oldpath, const char *newpath, nfs_cb cb, void *private_data);
84004dbf
RS
983/*
984 * Sync link(<oldpath>, <newpath>)
985 * Function returns
986 * 0 : The operation was successfull.
987 * -errno : The command failed.
988 */
66ad6d84 989EXTERN int nfs_link(struct nfs_context *nfs, const char *oldpath, const char *newpath);
84004dbf
RS
990
991
7f0242ca
RS
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 */
66ad6d84 1013EXTERN int mount_getexports_async(struct rpc_context *rpc, const char *server, rpc_cb cb, void *private_data);
df5af25f
RS
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 */
66ad6d84 1022EXTERN struct exportnode *mount_getexports(const char *server);
7f0242ca 1023
66ad6d84 1024EXTERN void mount_free_export_list(struct exportnode *exports);
7f0242ca 1025
84004dbf
RS
1026
1027//qqq replace later with lseek(cur, 0)
183451cf 1028uint64_t nfs_get_current_offset(struct nfsfh *nfsfh);
552c7665
RS
1029
1030
1031
9c4212bf
RS
1032
1033
552c7665
RS
1034struct nfs_server_list {
1035 struct nfs_server_list *next;
1036 char *addr;
1037};
1038
9c4212bf
RS
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 */
552c7665
RS
1051struct nfs_server_list *nfs_find_local_servers(void);
1052void free_nfs_srvr_list(struct nfs_server_list *srv);