2 Copyright (C) 2010 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
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.
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.
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/>.
18 * This is the highlevel interface to access NFS resources using a posix-like interface
31 #if defined(__APPLE__) && defined(__MACH__)
39 #define LIBNFS_FEATURE_READAHEAD
40 #define NFS_BLKSIZE 4096
52 #define EXTERN __declspec( dllexport )
81 * Used for interfacing the async version of the api into an external eventsystem
83 EXTERN
int nfs_get_fd(struct nfs_context
*nfs
);
84 EXTERN
int nfs_which_events(struct nfs_context
*nfs
);
85 EXTERN
int nfs_service(struct nfs_context
*nfs
, int revents
);
86 EXTERN
int nfs_queue_length(struct nfs_context
*nfs
);
89 * Used if you need different credentials than the default for the current user.
92 EXTERN
void nfs_set_auth(struct nfs_context
*nfs
, struct AUTH
*auth
);
95 * When an operation failed, this function can extract a detailed error string.
97 EXTERN
char *nfs_get_error(struct nfs_context
*nfs
);
101 * Callback for all ASYNC nfs functions
103 typedef void (*nfs_cb
)(int err
, struct nfs_context
*nfs
, void *data
, void *private_data
);
106 * Callback for all ASYNC rpc functions
108 typedef void (*rpc_cb
)(struct rpc_context
*rpc
, int status
, void *data
, void *private_data
);
116 * Create an NFS c, the context.
118 * NULL : Failed to create a context.
119 * *nfs : A pointer to an nfs context.
121 EXTERN
struct nfs_context
*nfs_init_context(void);
123 * Destroy an nfs context.
125 EXTERN
void nfs_destroy_context(struct nfs_context
*nfs
);
129 * URL parsing functions.
130 * These functions all parse a URL of the form
131 * nfs://server/path/file?argv=val[&arg=val]*
132 * and returns a nfs_url.
134 * Apart from parsing the URL the functions will also update
135 * the nfs context to reflect settings controlled via url arguments.
137 * Current URL arguments are :
138 * tcp-syncnt=<int> : Number of SYNs to send during the seccion establish
139 * before failing settin up the tcp connection to the
141 * uid=<int> : UID value to use when talking to the server.
142 * default it 65534 on Windows and getuid() on unixen.
143 * gid=<int> : GID value to use when talking to the server.
144 * default it 65534 on Windows and getgid() on unixen.
147 * Parse a complete NFS URL including, server, path and
148 * filename. Fail if any component is missing.
150 EXTERN
struct nfs_url
*nfs_parse_url_full(struct nfs_context
*nfs
, const char *url
);
153 * Parse an NFS URL, but do not split path and file. File
154 * in the resulting struct remains NULL.
156 EXTERN
struct nfs_url
*nfs_parse_url_dir(struct nfs_context
*nfs
, const char *url
);
159 * Parse an NFS URL, but do not fail if file, path or even server is missing.
160 * Check elements of the resulting struct for NULL.
162 EXTERN
struct nfs_url
*nfs_parse_url_incomplete(struct nfs_context
*nfs
, const char *url
);
166 * Free the URL struct returned by the nfs_parse_url_* functions.
168 EXTERN
void nfs_destroy_url(struct nfs_url
*url
);
174 * Get the maximum supported READ3 size by the server
176 EXTERN
uint64_t nfs_get_readmax(struct nfs_context
*nfs
);
179 * Get the maximum supported WRITE3 size by the server
181 EXTERN
uint64_t nfs_get_writemax(struct nfs_context
*nfs
);
184 * MODIFY CONNECT PARAMTERS
187 EXTERN
void nfs_set_tcp_syncnt(struct nfs_context
*nfs
, int v
);
188 EXTERN
void nfs_set_uid(struct nfs_context
*nfs
, int uid
);
189 EXTERN
void nfs_set_gid(struct nfs_context
*nfs
, int gid
);
190 EXTERN
void nfs_set_readahead(struct nfs_context
*nfs
, uint32_t v
);
198 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
199 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
201 * When the callback is invoked, status indicates the result:
204 * -errno : An error occured.
205 * data is the error string.
207 EXTERN
int nfs_mount_async(struct nfs_context
*nfs
, const char *server
, const char *exportname
, nfs_cb cb
, void *private_data
);
211 * 0 : The operation was successfull.
212 * -errno : The command failed.
214 EXTERN
int nfs_mount(struct nfs_context
*nfs
, const char *server
, const char *exportname
);
223 * Async stat(<filename>)
225 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
226 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
228 * When the callback is invoked, status indicates the result:
230 * data is struct stat *
231 * -errno : An error occured.
232 * data is the error string.
234 /* This function is deprecated. Use nfs_stat64_async() instead */
236 EXTERN
int nfs_stat_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
238 * Sync stat(<filename>)
240 * 0 : The operation was successfull.
241 * -errno : The command failed.
243 /* This function is deprecated. Use nfs_stat64() instead */
245 EXTERN
int nfs_stat(struct nfs_context
*nfs
, const char *path
, struct __stat64
*st
);
247 EXTERN
int nfs_stat(struct nfs_context
*nfs
, const char *path
, struct stat
*st
);
252 * 64 bit version if stat. All fields are always 64bit.
253 * Use these functions instead of nfs_stat[_async](), especially if you
254 * have weird stat structures.
268 uint64_t nfs_blksize
;
273 uint64_t nfs_atime_nsec
;
274 uint64_t nfs_mtime_nsec
;
275 uint64_t nfs_ctime_nsec
;
280 * Async stat(<filename>)
282 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
283 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
285 * When the callback is invoked, status indicates the result:
287 * data is struct nfs_stat_64 *
288 * -errno : An error occured.
289 * data is the error string.
291 EXTERN
int nfs_stat64_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
293 * Sync stat(<filename>)
295 * 0 : The operation was successfull.
296 * -errno : The command failed.
298 EXTERN
int nfs_stat64(struct nfs_context
*nfs
, const char *path
, struct nfs_stat_64
*st
);
304 * Async fstat(nfsfh *)
306 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
307 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
309 * When the callback is invoked, status indicates the result:
311 * data is struct stat *
312 * -errno : An error occured.
313 * data is the error string.
315 EXTERN
int nfs_fstat_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, nfs_cb cb
, void *private_data
);
317 * Sync fstat(nfsfh *)
319 * 0 : The operation was successfull.
320 * -errno : The command failed.
323 EXTERN
int nfs_fstat(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, struct __stat64
*st
);
325 EXTERN
int nfs_fstat(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, struct stat
*st
);
334 * Async open(<filename>)
336 * mode is a combination of the flags :
337 * O_RDOLNY, O_WRONLY, O_RDWR , O_SYNC, O_APPEND
340 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
341 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
343 * Supported flags are
348 * O_TRUNC (Only valid with O_RDWR or O_WRONLY. Ignored otherwise.)
350 * When the callback is invoked, status indicates the result:
352 * data is a struct *nfsfh;
353 * The nfsfh is close using nfs_close().
354 * -errno : An error occured.
355 * data is the error string.
357 EXTERN
int nfs_open_async(struct nfs_context
*nfs
, const char *path
, int flags
, nfs_cb cb
, void *private_data
);
359 * Sync open(<filename>)
361 * 0 : The operation was successfull. *nfsfh is filled in.
362 * -errno : The command failed.
364 EXTERN
int nfs_open(struct nfs_context
*nfs
, const char *path
, int flags
, struct nfsfh
**nfsfh
);
376 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
377 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
379 * When the callback is invoked, status indicates the result:
382 * -errno : An error occured.
383 * data is the error string.
385 EXTERN
int nfs_close_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, nfs_cb cb
, void *private_data
);
389 * 0 : The operation was successfull.
390 * -errno : The command failed.
392 EXTERN
int nfs_close(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
);
402 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
403 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
405 * When the callback is invoked, status indicates the result:
407 * status is numer of bytes read.
408 * data is a pointer to the returned data.
409 * -errno : An error occured.
410 * data is the error string.
412 EXTERN
int nfs_pread_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t offset
, uint64_t count
, nfs_cb cb
, void *private_data
);
416 * >=0 : numer of bytes read.
417 * -errno : An error occured.
419 EXTERN
int nfs_pread(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t offset
, uint64_t count
, char *buf
);
430 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
431 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
433 * When the callback is invoked, status indicates the result:
435 * status is numer of bytes read.
436 * data is a pointer to the returned data.
437 * -errno : An error occured.
438 * data is the error string.
440 EXTERN
int nfs_read_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t count
, nfs_cb cb
, void *private_data
);
444 * >=0 : numer of bytes read.
445 * -errno : An error occured.
447 EXTERN
int nfs_read(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t count
, char *buf
);
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.
462 * When the callback is invoked, status indicates the result:
464 * status is numer of bytes written.
465 * -errno : An error occured.
466 * data is the error string.
468 EXTERN
int nfs_pwrite_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t offset
, uint64_t count
, char *buf
, nfs_cb cb
, void *private_data
);
472 * >=0 : numer of bytes written.
473 * -errno : An error occured.
475 EXTERN
int nfs_pwrite(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t offset
, uint64_t count
, char *buf
);
485 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
486 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
488 * When the callback is invoked, status indicates the result:
490 * status is numer of bytes written.
491 * -errno : An error occured.
492 * data is the error string.
494 EXTERN
int nfs_write_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t count
, char *buf
, nfs_cb cb
, void *private_data
);
498 * >=0 : numer of bytes written.
499 * -errno : An error occured.
501 EXTERN
int nfs_write(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t count
, char *buf
);
511 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
512 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
514 * When the callback is invoked, status indicates the result:
516 * data is uint64_t * for the current position.
517 * -errno : An error occured.
518 * data is the error string.
520 EXTERN
int nfs_lseek_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int64_t offset
, int whence
, nfs_cb cb
, void *private_data
);
524 * >=0 : numer of bytes read.
525 * -errno : An error occured.
527 EXTERN
int nfs_lseek(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int64_t offset
, int whence
, uint64_t *current_offset
);
537 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
538 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
540 * When the callback is invoked, status indicates the result:
542 * -errno : An error occured.
543 * data is the error string.
545 EXTERN
int nfs_fsync_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, nfs_cb cb
, void *private_data
);
550 * -errno : An error occured.
552 EXTERN
int nfs_fsync(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
);
563 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
564 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
566 * When the callback is invoked, status indicates the result:
568 * -errno : An error occured.
569 * data is the error string.
571 EXTERN
int nfs_truncate_async(struct nfs_context
*nfs
, const char *path
, uint64_t length
, nfs_cb cb
, void *private_data
);
576 * -errno : An error occured.
578 EXTERN
int nfs_truncate(struct nfs_context
*nfs
, const char *path
, uint64_t length
);
589 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
590 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
592 * When the callback is invoked, status indicates the result:
594 * -errno : An error occured.
595 * data is the error string.
597 EXTERN
int nfs_ftruncate_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t length
, nfs_cb cb
, void *private_data
);
602 * -errno : An error occured.
604 EXTERN
int nfs_ftruncate(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t length
);
618 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
619 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
621 * When the callback is invoked, status indicates the result:
623 * -errno : An error occured.
624 * data is the error string.
626 EXTERN
int nfs_mkdir_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
631 * -errno : An error occured.
633 EXTERN
int nfs_mkdir(struct nfs_context
*nfs
, const char *path
);
644 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
645 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
647 * When the callback is invoked, status indicates the result:
649 * -errno : An error occured.
650 * data is the error string.
652 EXTERN
int nfs_rmdir_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
657 * -errno : An error occured.
659 EXTERN
int nfs_rmdir(struct nfs_context
*nfs
, const char *path
);
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.
674 * When the callback is invoked, status indicates the result:
676 * data is a struct *nfsfh;
677 * -errno : An error occured.
678 * data is the error string.
680 EXTERN
int nfs_creat_async(struct nfs_context
*nfs
, const char *path
, int mode
, nfs_cb cb
, void *private_data
);
685 * -errno : An error occured.
687 EXTERN
int nfs_creat(struct nfs_context
*nfs
, const char *path
, int mode
, struct nfsfh
**nfsfh
);
692 * Same as nfs_creat_async but allows passing flags:
698 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
699 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
701 * When the callback is invoked, status indicates the result:
703 * data is a struct *nfsfh;
704 * -errno : An error occured.
705 * data is the error string.
707 EXTERN
int nfs_create_async(struct nfs_context
*nfs
, const char *path
, int flags
, int mode
, nfs_cb cb
, void *private_data
);
712 * -errno : An error occured.
714 EXTERN
int nfs_create(struct nfs_context
*nfs
, const char *path
, int flags
, int mode
, struct nfsfh
**nfsfh
);
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.
727 * When the callback is invoked, status indicates the result:
729 * -errno : An error occured.
730 * data is the error string.
732 EXTERN
int nfs_mknod_async(struct nfs_context
*nfs
, const char *path
, int mode
, int dev
, nfs_cb cb
, void *private_data
);
737 * -errno : An error occured.
739 EXTERN
int nfs_mknod(struct nfs_context
*nfs
, const char *path
, int mode
, int dev
);
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.
753 * When the callback is invoked, status indicates the result:
756 * -errno : An error occured.
757 * data is the error string.
759 EXTERN
int nfs_unlink_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
764 * -errno : An error occured.
766 EXTERN
int nfs_unlink(struct nfs_context
*nfs
, const char *path
);
779 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
780 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
782 * When struct nfsdir * is returned, this resource is closed/freed by calling nfs_closedir()
784 * When the callback is invoked, status indicates the result:
786 * data is struct nfsdir *
787 * -errno : An error occured.
788 * data is the error string.
790 EXTERN
int nfs_opendir_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
795 * -errno : An error occured.
797 EXTERN
int nfs_opendir(struct nfs_context
*nfs
, const char *path
, struct nfsdir
**nfsdir
);
805 struct nfsdirent
*next
;
809 /* Some extra fields we get for free through the READDIRPLUS3 call.
810 You need libnfs-raw-nfs.h for type/mode constants */
811 uint32_t type
; /* NF3REG, NF3DIR, NF3BLK, ... */
814 struct timeval atime
;
815 struct timeval mtime
;
816 struct timeval ctime
;
830 * nfs_readdir() never blocks, so no special sync/async versions are available
832 EXTERN
struct nfsdirent
*nfs_readdir(struct nfs_context
*nfs
, struct nfsdir
*nfsdir
);
840 * nfs_closedir() never blocks, so no special sync/async versions are available
842 EXTERN
void nfs_closedir(struct nfs_context
*nfs
, struct nfsdir
*nfsdir
);
849 * Async chdir(<path>)
852 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
853 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
855 * When the callback is invoked, status indicates the result:
858 * -errno : An error occured.
859 * data is the error string.
861 EXTERN
int nfs_chdir_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
865 * 0 : The operation was successfull.
866 * -errno : The command failed.
868 EXTERN
int nfs_chdir(struct nfs_context
*nfs
, const char *path
);
874 * nfs_getcwd() never blocks, so no special sync/async versions are available
878 * This function returns a pointer to the current working directory.
879 * This pointer is only stable until the next [f]chdir or when the
880 * context is destroyed.
883 * 0 : The operation was successfull and *cwd is filled in.
884 * -errno : The command failed.
886 EXTERN
void nfs_getcwd(struct nfs_context
*nfs
, const char **cwd
);
893 * Async statvfs(<dirname>)
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.
898 * When the callback is invoked, status indicates the result:
900 * data is struct statvfs *
901 * -errno : An error occured.
902 * data is the error string.
905 EXTERN
int nfs_statvfs_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
907 * Sync statvfs(<dirname>)
909 * 0 : The operation was successfull.
910 * -errno : The command failed.
912 EXTERN
int nfs_statvfs(struct nfs_context
*nfs
, const char *path
, struct statvfs
*svfs
);
919 * Async readlink(<name>)
921 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
922 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
924 * When the callback is invoked, status indicates the result:
927 * data is only valid during the callback and is automatically freed when the callback returns.
928 * -errno : An error occured.
929 * data is the error string.
932 EXTERN
int nfs_readlink_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
934 * Sync readlink(<name>)
936 * 0 : The operation was successfull.
937 * -errno : The command failed.
939 EXTERN
int nfs_readlink(struct nfs_context
*nfs
, const char *path
, char *buf
, int bufsize
);
947 * Async chmod(<name>)
949 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
950 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
952 * When the callback is invoked, status indicates the result:
955 * -errno : An error occured.
956 * data is the error string.
958 EXTERN
int nfs_chmod_async(struct nfs_context
*nfs
, const char *path
, int mode
, nfs_cb cb
, void *private_data
);
962 * 0 : The operation was successfull.
963 * -errno : The command failed.
965 EXTERN
int nfs_chmod(struct nfs_context
*nfs
, const char *path
, int mode
);
973 * Async fchmod(<handle>)
975 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
976 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
978 * When the callback is invoked, status indicates the result:
981 * -errno : An error occured.
982 * data is the error string.
984 EXTERN
int nfs_fchmod_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int mode
, nfs_cb cb
, void *private_data
);
986 * Sync fchmod(<handle>)
988 * 0 : The operation was successfull.
989 * -errno : The command failed.
991 EXTERN
int nfs_fchmod(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int mode
);
999 * Async chown(<name>)
1001 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1002 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1004 * When the callback is invoked, status indicates the result:
1007 * -errno : An error occured.
1008 * data is the error string.
1010 EXTERN
int nfs_chown_async(struct nfs_context
*nfs
, const char *path
, int uid
, int gid
, nfs_cb cb
, void *private_data
);
1012 * Sync chown(<name>)
1014 * 0 : The operation was successfull.
1015 * -errno : The command failed.
1017 EXTERN
int nfs_chown(struct nfs_context
*nfs
, const char *path
, int uid
, int gid
);
1025 * Async fchown(<handle>)
1027 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1028 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1030 * When the callback is invoked, status indicates the result:
1033 * -errno : An error occured.
1034 * data is the error string.
1036 EXTERN
int nfs_fchown_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int uid
, int gid
, nfs_cb cb
, void *private_data
);
1038 * Sync fchown(<handle>)
1040 * 0 : The operation was successfull.
1041 * -errno : The command failed.
1043 EXTERN
int nfs_fchown(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int uid
, int gid
);
1052 * Async utimes(<path>)
1054 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1055 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1057 * When the callback is invoked, status indicates the result:
1060 * -errno : An error occured.
1061 * data is the error string.
1063 EXTERN
int nfs_utimes_async(struct nfs_context
*nfs
, const char *path
, struct timeval
*times
, nfs_cb cb
, void *private_data
);
1065 * Sync utimes(<path>)
1067 * 0 : The operation was successfull.
1068 * -errno : The command failed.
1070 EXTERN
int nfs_utimes(struct nfs_context
*nfs
, const char *path
, struct timeval
*times
);
1077 * Async utime(<path>)
1079 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1080 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1082 * When the callback is invoked, status indicates the result:
1085 * -errno : An error occured.
1086 * data is the error string.
1089 EXTERN
int nfs_utime_async(struct nfs_context
*nfs
, const char *path
, struct utimbuf
*times
, nfs_cb cb
, void *private_data
);
1091 * Sync utime(<path>)
1093 * 0 : The operation was successfull.
1094 * -errno : The command failed.
1096 EXTERN
int nfs_utime(struct nfs_context
*nfs
, const char *path
, struct utimbuf
*times
);
1105 * Async access(<path>)
1107 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1108 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1110 * When the callback is invoked, status indicates the result:
1113 * -errno : An error occured.
1114 * data is the error string.
1116 EXTERN
int nfs_access_async(struct nfs_context
*nfs
, const char *path
, int mode
, nfs_cb cb
, void *private_data
);
1118 * Sync access(<path>)
1120 * 0 : The operation was successfull.
1121 * -errno : The command failed.
1123 EXTERN
int nfs_access(struct nfs_context
*nfs
, const char *path
, int mode
);
1132 * Async symlink(<path>)
1134 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1135 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1137 * When the callback is invoked, status indicates the result:
1140 * -errno : An error occured.
1141 * data is the error string.
1143 EXTERN
int nfs_symlink_async(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
, nfs_cb cb
, void *private_data
);
1145 * Sync symlink(<path>)
1147 * 0 : The operation was successfull.
1148 * -errno : The command failed.
1150 EXTERN
int nfs_symlink(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
);
1157 * Async rename(<oldpath>, <newpath>)
1159 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1160 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1162 * When the callback is invoked, status indicates the result:
1165 * -errno : An error occured.
1166 * data is the error string.
1168 EXTERN
int nfs_rename_async(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
, nfs_cb cb
, void *private_data
);
1170 * Sync rename(<oldpath>, <newpath>)
1172 * 0 : The operation was successfull.
1173 * -errno : The command failed.
1175 EXTERN
int nfs_rename(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
);
1183 * Async link(<oldpath>, <newpath>)
1185 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1186 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1188 * When the callback is invoked, status indicates the result:
1191 * -errno : An error occured.
1192 * data is the error string.
1194 EXTERN
int nfs_link_async(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
, nfs_cb cb
, void *private_data
);
1196 * Sync link(<oldpath>, <newpath>)
1198 * 0 : The operation was successfull.
1199 * -errno : The command failed.
1201 EXTERN
int nfs_link(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
);
1208 * Async getexports()
1209 * NOTE: You must include 'libnfs-raw-mount.h' to get the definitions of the
1210 * returned structures.
1212 * This function will return the list of exports from an NFS server.
1215 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1216 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1218 * When the callback is invoked, status indicates the result:
1220 * data is a pointer to an exports pointer:
1221 * exports export = *(exports *)data;
1222 * -errno : An error occured.
1223 * data is the error string.
1225 EXTERN
int mount_getexports_async(struct rpc_context
*rpc
, const char *server
, rpc_cb cb
, void *private_data
);
1227 * Sync getexports(<server>)
1229 * NULL : something failed
1230 * exports export : a linked list of exported directories
1232 * returned data must be freed by calling mount_free_export_list(exportnode);
1234 EXTERN
struct exportnode
*mount_getexports(const char *server
);
1236 EXTERN
void mount_free_export_list(struct exportnode
*exports
);
1239 //qqq replace later with lseek(cur, 0)
1240 uint64_t nfs_get_current_offset(struct nfsfh
*nfsfh
);
1246 struct nfs_server_list
{
1247 struct nfs_server_list
*next
;
1252 * Sync find_local_servers(<server>)
1253 * This function will probe all local networks for NFS server. This function will
1254 * block for one second while awaiting for all nfs servers to respond.
1257 * NULL : something failed
1259 * struct nfs_server_list : a linked list of all discovered servers
1261 * returned data must be freed by nfs_free_srvr_list(srv);
1263 struct nfs_server_list
*nfs_find_local_servers(void);
1264 void free_nfs_srvr_list(struct nfs_server_list
*srv
);
1270 #endif /* !_LIBNFS_H_ */