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