2149b8a8fa8ebe1fffe4cc7700569aae7f8f1c93
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 /* This function is deprecated. Use nfs_fstat64_async() instead */
316 EXTERN
int nfs_fstat_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, nfs_cb cb
, void *private_data
);
318 * Sync fstat(nfsfh *)
320 * 0 : The operation was successfull.
321 * -errno : The command failed.
324 EXTERN
int nfs_fstat(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, struct __stat64
*st
);
326 EXTERN
int nfs_fstat(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, struct stat
*st
);
330 * 64 bit version of fstat. All fields are always 64bit.
331 * Use these functions instead of nfs_fstat[_async](), especially if you
332 * have weird stat structures.
338 * Async fstat(nfsfh *)
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 * When the callback is invoked, status indicates the result:
345 * data is struct stat *
346 * -errno : An error occured.
347 * data is the error string.
349 EXTERN
int nfs_fstat64_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, nfs_cb cb
, void *private_data
);
351 * Sync fstat(nfsfh *)
353 * 0 : The operation was successfull.
354 * -errno : The command failed.
356 EXTERN
int nfs_fstat64(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, struct nfs_stat_64
*st
);
364 * Async open(<filename>)
366 * mode is a combination of the flags :
367 * O_RDOLNY, O_WRONLY, O_RDWR , O_SYNC, O_APPEND, O_TRUNC
370 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
371 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
373 * Supported flags are
379 * O_TRUNC (Only valid with O_RDWR or O_WRONLY. Ignored otherwise.)
381 * When the callback is invoked, status indicates the result:
383 * data is a struct *nfsfh;
384 * The nfsfh is close using nfs_close().
385 * -errno : An error occured.
386 * data is the error string.
388 EXTERN
int nfs_open_async(struct nfs_context
*nfs
, const char *path
, int flags
, nfs_cb cb
, void *private_data
);
390 * Sync open(<filename>)
392 * 0 : The operation was successfull. *nfsfh is filled in.
393 * -errno : The command failed.
395 EXTERN
int nfs_open(struct nfs_context
*nfs
, const char *path
, int flags
, struct nfsfh
**nfsfh
);
407 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
408 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
410 * When the callback is invoked, status indicates the result:
413 * -errno : An error occured.
414 * data is the error string.
416 EXTERN
int nfs_close_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, nfs_cb cb
, void *private_data
);
420 * 0 : The operation was successfull.
421 * -errno : The command failed.
423 EXTERN
int nfs_close(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
);
433 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
434 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
436 * When the callback is invoked, status indicates the result:
438 * status is numer of bytes read.
439 * data is a pointer to the returned data.
440 * -errno : An error occured.
441 * data is the error string.
443 EXTERN
int nfs_pread_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t offset
, uint64_t count
, nfs_cb cb
, void *private_data
);
447 * >=0 : numer of bytes read.
448 * -errno : An error occured.
450 EXTERN
int nfs_pread(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t offset
, uint64_t count
, char *buf
);
461 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
462 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
464 * When the callback is invoked, status indicates the result:
466 * status is numer of bytes read.
467 * data is a pointer to the returned data.
468 * -errno : An error occured.
469 * data is the error string.
471 EXTERN
int nfs_read_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t count
, nfs_cb cb
, void *private_data
);
475 * >=0 : numer of bytes read.
476 * -errno : An error occured.
478 EXTERN
int nfs_read(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t count
, char *buf
);
490 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
491 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
493 * When the callback is invoked, status indicates the result:
495 * status is numer of bytes written.
496 * -errno : An error occured.
497 * data is the error string.
499 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
);
503 * >=0 : numer of bytes written.
504 * -errno : An error occured.
506 EXTERN
int nfs_pwrite(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t offset
, uint64_t count
, char *buf
);
516 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
517 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
519 * When the callback is invoked, status indicates the result:
521 * status is numer of bytes written.
522 * -errno : An error occured.
523 * data is the error string.
525 EXTERN
int nfs_write_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t count
, char *buf
, nfs_cb cb
, void *private_data
);
529 * >=0 : numer of bytes written.
530 * -errno : An error occured.
532 EXTERN
int nfs_write(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t count
, char *buf
);
542 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
543 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
545 * When the callback is invoked, status indicates the result:
547 * data is uint64_t * for the current position.
548 * -errno : An error occured.
549 * data is the error string.
551 EXTERN
int nfs_lseek_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int64_t offset
, int whence
, nfs_cb cb
, void *private_data
);
555 * >=0 : numer of bytes read.
556 * -errno : An error occured.
558 EXTERN
int nfs_lseek(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int64_t offset
, int whence
, uint64_t *current_offset
);
568 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
569 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
571 * When the callback is invoked, status indicates the result:
573 * -errno : An error occured.
574 * data is the error string.
576 EXTERN
int nfs_fsync_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, nfs_cb cb
, void *private_data
);
581 * -errno : An error occured.
583 EXTERN
int nfs_fsync(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
);
594 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
595 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
597 * When the callback is invoked, status indicates the result:
599 * -errno : An error occured.
600 * data is the error string.
602 EXTERN
int nfs_truncate_async(struct nfs_context
*nfs
, const char *path
, uint64_t length
, nfs_cb cb
, void *private_data
);
607 * -errno : An error occured.
609 EXTERN
int nfs_truncate(struct nfs_context
*nfs
, const char *path
, uint64_t length
);
620 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
621 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
623 * When the callback is invoked, status indicates the result:
625 * -errno : An error occured.
626 * data is the error string.
628 EXTERN
int nfs_ftruncate_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t length
, nfs_cb cb
, void *private_data
);
633 * -errno : An error occured.
635 EXTERN
int nfs_ftruncate(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t length
);
649 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
650 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
652 * When the callback is invoked, status indicates the result:
654 * -errno : An error occured.
655 * data is the error string.
657 EXTERN
int nfs_mkdir_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
662 * -errno : An error occured.
664 EXTERN
int nfs_mkdir(struct nfs_context
*nfs
, const char *path
);
675 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
676 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
678 * When the callback is invoked, status indicates the result:
680 * -errno : An error occured.
681 * data is the error string.
683 EXTERN
int nfs_rmdir_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
688 * -errno : An error occured.
690 EXTERN
int nfs_rmdir(struct nfs_context
*nfs
, const char *path
);
702 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
703 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
705 * When the callback is invoked, status indicates the result:
707 * data is a struct *nfsfh;
708 * -errno : An error occured.
709 * data is the error string.
711 EXTERN
int nfs_creat_async(struct nfs_context
*nfs
, const char *path
, int mode
, nfs_cb cb
, void *private_data
);
716 * -errno : An error occured.
718 EXTERN
int nfs_creat(struct nfs_context
*nfs
, const char *path
, int mode
, struct nfsfh
**nfsfh
);
723 * Same as nfs_creat_async but allows passing flags:
730 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
731 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
733 * When the callback is invoked, status indicates the result:
735 * data is a struct *nfsfh;
736 * -errno : An error occured.
737 * data is the error string.
739 EXTERN
int nfs_create_async(struct nfs_context
*nfs
, const char *path
, int flags
, int mode
, nfs_cb cb
, void *private_data
);
744 * -errno : An error occured.
746 EXTERN
int nfs_create(struct nfs_context
*nfs
, const char *path
, int flags
, int mode
, struct nfsfh
**nfsfh
);
756 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
757 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
759 * When the callback is invoked, status indicates the result:
761 * -errno : An error occured.
762 * data is the error string.
764 EXTERN
int nfs_mknod_async(struct nfs_context
*nfs
, const char *path
, int mode
, int dev
, nfs_cb cb
, void *private_data
);
769 * -errno : An error occured.
771 EXTERN
int nfs_mknod(struct nfs_context
*nfs
, const char *path
, int mode
, int dev
);
782 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
783 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
785 * When the callback is invoked, status indicates the result:
788 * -errno : An error occured.
789 * data is the error string.
791 EXTERN
int nfs_unlink_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
796 * -errno : An error occured.
798 EXTERN
int nfs_unlink(struct nfs_context
*nfs
, const char *path
);
811 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
812 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
814 * When struct nfsdir * is returned, this resource is closed/freed by calling nfs_closedir()
816 * When the callback is invoked, status indicates the result:
818 * data is struct nfsdir *
819 * -errno : An error occured.
820 * data is the error string.
822 EXTERN
int nfs_opendir_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
827 * -errno : An error occured.
829 EXTERN
int nfs_opendir(struct nfs_context
*nfs
, const char *path
, struct nfsdir
**nfsdir
);
837 struct nfsdirent
*next
;
841 /* Some extra fields we get for free through the READDIRPLUS3 call.
842 You need libnfs-raw-nfs.h for type/mode constants */
843 uint32_t type
; /* NF3REG, NF3DIR, NF3BLK, ... */
846 struct timeval atime
;
847 struct timeval mtime
;
848 struct timeval ctime
;
862 * nfs_readdir() never blocks, so no special sync/async versions are available
864 EXTERN
struct nfsdirent
*nfs_readdir(struct nfs_context
*nfs
, struct nfsdir
*nfsdir
);
872 * nfs_closedir() never blocks, so no special sync/async versions are available
874 EXTERN
void nfs_closedir(struct nfs_context
*nfs
, struct nfsdir
*nfsdir
);
881 * Async chdir(<path>)
884 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
885 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
887 * When the callback is invoked, status indicates the result:
890 * -errno : An error occured.
891 * data is the error string.
893 EXTERN
int nfs_chdir_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
897 * 0 : The operation was successfull.
898 * -errno : The command failed.
900 EXTERN
int nfs_chdir(struct nfs_context
*nfs
, const char *path
);
906 * nfs_getcwd() never blocks, so no special sync/async versions are available
910 * This function returns a pointer to the current working directory.
911 * This pointer is only stable until the next [f]chdir or when the
912 * context is destroyed.
915 * 0 : The operation was successfull and *cwd is filled in.
916 * -errno : The command failed.
918 EXTERN
void nfs_getcwd(struct nfs_context
*nfs
, const char **cwd
);
925 * Async statvfs(<dirname>)
927 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
928 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
930 * When the callback is invoked, status indicates the result:
932 * data is struct statvfs *
933 * -errno : An error occured.
934 * data is the error string.
937 EXTERN
int nfs_statvfs_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
939 * Sync statvfs(<dirname>)
941 * 0 : The operation was successfull.
942 * -errno : The command failed.
944 EXTERN
int nfs_statvfs(struct nfs_context
*nfs
, const char *path
, struct statvfs
*svfs
);
951 * Async readlink(<name>)
953 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
954 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
956 * When the callback is invoked, status indicates the result:
959 * data is only valid during the callback and is automatically freed when the callback returns.
960 * -errno : An error occured.
961 * data is the error string.
964 EXTERN
int nfs_readlink_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
966 * Sync readlink(<name>)
968 * 0 : The operation was successfull.
969 * -errno : The command failed.
971 EXTERN
int nfs_readlink(struct nfs_context
*nfs
, const char *path
, char *buf
, int bufsize
);
979 * Async chmod(<name>)
981 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
982 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
984 * When the callback is invoked, status indicates the result:
987 * -errno : An error occured.
988 * data is the error string.
990 EXTERN
int nfs_chmod_async(struct nfs_context
*nfs
, const char *path
, int mode
, nfs_cb cb
, void *private_data
);
994 * 0 : The operation was successfull.
995 * -errno : The command failed.
997 EXTERN
int nfs_chmod(struct nfs_context
*nfs
, const char *path
, int mode
);
1005 * Async fchmod(<handle>)
1007 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1008 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1010 * When the callback is invoked, status indicates the result:
1013 * -errno : An error occured.
1014 * data is the error string.
1016 EXTERN
int nfs_fchmod_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int mode
, nfs_cb cb
, void *private_data
);
1018 * Sync fchmod(<handle>)
1020 * 0 : The operation was successfull.
1021 * -errno : The command failed.
1023 EXTERN
int nfs_fchmod(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int mode
);
1031 * Async chown(<name>)
1033 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1034 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1036 * When the callback is invoked, status indicates the result:
1039 * -errno : An error occured.
1040 * data is the error string.
1042 EXTERN
int nfs_chown_async(struct nfs_context
*nfs
, const char *path
, int uid
, int gid
, nfs_cb cb
, void *private_data
);
1044 * Sync chown(<name>)
1046 * 0 : The operation was successfull.
1047 * -errno : The command failed.
1049 EXTERN
int nfs_chown(struct nfs_context
*nfs
, const char *path
, int uid
, int gid
);
1057 * Async fchown(<handle>)
1059 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1060 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1062 * When the callback is invoked, status indicates the result:
1065 * -errno : An error occured.
1066 * data is the error string.
1068 EXTERN
int nfs_fchown_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int uid
, int gid
, nfs_cb cb
, void *private_data
);
1070 * Sync fchown(<handle>)
1072 * 0 : The operation was successfull.
1073 * -errno : The command failed.
1075 EXTERN
int nfs_fchown(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int uid
, int gid
);
1084 * Async utimes(<path>)
1086 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1087 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1089 * When the callback is invoked, status indicates the result:
1092 * -errno : An error occured.
1093 * data is the error string.
1095 EXTERN
int nfs_utimes_async(struct nfs_context
*nfs
, const char *path
, struct timeval
*times
, nfs_cb cb
, void *private_data
);
1097 * Sync utimes(<path>)
1099 * 0 : The operation was successfull.
1100 * -errno : The command failed.
1102 EXTERN
int nfs_utimes(struct nfs_context
*nfs
, const char *path
, struct timeval
*times
);
1109 * Async utime(<path>)
1111 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1112 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1114 * When the callback is invoked, status indicates the result:
1117 * -errno : An error occured.
1118 * data is the error string.
1121 EXTERN
int nfs_utime_async(struct nfs_context
*nfs
, const char *path
, struct utimbuf
*times
, nfs_cb cb
, void *private_data
);
1123 * Sync utime(<path>)
1125 * 0 : The operation was successfull.
1126 * -errno : The command failed.
1128 EXTERN
int nfs_utime(struct nfs_context
*nfs
, const char *path
, struct utimbuf
*times
);
1137 * Async access(<path>)
1139 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1140 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1142 * When the callback is invoked, status indicates the result:
1145 * -errno : An error occured.
1146 * data is the error string.
1148 EXTERN
int nfs_access_async(struct nfs_context
*nfs
, const char *path
, int mode
, nfs_cb cb
, void *private_data
);
1150 * Sync access(<path>)
1152 * 0 : The operation was successfull.
1153 * -errno : The command failed.
1155 EXTERN
int nfs_access(struct nfs_context
*nfs
, const char *path
, int mode
);
1164 * Async symlink(<path>)
1166 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1167 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1169 * When the callback is invoked, status indicates the result:
1172 * -errno : An error occured.
1173 * data is the error string.
1175 EXTERN
int nfs_symlink_async(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
, nfs_cb cb
, void *private_data
);
1177 * Sync symlink(<path>)
1179 * 0 : The operation was successfull.
1180 * -errno : The command failed.
1182 EXTERN
int nfs_symlink(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
);
1189 * Async rename(<oldpath>, <newpath>)
1191 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1192 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1194 * When the callback is invoked, status indicates the result:
1197 * -errno : An error occured.
1198 * data is the error string.
1200 EXTERN
int nfs_rename_async(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
, nfs_cb cb
, void *private_data
);
1202 * Sync rename(<oldpath>, <newpath>)
1204 * 0 : The operation was successfull.
1205 * -errno : The command failed.
1207 EXTERN
int nfs_rename(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
);
1215 * Async link(<oldpath>, <newpath>)
1217 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1218 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1220 * When the callback is invoked, status indicates the result:
1223 * -errno : An error occured.
1224 * data is the error string.
1226 EXTERN
int nfs_link_async(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
, nfs_cb cb
, void *private_data
);
1228 * Sync link(<oldpath>, <newpath>)
1230 * 0 : The operation was successfull.
1231 * -errno : The command failed.
1233 EXTERN
int nfs_link(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
);
1240 * Async getexports()
1241 * NOTE: You must include 'libnfs-raw-mount.h' to get the definitions of the
1242 * returned structures.
1244 * This function will return the list of exports from an NFS server.
1247 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1248 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1250 * When the callback is invoked, status indicates the result:
1252 * data is a pointer to an exports pointer:
1253 * exports export = *(exports *)data;
1254 * -errno : An error occured.
1255 * data is the error string.
1257 EXTERN
int mount_getexports_async(struct rpc_context
*rpc
, const char *server
, rpc_cb cb
, void *private_data
);
1259 * Sync getexports(<server>)
1261 * NULL : something failed
1262 * exports export : a linked list of exported directories
1264 * returned data must be freed by calling mount_free_export_list(exportnode);
1266 EXTERN
struct exportnode
*mount_getexports(const char *server
);
1268 EXTERN
void mount_free_export_list(struct exportnode
*exports
);
1271 //qqq replace later with lseek(cur, 0)
1272 uint64_t nfs_get_current_offset(struct nfsfh
*nfsfh
);
1278 struct nfs_server_list
{
1279 struct nfs_server_list
*next
;
1284 * Sync find_local_servers(<server>)
1285 * This function will probe all local networks for NFS server. This function will
1286 * block for one second while awaiting for all nfs servers to respond.
1289 * NULL : something failed
1291 * struct nfs_server_list : a linked list of all discovered servers
1293 * returned data must be freed by nfs_free_srvr_list(srv);
1295 struct nfs_server_list
*nfs_find_local_servers(void);
1296 void free_nfs_srvr_list(struct nfs_server_list
*srv
);
1302 #endif /* !_LIBNFS_H_ */