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
;
276 * Async stat(<filename>)
278 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
279 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
281 * When the callback is invoked, status indicates the result:
283 * data is struct nfs_stat_64 *
284 * -errno : An error occured.
285 * data is the error string.
287 EXTERN
int nfs_stat64_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
289 * Sync stat(<filename>)
291 * 0 : The operation was successfull.
292 * -errno : The command failed.
294 EXTERN
int nfs_stat64(struct nfs_context
*nfs
, const char *path
, struct nfs_stat_64
*st
);
300 * Async fstat(nfsfh *)
302 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
303 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
305 * When the callback is invoked, status indicates the result:
307 * data is struct stat *
308 * -errno : An error occured.
309 * data is the error string.
311 EXTERN
int nfs_fstat_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, nfs_cb cb
, void *private_data
);
313 * Sync fstat(nfsfh *)
315 * 0 : The operation was successfull.
316 * -errno : The command failed.
319 EXTERN
int nfs_fstat(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, struct __stat64
*st
);
321 EXTERN
int nfs_fstat(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, struct stat
*st
);
330 * Async open(<filename>)
332 * mode is a combination of the flags :
333 * O_RDOLNY, O_WRONLY, O_RDWR , O_SYNC, O_APPEND, O_TRUNC
336 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
337 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
339 * Supported flags are
345 * O_TRUNC (Only valid with O_RDWR or O_WRONLY. Ignored otherwise.)
347 * When the callback is invoked, status indicates the result:
349 * data is a struct *nfsfh;
350 * The nfsfh is close using nfs_close().
351 * -errno : An error occured.
352 * data is the error string.
354 EXTERN
int nfs_open_async(struct nfs_context
*nfs
, const char *path
, int flags
, nfs_cb cb
, void *private_data
);
356 * Sync open(<filename>)
358 * 0 : The operation was successfull. *nfsfh is filled in.
359 * -errno : The command failed.
361 EXTERN
int nfs_open(struct nfs_context
*nfs
, const char *path
, int flags
, struct nfsfh
**nfsfh
);
373 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
374 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
376 * When the callback is invoked, status indicates the result:
379 * -errno : An error occured.
380 * data is the error string.
382 EXTERN
int nfs_close_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, nfs_cb cb
, void *private_data
);
386 * 0 : The operation was successfull.
387 * -errno : The command failed.
389 EXTERN
int nfs_close(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
);
399 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
400 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
402 * When the callback is invoked, status indicates the result:
404 * status is numer of bytes read.
405 * data is a pointer to the returned data.
406 * -errno : An error occured.
407 * data is the error string.
409 EXTERN
int nfs_pread_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t offset
, uint64_t count
, nfs_cb cb
, void *private_data
);
413 * >=0 : numer of bytes read.
414 * -errno : An error occured.
416 EXTERN
int nfs_pread(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t offset
, uint64_t count
, char *buf
);
427 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
428 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
430 * When the callback is invoked, status indicates the result:
432 * status is numer of bytes read.
433 * data is a pointer to the returned data.
434 * -errno : An error occured.
435 * data is the error string.
437 EXTERN
int nfs_read_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t count
, nfs_cb cb
, void *private_data
);
441 * >=0 : numer of bytes read.
442 * -errno : An error occured.
444 EXTERN
int nfs_read(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t count
, char *buf
);
456 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
457 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
459 * When the callback is invoked, status indicates the result:
461 * status is numer of bytes written.
462 * -errno : An error occured.
463 * data is the error string.
465 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
);
469 * >=0 : numer of bytes written.
470 * -errno : An error occured.
472 EXTERN
int nfs_pwrite(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t offset
, uint64_t count
, char *buf
);
482 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
483 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
485 * When the callback is invoked, status indicates the result:
487 * status is numer of bytes written.
488 * -errno : An error occured.
489 * data is the error string.
491 EXTERN
int nfs_write_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t count
, char *buf
, nfs_cb cb
, void *private_data
);
495 * >=0 : numer of bytes written.
496 * -errno : An error occured.
498 EXTERN
int nfs_write(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t count
, char *buf
);
508 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
509 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
511 * When the callback is invoked, status indicates the result:
513 * data is uint64_t * for the current position.
514 * -errno : An error occured.
515 * data is the error string.
517 EXTERN
int nfs_lseek_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int64_t offset
, int whence
, nfs_cb cb
, void *private_data
);
521 * >=0 : numer of bytes read.
522 * -errno : An error occured.
524 EXTERN
int nfs_lseek(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int64_t offset
, int whence
, uint64_t *current_offset
);
534 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
535 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
537 * When the callback is invoked, status indicates the result:
539 * -errno : An error occured.
540 * data is the error string.
542 EXTERN
int nfs_fsync_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, nfs_cb cb
, void *private_data
);
547 * -errno : An error occured.
549 EXTERN
int nfs_fsync(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
);
560 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
561 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
563 * When the callback is invoked, status indicates the result:
565 * -errno : An error occured.
566 * data is the error string.
568 EXTERN
int nfs_truncate_async(struct nfs_context
*nfs
, const char *path
, uint64_t length
, nfs_cb cb
, void *private_data
);
573 * -errno : An error occured.
575 EXTERN
int nfs_truncate(struct nfs_context
*nfs
, const char *path
, uint64_t length
);
586 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
587 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
589 * When the callback is invoked, status indicates the result:
591 * -errno : An error occured.
592 * data is the error string.
594 EXTERN
int nfs_ftruncate_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t length
, nfs_cb cb
, void *private_data
);
599 * -errno : An error occured.
601 EXTERN
int nfs_ftruncate(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t length
);
615 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
616 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
618 * When the callback is invoked, status indicates the result:
620 * -errno : An error occured.
621 * data is the error string.
623 EXTERN
int nfs_mkdir_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
628 * -errno : An error occured.
630 EXTERN
int nfs_mkdir(struct nfs_context
*nfs
, const char *path
);
641 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
642 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
644 * When the callback is invoked, status indicates the result:
646 * -errno : An error occured.
647 * data is the error string.
649 EXTERN
int nfs_rmdir_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
654 * -errno : An error occured.
656 EXTERN
int nfs_rmdir(struct nfs_context
*nfs
, const char *path
);
668 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
669 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
671 * When the callback is invoked, status indicates the result:
673 * data is a struct *nfsfh;
674 * -errno : An error occured.
675 * data is the error string.
677 EXTERN
int nfs_creat_async(struct nfs_context
*nfs
, const char *path
, int mode
, nfs_cb cb
, void *private_data
);
682 * -errno : An error occured.
684 EXTERN
int nfs_creat(struct nfs_context
*nfs
, const char *path
, int mode
, struct nfsfh
**nfsfh
);
689 * Same as nfs_creat_async but allows passing flags:
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.
699 * When the callback is invoked, status indicates the result:
701 * data is a struct *nfsfh;
702 * -errno : An error occured.
703 * data is the error string.
705 EXTERN
int nfs_create_async(struct nfs_context
*nfs
, const char *path
, int flags
, int mode
, nfs_cb cb
, void *private_data
);
710 * -errno : An error occured.
712 EXTERN
int nfs_create(struct nfs_context
*nfs
, const char *path
, int flags
, int mode
, struct nfsfh
**nfsfh
);
722 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
723 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
725 * When the callback is invoked, status indicates the result:
727 * -errno : An error occured.
728 * data is the error string.
730 EXTERN
int nfs_mknod_async(struct nfs_context
*nfs
, const char *path
, int mode
, int dev
, nfs_cb cb
, void *private_data
);
735 * -errno : An error occured.
737 EXTERN
int nfs_mknod(struct nfs_context
*nfs
, const char *path
, int mode
, int dev
);
748 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
749 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
751 * When the callback is invoked, status indicates the result:
754 * -errno : An error occured.
755 * data is the error string.
757 EXTERN
int nfs_unlink_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
762 * -errno : An error occured.
764 EXTERN
int nfs_unlink(struct nfs_context
*nfs
, const char *path
);
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.
780 * When struct nfsdir * is returned, this resource is closed/freed by calling nfs_closedir()
782 * When the callback is invoked, status indicates the result:
784 * data is struct nfsdir *
785 * -errno : An error occured.
786 * data is the error string.
788 EXTERN
int nfs_opendir_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
793 * -errno : An error occured.
795 EXTERN
int nfs_opendir(struct nfs_context
*nfs
, const char *path
, struct nfsdir
**nfsdir
);
803 struct nfsdirent
*next
;
807 /* Some extra fields we get for free through the READDIRPLUS3 call.
808 You need libnfs-raw-nfs.h for type/mode constants */
809 uint32_t type
; /* NF3REG, NF3DIR, NF3BLK, ... */
812 struct timeval atime
;
813 struct timeval mtime
;
814 struct timeval ctime
;
820 * nfs_readdir() never blocks, so no special sync/async versions are available
822 EXTERN
struct nfsdirent
*nfs_readdir(struct nfs_context
*nfs
, struct nfsdir
*nfsdir
);
830 * nfs_closedir() never blocks, so no special sync/async versions are available
832 EXTERN
void nfs_closedir(struct nfs_context
*nfs
, struct nfsdir
*nfsdir
);
839 * Async chdir(<path>)
842 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
843 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
845 * When the callback is invoked, status indicates the result:
848 * -errno : An error occured.
849 * data is the error string.
851 EXTERN
int nfs_chdir_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
855 * 0 : The operation was successfull.
856 * -errno : The command failed.
858 EXTERN
int nfs_chdir(struct nfs_context
*nfs
, const char *path
);
864 * nfs_getcwd() never blocks, so no special sync/async versions are available
868 * This function returns a pointer to the current working directory.
869 * This pointer is only stable until the next [f]chdir or when the
870 * context is destroyed.
873 * 0 : The operation was successfull and *cwd is filled in.
874 * -errno : The command failed.
876 EXTERN
void nfs_getcwd(struct nfs_context
*nfs
, const char **cwd
);
883 * Async statvfs(<dirname>)
885 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
886 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
888 * When the callback is invoked, status indicates the result:
890 * data is struct statvfs *
891 * -errno : An error occured.
892 * data is the error string.
895 EXTERN
int nfs_statvfs_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
897 * Sync statvfs(<dirname>)
899 * 0 : The operation was successfull.
900 * -errno : The command failed.
902 EXTERN
int nfs_statvfs(struct nfs_context
*nfs
, const char *path
, struct statvfs
*svfs
);
909 * Async readlink(<name>)
911 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
912 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
914 * When the callback is invoked, status indicates the result:
917 * data is only valid during the callback and is automatically freed when the callback returns.
918 * -errno : An error occured.
919 * data is the error string.
922 EXTERN
int nfs_readlink_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
924 * Sync readlink(<name>)
926 * 0 : The operation was successfull.
927 * -errno : The command failed.
929 EXTERN
int nfs_readlink(struct nfs_context
*nfs
, const char *path
, char *buf
, int bufsize
);
937 * Async chmod(<name>)
939 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
940 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
942 * When the callback is invoked, status indicates the result:
945 * -errno : An error occured.
946 * data is the error string.
948 EXTERN
int nfs_chmod_async(struct nfs_context
*nfs
, const char *path
, int mode
, nfs_cb cb
, void *private_data
);
952 * 0 : The operation was successfull.
953 * -errno : The command failed.
955 EXTERN
int nfs_chmod(struct nfs_context
*nfs
, const char *path
, int mode
);
963 * Async fchmod(<handle>)
965 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
966 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
968 * When the callback is invoked, status indicates the result:
971 * -errno : An error occured.
972 * data is the error string.
974 EXTERN
int nfs_fchmod_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int mode
, nfs_cb cb
, void *private_data
);
976 * Sync fchmod(<handle>)
978 * 0 : The operation was successfull.
979 * -errno : The command failed.
981 EXTERN
int nfs_fchmod(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int mode
);
989 * Async chown(<name>)
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.
994 * When the callback is invoked, status indicates the result:
997 * -errno : An error occured.
998 * data is the error string.
1000 EXTERN
int nfs_chown_async(struct nfs_context
*nfs
, const char *path
, int uid
, int gid
, nfs_cb cb
, void *private_data
);
1002 * Sync chown(<name>)
1004 * 0 : The operation was successfull.
1005 * -errno : The command failed.
1007 EXTERN
int nfs_chown(struct nfs_context
*nfs
, const char *path
, int uid
, int gid
);
1015 * Async fchown(<handle>)
1017 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1018 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1020 * When the callback is invoked, status indicates the result:
1023 * -errno : An error occured.
1024 * data is the error string.
1026 EXTERN
int nfs_fchown_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int uid
, int gid
, nfs_cb cb
, void *private_data
);
1028 * Sync fchown(<handle>)
1030 * 0 : The operation was successfull.
1031 * -errno : The command failed.
1033 EXTERN
int nfs_fchown(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int uid
, int gid
);
1042 * Async utimes(<path>)
1044 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1045 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1047 * When the callback is invoked, status indicates the result:
1050 * -errno : An error occured.
1051 * data is the error string.
1053 EXTERN
int nfs_utimes_async(struct nfs_context
*nfs
, const char *path
, struct timeval
*times
, nfs_cb cb
, void *private_data
);
1055 * Sync utimes(<path>)
1057 * 0 : The operation was successfull.
1058 * -errno : The command failed.
1060 EXTERN
int nfs_utimes(struct nfs_context
*nfs
, const char *path
, struct timeval
*times
);
1067 * Async utime(<path>)
1069 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1070 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1072 * When the callback is invoked, status indicates the result:
1075 * -errno : An error occured.
1076 * data is the error string.
1079 EXTERN
int nfs_utime_async(struct nfs_context
*nfs
, const char *path
, struct utimbuf
*times
, nfs_cb cb
, void *private_data
);
1081 * Sync utime(<path>)
1083 * 0 : The operation was successfull.
1084 * -errno : The command failed.
1086 EXTERN
int nfs_utime(struct nfs_context
*nfs
, const char *path
, struct utimbuf
*times
);
1095 * Async access(<path>)
1097 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1098 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1100 * When the callback is invoked, status indicates the result:
1103 * -errno : An error occured.
1104 * data is the error string.
1106 EXTERN
int nfs_access_async(struct nfs_context
*nfs
, const char *path
, int mode
, nfs_cb cb
, void *private_data
);
1108 * Sync access(<path>)
1110 * 0 : The operation was successfull.
1111 * -errno : The command failed.
1113 EXTERN
int nfs_access(struct nfs_context
*nfs
, const char *path
, int mode
);
1122 * Async symlink(<path>)
1124 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1125 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1127 * When the callback is invoked, status indicates the result:
1130 * -errno : An error occured.
1131 * data is the error string.
1133 EXTERN
int nfs_symlink_async(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
, nfs_cb cb
, void *private_data
);
1135 * Sync symlink(<path>)
1137 * 0 : The operation was successfull.
1138 * -errno : The command failed.
1140 EXTERN
int nfs_symlink(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
);
1147 * Async rename(<oldpath>, <newpath>)
1149 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1150 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1152 * When the callback is invoked, status indicates the result:
1155 * -errno : An error occured.
1156 * data is the error string.
1158 EXTERN
int nfs_rename_async(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
, nfs_cb cb
, void *private_data
);
1160 * Sync rename(<oldpath>, <newpath>)
1162 * 0 : The operation was successfull.
1163 * -errno : The command failed.
1165 EXTERN
int nfs_rename(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
);
1173 * Async link(<oldpath>, <newpath>)
1175 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1176 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1178 * When the callback is invoked, status indicates the result:
1181 * -errno : An error occured.
1182 * data is the error string.
1184 EXTERN
int nfs_link_async(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
, nfs_cb cb
, void *private_data
);
1186 * Sync link(<oldpath>, <newpath>)
1188 * 0 : The operation was successfull.
1189 * -errno : The command failed.
1191 EXTERN
int nfs_link(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
);
1198 * Async getexports()
1199 * NOTE: You must include 'libnfs-raw-mount.h' to get the definitions of the
1200 * returned structures.
1202 * This function will return the list of exports from an NFS server.
1205 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1206 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1208 * When the callback is invoked, status indicates the result:
1210 * data is a pointer to an exports pointer:
1211 * exports export = *(exports *)data;
1212 * -errno : An error occured.
1213 * data is the error string.
1215 EXTERN
int mount_getexports_async(struct rpc_context
*rpc
, const char *server
, rpc_cb cb
, void *private_data
);
1217 * Sync getexports(<server>)
1219 * NULL : something failed
1220 * exports export : a linked list of exported directories
1222 * returned data must be freed by calling mount_free_export_list(exportnode);
1224 EXTERN
struct exportnode
*mount_getexports(const char *server
);
1226 EXTERN
void mount_free_export_list(struct exportnode
*exports
);
1229 //qqq replace later with lseek(cur, 0)
1230 uint64_t nfs_get_current_offset(struct nfsfh
*nfsfh
);
1236 struct nfs_server_list
{
1237 struct nfs_server_list
*next
;
1242 * Sync find_local_servers(<server>)
1243 * This function will probe all local networks for NFS server. This function will
1244 * block for one second while awaiting for all nfs servers to respond.
1247 * NULL : something failed
1249 * struct nfs_server_list : a linked list of all discovered servers
1251 * returned data must be freed by nfs_free_srvr_list(srv);
1253 struct nfs_server_list
*nfs_find_local_servers(void);
1254 void free_nfs_srvr_list(struct nfs_server_list
*srv
);
1260 #endif /* !_LIBNFS_H_ */