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
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
378 * O_TRUNC (Only valid with O_RDWR or O_WRONLY. Ignored otherwise.)
380 * When the callback is invoked, status indicates the result:
382 * data is a struct *nfsfh;
383 * The nfsfh is close using nfs_close().
384 * -errno : An error occured.
385 * data is the error string.
387 EXTERN
int nfs_open_async(struct nfs_context
*nfs
, const char *path
, int flags
, nfs_cb cb
, void *private_data
);
389 * Sync open(<filename>)
391 * 0 : The operation was successfull. *nfsfh is filled in.
392 * -errno : The command failed.
394 EXTERN
int nfs_open(struct nfs_context
*nfs
, const char *path
, int flags
, struct nfsfh
**nfsfh
);
406 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
407 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
409 * When the callback is invoked, status indicates the result:
412 * -errno : An error occured.
413 * data is the error string.
415 EXTERN
int nfs_close_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, nfs_cb cb
, void *private_data
);
419 * 0 : The operation was successfull.
420 * -errno : The command failed.
422 EXTERN
int nfs_close(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
);
432 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
433 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
435 * When the callback is invoked, status indicates the result:
437 * status is numer of bytes read.
438 * data is a pointer to the returned data.
439 * -errno : An error occured.
440 * data is the error string.
442 EXTERN
int nfs_pread_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t offset
, uint64_t count
, nfs_cb cb
, void *private_data
);
446 * >=0 : numer of bytes read.
447 * -errno : An error occured.
449 EXTERN
int nfs_pread(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t offset
, uint64_t count
, char *buf
);
460 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
461 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
463 * When the callback is invoked, status indicates the result:
465 * status is numer of bytes read.
466 * data is a pointer to the returned data.
467 * -errno : An error occured.
468 * data is the error string.
470 EXTERN
int nfs_read_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t count
, nfs_cb cb
, void *private_data
);
474 * >=0 : numer of bytes read.
475 * -errno : An error occured.
477 EXTERN
int nfs_read(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t count
, char *buf
);
489 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
490 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
492 * When the callback is invoked, status indicates the result:
494 * status is numer of bytes written.
495 * -errno : An error occured.
496 * data is the error string.
498 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
);
502 * >=0 : numer of bytes written.
503 * -errno : An error occured.
505 EXTERN
int nfs_pwrite(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t offset
, uint64_t count
, char *buf
);
515 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
516 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
518 * When the callback is invoked, status indicates the result:
520 * status is numer of bytes written.
521 * -errno : An error occured.
522 * data is the error string.
524 EXTERN
int nfs_write_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t count
, char *buf
, nfs_cb cb
, void *private_data
);
528 * >=0 : numer of bytes written.
529 * -errno : An error occured.
531 EXTERN
int nfs_write(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t count
, char *buf
);
541 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
542 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
544 * When the callback is invoked, status indicates the result:
546 * data is uint64_t * for the current position.
547 * -errno : An error occured.
548 * data is the error string.
550 EXTERN
int nfs_lseek_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int64_t offset
, int whence
, nfs_cb cb
, void *private_data
);
554 * >=0 : numer of bytes read.
555 * -errno : An error occured.
557 EXTERN
int nfs_lseek(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int64_t offset
, int whence
, uint64_t *current_offset
);
567 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
568 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
570 * When the callback is invoked, status indicates the result:
572 * -errno : An error occured.
573 * data is the error string.
575 EXTERN
int nfs_fsync_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, nfs_cb cb
, void *private_data
);
580 * -errno : An error occured.
582 EXTERN
int nfs_fsync(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
);
593 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
594 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
596 * When the callback is invoked, status indicates the result:
598 * -errno : An error occured.
599 * data is the error string.
601 EXTERN
int nfs_truncate_async(struct nfs_context
*nfs
, const char *path
, uint64_t length
, nfs_cb cb
, void *private_data
);
606 * -errno : An error occured.
608 EXTERN
int nfs_truncate(struct nfs_context
*nfs
, const char *path
, uint64_t length
);
619 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
620 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
622 * When the callback is invoked, status indicates the result:
624 * -errno : An error occured.
625 * data is the error string.
627 EXTERN
int nfs_ftruncate_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t length
, nfs_cb cb
, void *private_data
);
632 * -errno : An error occured.
634 EXTERN
int nfs_ftruncate(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t length
);
648 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
649 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
651 * When the callback is invoked, status indicates the result:
653 * -errno : An error occured.
654 * data is the error string.
656 EXTERN
int nfs_mkdir_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
661 * -errno : An error occured.
663 EXTERN
int nfs_mkdir(struct nfs_context
*nfs
, const char *path
);
674 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
675 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
677 * When the callback is invoked, status indicates the result:
679 * -errno : An error occured.
680 * data is the error string.
682 EXTERN
int nfs_rmdir_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
687 * -errno : An error occured.
689 EXTERN
int nfs_rmdir(struct nfs_context
*nfs
, const char *path
);
701 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
702 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
704 * When the callback is invoked, status indicates the result:
706 * data is a struct *nfsfh;
707 * -errno : An error occured.
708 * data is the error string.
710 EXTERN
int nfs_creat_async(struct nfs_context
*nfs
, const char *path
, int mode
, nfs_cb cb
, void *private_data
);
715 * -errno : An error occured.
717 EXTERN
int nfs_creat(struct nfs_context
*nfs
, const char *path
, int mode
, struct nfsfh
**nfsfh
);
722 * Same as nfs_creat_async but allows passing flags:
728 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
729 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
731 * When the callback is invoked, status indicates the result:
733 * data is a struct *nfsfh;
734 * -errno : An error occured.
735 * data is the error string.
737 EXTERN
int nfs_create_async(struct nfs_context
*nfs
, const char *path
, int flags
, int mode
, nfs_cb cb
, void *private_data
);
742 * -errno : An error occured.
744 EXTERN
int nfs_create(struct nfs_context
*nfs
, const char *path
, int flags
, int mode
, struct nfsfh
**nfsfh
);
754 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
755 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
757 * When the callback is invoked, status indicates the result:
759 * -errno : An error occured.
760 * data is the error string.
762 EXTERN
int nfs_mknod_async(struct nfs_context
*nfs
, const char *path
, int mode
, int dev
, nfs_cb cb
, void *private_data
);
767 * -errno : An error occured.
769 EXTERN
int nfs_mknod(struct nfs_context
*nfs
, const char *path
, int mode
, int dev
);
780 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
781 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
783 * When the callback is invoked, status indicates the result:
786 * -errno : An error occured.
787 * data is the error string.
789 EXTERN
int nfs_unlink_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
794 * -errno : An error occured.
796 EXTERN
int nfs_unlink(struct nfs_context
*nfs
, const char *path
);
809 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
810 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
812 * When struct nfsdir * is returned, this resource is closed/freed by calling nfs_closedir()
814 * When the callback is invoked, status indicates the result:
816 * data is struct nfsdir *
817 * -errno : An error occured.
818 * data is the error string.
820 EXTERN
int nfs_opendir_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
825 * -errno : An error occured.
827 EXTERN
int nfs_opendir(struct nfs_context
*nfs
, const char *path
, struct nfsdir
**nfsdir
);
835 struct nfsdirent
*next
;
839 /* Some extra fields we get for free through the READDIRPLUS3 call.
840 You need libnfs-raw-nfs.h for type/mode constants */
841 uint32_t type
; /* NF3REG, NF3DIR, NF3BLK, ... */
844 struct timeval atime
;
845 struct timeval mtime
;
846 struct timeval ctime
;
860 * nfs_readdir() never blocks, so no special sync/async versions are available
862 EXTERN
struct nfsdirent
*nfs_readdir(struct nfs_context
*nfs
, struct nfsdir
*nfsdir
);
870 * nfs_closedir() never blocks, so no special sync/async versions are available
872 EXTERN
void nfs_closedir(struct nfs_context
*nfs
, struct nfsdir
*nfsdir
);
879 * Async chdir(<path>)
882 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
883 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
885 * When the callback is invoked, status indicates the result:
888 * -errno : An error occured.
889 * data is the error string.
891 EXTERN
int nfs_chdir_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
895 * 0 : The operation was successfull.
896 * -errno : The command failed.
898 EXTERN
int nfs_chdir(struct nfs_context
*nfs
, const char *path
);
904 * nfs_getcwd() never blocks, so no special sync/async versions are available
908 * This function returns a pointer to the current working directory.
909 * This pointer is only stable until the next [f]chdir or when the
910 * context is destroyed.
913 * 0 : The operation was successfull and *cwd is filled in.
914 * -errno : The command failed.
916 EXTERN
void nfs_getcwd(struct nfs_context
*nfs
, const char **cwd
);
923 * Async statvfs(<dirname>)
925 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
926 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
928 * When the callback is invoked, status indicates the result:
930 * data is struct statvfs *
931 * -errno : An error occured.
932 * data is the error string.
935 EXTERN
int nfs_statvfs_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
937 * Sync statvfs(<dirname>)
939 * 0 : The operation was successfull.
940 * -errno : The command failed.
942 EXTERN
int nfs_statvfs(struct nfs_context
*nfs
, const char *path
, struct statvfs
*svfs
);
949 * Async readlink(<name>)
951 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
952 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
954 * When the callback is invoked, status indicates the result:
957 * data is only valid during the callback and is automatically freed when the callback returns.
958 * -errno : An error occured.
959 * data is the error string.
962 EXTERN
int nfs_readlink_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
964 * Sync readlink(<name>)
966 * 0 : The operation was successfull.
967 * -errno : The command failed.
969 EXTERN
int nfs_readlink(struct nfs_context
*nfs
, const char *path
, char *buf
, int bufsize
);
977 * Async chmod(<name>)
979 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
980 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
982 * When the callback is invoked, status indicates the result:
985 * -errno : An error occured.
986 * data is the error string.
988 EXTERN
int nfs_chmod_async(struct nfs_context
*nfs
, const char *path
, int mode
, nfs_cb cb
, void *private_data
);
992 * 0 : The operation was successfull.
993 * -errno : The command failed.
995 EXTERN
int nfs_chmod(struct nfs_context
*nfs
, const char *path
, int mode
);
1003 * Async fchmod(<handle>)
1005 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1006 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1008 * When the callback is invoked, status indicates the result:
1011 * -errno : An error occured.
1012 * data is the error string.
1014 EXTERN
int nfs_fchmod_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int mode
, nfs_cb cb
, void *private_data
);
1016 * Sync fchmod(<handle>)
1018 * 0 : The operation was successfull.
1019 * -errno : The command failed.
1021 EXTERN
int nfs_fchmod(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int mode
);
1029 * Async chown(<name>)
1031 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1032 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1034 * When the callback is invoked, status indicates the result:
1037 * -errno : An error occured.
1038 * data is the error string.
1040 EXTERN
int nfs_chown_async(struct nfs_context
*nfs
, const char *path
, int uid
, int gid
, nfs_cb cb
, void *private_data
);
1042 * Sync chown(<name>)
1044 * 0 : The operation was successfull.
1045 * -errno : The command failed.
1047 EXTERN
int nfs_chown(struct nfs_context
*nfs
, const char *path
, int uid
, int gid
);
1055 * Async fchown(<handle>)
1057 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1058 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1060 * When the callback is invoked, status indicates the result:
1063 * -errno : An error occured.
1064 * data is the error string.
1066 EXTERN
int nfs_fchown_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int uid
, int gid
, nfs_cb cb
, void *private_data
);
1068 * Sync fchown(<handle>)
1070 * 0 : The operation was successfull.
1071 * -errno : The command failed.
1073 EXTERN
int nfs_fchown(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int uid
, int gid
);
1082 * Async utimes(<path>)
1084 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1085 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1087 * When the callback is invoked, status indicates the result:
1090 * -errno : An error occured.
1091 * data is the error string.
1093 EXTERN
int nfs_utimes_async(struct nfs_context
*nfs
, const char *path
, struct timeval
*times
, nfs_cb cb
, void *private_data
);
1095 * Sync utimes(<path>)
1097 * 0 : The operation was successfull.
1098 * -errno : The command failed.
1100 EXTERN
int nfs_utimes(struct nfs_context
*nfs
, const char *path
, struct timeval
*times
);
1107 * Async utime(<path>)
1109 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1110 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1112 * When the callback is invoked, status indicates the result:
1115 * -errno : An error occured.
1116 * data is the error string.
1119 EXTERN
int nfs_utime_async(struct nfs_context
*nfs
, const char *path
, struct utimbuf
*times
, nfs_cb cb
, void *private_data
);
1121 * Sync utime(<path>)
1123 * 0 : The operation was successfull.
1124 * -errno : The command failed.
1126 EXTERN
int nfs_utime(struct nfs_context
*nfs
, const char *path
, struct utimbuf
*times
);
1135 * Async access(<path>)
1137 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1138 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1140 * When the callback is invoked, status indicates the result:
1143 * -errno : An error occured.
1144 * data is the error string.
1146 EXTERN
int nfs_access_async(struct nfs_context
*nfs
, const char *path
, int mode
, nfs_cb cb
, void *private_data
);
1148 * Sync access(<path>)
1150 * 0 : The operation was successfull.
1151 * -errno : The command failed.
1153 EXTERN
int nfs_access(struct nfs_context
*nfs
, const char *path
, int mode
);
1162 * Async symlink(<path>)
1164 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1165 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1167 * When the callback is invoked, status indicates the result:
1170 * -errno : An error occured.
1171 * data is the error string.
1173 EXTERN
int nfs_symlink_async(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
, nfs_cb cb
, void *private_data
);
1175 * Sync symlink(<path>)
1177 * 0 : The operation was successfull.
1178 * -errno : The command failed.
1180 EXTERN
int nfs_symlink(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
);
1187 * Async rename(<oldpath>, <newpath>)
1189 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1190 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1192 * When the callback is invoked, status indicates the result:
1195 * -errno : An error occured.
1196 * data is the error string.
1198 EXTERN
int nfs_rename_async(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
, nfs_cb cb
, void *private_data
);
1200 * Sync rename(<oldpath>, <newpath>)
1202 * 0 : The operation was successfull.
1203 * -errno : The command failed.
1205 EXTERN
int nfs_rename(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
);
1213 * Async link(<oldpath>, <newpath>)
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:
1221 * -errno : An error occured.
1222 * data is the error string.
1224 EXTERN
int nfs_link_async(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
, nfs_cb cb
, void *private_data
);
1226 * Sync link(<oldpath>, <newpath>)
1228 * 0 : The operation was successfull.
1229 * -errno : The command failed.
1231 EXTERN
int nfs_link(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
);
1238 * Async getexports()
1239 * NOTE: You must include 'libnfs-raw-mount.h' to get the definitions of the
1240 * returned structures.
1242 * This function will return the list of exports from an NFS server.
1245 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1246 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1248 * When the callback is invoked, status indicates the result:
1250 * data is a pointer to an exports pointer:
1251 * exports export = *(exports *)data;
1252 * -errno : An error occured.
1253 * data is the error string.
1255 EXTERN
int mount_getexports_async(struct rpc_context
*rpc
, const char *server
, rpc_cb cb
, void *private_data
);
1257 * Sync getexports(<server>)
1259 * NULL : something failed
1260 * exports export : a linked list of exported directories
1262 * returned data must be freed by calling mount_free_export_list(exportnode);
1264 EXTERN
struct exportnode
*mount_getexports(const char *server
);
1266 EXTERN
void mount_free_export_list(struct exportnode
*exports
);
1269 //qqq replace later with lseek(cur, 0)
1270 uint64_t nfs_get_current_offset(struct nfsfh
*nfsfh
);
1276 struct nfs_server_list
{
1277 struct nfs_server_list
*next
;
1282 * Sync find_local_servers(<server>)
1283 * This function will probe all local networks for NFS server. This function will
1284 * block for one second while awaiting for all nfs servers to respond.
1287 * NULL : something failed
1289 * struct nfs_server_list : a linked list of all discovered servers
1291 * returned data must be freed by nfs_free_srvr_list(srv);
1293 struct nfs_server_list
*nfs_find_local_servers(void);
1294 void free_nfs_srvr_list(struct nfs_server_list
*srv
);
1300 #endif /* !_LIBNFS_H_ */