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