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
);
301 * Async stat(<filename>)
303 * Like stat except if the destination is a symbolic link, it acts on the
304 * symbolic link itself.
307 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
308 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
310 * When the callback is invoked, status indicates the result:
312 * data is struct nfs_stat_64 *
313 * -errno : An error occured.
314 * data is the error string.
316 EXTERN
int nfs_lstat64_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
318 * Sync stat(<filename>)
320 * Like stat except if the destination is a symbolic link, it acts on the
321 * symbolic link itself.
324 * 0 : The operation was successfull.
325 * -errno : The command failed.
327 EXTERN
int nfs_lstat64(struct nfs_context
*nfs
, const char *path
, struct nfs_stat_64
*st
);
333 * Async fstat(nfsfh *)
335 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
336 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
338 * When the callback is invoked, status indicates the result:
340 * data is struct stat *
341 * -errno : An error occured.
342 * data is the error string.
344 /* This function is deprecated. Use nfs_fstat64_async() instead */
345 EXTERN
int nfs_fstat_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, nfs_cb cb
, void *private_data
);
347 * Sync fstat(nfsfh *)
349 * 0 : The operation was successfull.
350 * -errno : The command failed.
353 EXTERN
int nfs_fstat(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, struct __stat64
*st
);
355 EXTERN
int nfs_fstat(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, struct stat
*st
);
359 * 64 bit version of fstat. All fields are always 64bit.
360 * Use these functions instead of nfs_fstat[_async](), especially if you
361 * have weird stat structures.
367 * Async fstat(nfsfh *)
369 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
370 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
372 * When the callback is invoked, status indicates the result:
374 * data is struct stat *
375 * -errno : An error occured.
376 * data is the error string.
378 EXTERN
int nfs_fstat64_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, nfs_cb cb
, void *private_data
);
380 * Sync fstat(nfsfh *)
382 * 0 : The operation was successfull.
383 * -errno : The command failed.
385 EXTERN
int nfs_fstat64(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, struct nfs_stat_64
*st
);
393 * Async open(<filename>)
395 * mode is a combination of the flags :
396 * O_RDOLNY, O_WRONLY, O_RDWR , O_SYNC, O_APPEND, O_TRUNC
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 * Supported flags are
408 * O_TRUNC (Only valid with O_RDWR or O_WRONLY. Ignored otherwise.)
410 * When the callback is invoked, status indicates the result:
412 * data is a struct *nfsfh;
413 * The nfsfh is close using nfs_close().
414 * -errno : An error occured.
415 * data is the error string.
417 EXTERN
int nfs_open_async(struct nfs_context
*nfs
, const char *path
, int flags
, nfs_cb cb
, void *private_data
);
419 * Sync open(<filename>)
421 * 0 : The operation was successfull. *nfsfh is filled in.
422 * -errno : The command failed.
424 EXTERN
int nfs_open(struct nfs_context
*nfs
, const char *path
, int flags
, struct nfsfh
**nfsfh
);
436 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
437 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
439 * When the callback is invoked, status indicates the result:
442 * -errno : An error occured.
443 * data is the error string.
445 EXTERN
int nfs_close_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, nfs_cb cb
, void *private_data
);
449 * 0 : The operation was successfull.
450 * -errno : The command failed.
452 EXTERN
int nfs_close(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
);
462 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
463 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
465 * When the callback is invoked, status indicates the result:
467 * status is numer of bytes read.
468 * data is a pointer to the returned data.
469 * -errno : An error occured.
470 * data is the error string.
472 EXTERN
int nfs_pread_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t offset
, uint64_t count
, nfs_cb cb
, void *private_data
);
476 * >=0 : numer of bytes read.
477 * -errno : An error occured.
479 EXTERN
int nfs_pread(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t offset
, 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 read.
496 * data is a pointer to the returned data.
497 * -errno : An error occured.
498 * data is the error string.
500 EXTERN
int nfs_read_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t count
, nfs_cb cb
, void *private_data
);
504 * >=0 : numer of bytes read.
505 * -errno : An error occured.
507 EXTERN
int nfs_read(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t count
, char *buf
);
519 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
520 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
522 * When the callback is invoked, status indicates the result:
524 * status is numer of bytes written.
525 * -errno : An error occured.
526 * data is the error string.
528 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
);
532 * >=0 : numer of bytes written.
533 * -errno : An error occured.
535 EXTERN
int nfs_pwrite(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t offset
, uint64_t count
, char *buf
);
545 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
546 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
548 * When the callback is invoked, status indicates the result:
550 * status is numer of bytes written.
551 * -errno : An error occured.
552 * data is the error string.
554 EXTERN
int nfs_write_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t count
, char *buf
, nfs_cb cb
, void *private_data
);
558 * >=0 : numer of bytes written.
559 * -errno : An error occured.
561 EXTERN
int nfs_write(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t count
, char *buf
);
571 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
572 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
574 * When the callback is invoked, status indicates the result:
576 * data is uint64_t * for the current position.
577 * -errno : An error occured.
578 * data is the error string.
580 EXTERN
int nfs_lseek_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int64_t offset
, int whence
, nfs_cb cb
, void *private_data
);
584 * >=0 : numer of bytes read.
585 * -errno : An error occured.
587 EXTERN
int nfs_lseek(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int64_t offset
, int whence
, uint64_t *current_offset
);
597 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
598 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
600 * When the callback is invoked, status indicates the result:
602 * -errno : An error occured.
603 * data is the error string.
605 EXTERN
int nfs_fsync_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, nfs_cb cb
, void *private_data
);
610 * -errno : An error occured.
612 EXTERN
int nfs_fsync(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
);
623 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
624 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
626 * When the callback is invoked, status indicates the result:
628 * -errno : An error occured.
629 * data is the error string.
631 EXTERN
int nfs_truncate_async(struct nfs_context
*nfs
, const char *path
, uint64_t length
, nfs_cb cb
, void *private_data
);
636 * -errno : An error occured.
638 EXTERN
int nfs_truncate(struct nfs_context
*nfs
, const char *path
, 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_ftruncate_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t length
, nfs_cb cb
, void *private_data
);
662 * -errno : An error occured.
664 EXTERN
int nfs_ftruncate(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t length
);
678 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
679 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
681 * When the callback is invoked, status indicates the result:
683 * -errno : An error occured.
684 * data is the error string.
686 EXTERN
int nfs_mkdir_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
691 * -errno : An error occured.
693 EXTERN
int nfs_mkdir(struct nfs_context
*nfs
, const char *path
);
704 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
705 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
707 * When the callback is invoked, status indicates the result:
709 * -errno : An error occured.
710 * data is the error string.
712 EXTERN
int nfs_rmdir_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
717 * -errno : An error occured.
719 EXTERN
int nfs_rmdir(struct nfs_context
*nfs
, const char *path
);
731 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
732 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
734 * When the callback is invoked, status indicates the result:
736 * data is a struct *nfsfh;
737 * -errno : An error occured.
738 * data is the error string.
740 EXTERN
int nfs_creat_async(struct nfs_context
*nfs
, const char *path
, int mode
, nfs_cb cb
, void *private_data
);
745 * -errno : An error occured.
747 EXTERN
int nfs_creat(struct nfs_context
*nfs
, const char *path
, int mode
, struct nfsfh
**nfsfh
);
752 * Same as nfs_creat_async but allows passing flags:
759 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
760 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
762 * When the callback is invoked, status indicates the result:
764 * data is a struct *nfsfh;
765 * -errno : An error occured.
766 * data is the error string.
768 EXTERN
int nfs_create_async(struct nfs_context
*nfs
, const char *path
, int flags
, int mode
, nfs_cb cb
, void *private_data
);
773 * -errno : An error occured.
775 EXTERN
int nfs_create(struct nfs_context
*nfs
, const char *path
, int flags
, int mode
, struct nfsfh
**nfsfh
);
785 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
786 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
788 * When the callback is invoked, status indicates the result:
790 * -errno : An error occured.
791 * data is the error string.
793 EXTERN
int nfs_mknod_async(struct nfs_context
*nfs
, const char *path
, int mode
, int dev
, nfs_cb cb
, void *private_data
);
798 * -errno : An error occured.
800 EXTERN
int nfs_mknod(struct nfs_context
*nfs
, const char *path
, int mode
, int dev
);
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 the callback is invoked, status indicates the result:
817 * -errno : An error occured.
818 * data is the error string.
820 EXTERN
int nfs_unlink_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
825 * -errno : An error occured.
827 EXTERN
int nfs_unlink(struct nfs_context
*nfs
, const char *path
);
840 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
841 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
843 * When struct nfsdir * is returned, this resource is closed/freed by calling nfs_closedir()
845 * When the callback is invoked, status indicates the result:
847 * data is struct nfsdir *
848 * -errno : An error occured.
849 * data is the error string.
851 EXTERN
int nfs_opendir_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
856 * -errno : An error occured.
858 EXTERN
int nfs_opendir(struct nfs_context
*nfs
, const char *path
, struct nfsdir
**nfsdir
);
866 struct nfsdirent
*next
;
870 /* Some extra fields we get for free through the READDIRPLUS3 call.
871 You need libnfs-raw-nfs.h for type/mode constants */
872 uint32_t type
; /* NF3REG, NF3DIR, NF3BLK, ... */
875 struct timeval atime
;
876 struct timeval mtime
;
877 struct timeval ctime
;
891 * nfs_readdir() never blocks, so no special sync/async versions are available
893 EXTERN
struct nfsdirent
*nfs_readdir(struct nfs_context
*nfs
, struct nfsdir
*nfsdir
);
901 * nfs_closedir() never blocks, so no special sync/async versions are available
903 EXTERN
void nfs_closedir(struct nfs_context
*nfs
, struct nfsdir
*nfsdir
);
910 * Async chdir(<path>)
913 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
914 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
916 * When the callback is invoked, status indicates the result:
919 * -errno : An error occured.
920 * data is the error string.
922 EXTERN
int nfs_chdir_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
926 * 0 : The operation was successfull.
927 * -errno : The command failed.
929 EXTERN
int nfs_chdir(struct nfs_context
*nfs
, const char *path
);
935 * nfs_getcwd() never blocks, so no special sync/async versions are available
939 * This function returns a pointer to the current working directory.
940 * This pointer is only stable until the next [f]chdir or when the
941 * context is destroyed.
944 * 0 : The operation was successfull and *cwd is filled in.
945 * -errno : The command failed.
947 EXTERN
void nfs_getcwd(struct nfs_context
*nfs
, const char **cwd
);
954 * Async statvfs(<dirname>)
956 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
957 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
959 * When the callback is invoked, status indicates the result:
961 * data is struct statvfs *
962 * -errno : An error occured.
963 * data is the error string.
966 EXTERN
int nfs_statvfs_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
968 * Sync statvfs(<dirname>)
970 * 0 : The operation was successfull.
971 * -errno : The command failed.
973 EXTERN
int nfs_statvfs(struct nfs_context
*nfs
, const char *path
, struct statvfs
*svfs
);
980 * Async readlink(<name>)
982 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
983 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
985 * When the callback is invoked, status indicates the result:
988 * data is only valid during the callback and is automatically freed when the callback returns.
989 * -errno : An error occured.
990 * data is the error string.
993 EXTERN
int nfs_readlink_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
995 * Sync readlink(<name>)
997 * 0 : The operation was successfull.
998 * -errno : The command failed.
1000 EXTERN
int nfs_readlink(struct nfs_context
*nfs
, const char *path
, char *buf
, int bufsize
);
1008 * Async chmod(<name>)
1010 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1011 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1013 * When the callback is invoked, status indicates the result:
1016 * -errno : An error occured.
1017 * data is the error string.
1019 EXTERN
int nfs_chmod_async(struct nfs_context
*nfs
, const char *path
, int mode
, nfs_cb cb
, void *private_data
);
1021 * Sync chmod(<name>)
1023 * 0 : The operation was successfull.
1024 * -errno : The command failed.
1026 EXTERN
int nfs_chmod(struct nfs_context
*nfs
, const char *path
, int mode
);
1028 * Async chmod(<name>)
1030 * Like chmod except if the destination is a symbolic link, it acts on the
1031 * symbolic link itself.
1034 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1035 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1037 * When the callback is invoked, status indicates the result:
1040 * -errno : An error occured.
1041 * data is the error string.
1043 EXTERN
int nfs_lchmod_async(struct nfs_context
*nfs
, const char *path
, int mode
, nfs_cb cb
, void *private_data
);
1045 * Sync chmod(<name>)
1047 * Like chmod except if the destination is a symbolic link, it acts on the
1048 * symbolic link itself.
1051 * 0 : The operation was successfull.
1052 * -errno : The command failed.
1054 EXTERN
int nfs_lchmod(struct nfs_context
*nfs
, const char *path
, int mode
);
1062 * Async fchmod(<handle>)
1064 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1065 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1067 * When the callback is invoked, status indicates the result:
1070 * -errno : An error occured.
1071 * data is the error string.
1073 EXTERN
int nfs_fchmod_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int mode
, nfs_cb cb
, void *private_data
);
1075 * Sync fchmod(<handle>)
1077 * 0 : The operation was successfull.
1078 * -errno : The command failed.
1080 EXTERN
int nfs_fchmod(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int mode
);
1088 * Async chown(<name>)
1090 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1091 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1093 * When the callback is invoked, status indicates the result:
1096 * -errno : An error occured.
1097 * data is the error string.
1099 EXTERN
int nfs_chown_async(struct nfs_context
*nfs
, const char *path
, int uid
, int gid
, nfs_cb cb
, void *private_data
);
1101 * Sync chown(<name>)
1103 * 0 : The operation was successfull.
1104 * -errno : The command failed.
1106 EXTERN
int nfs_chown(struct nfs_context
*nfs
, const char *path
, int uid
, int gid
);
1108 * Async chown(<name>)
1110 * Like chown except if the destination is a symbolic link, it acts on the
1111 * symbolic link itself.
1114 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1115 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1117 * When the callback is invoked, status indicates the result:
1120 * -errno : An error occured.
1121 * data is the error string.
1123 EXTERN
int nfs_lchown_async(struct nfs_context
*nfs
, const char *path
, int uid
, int gid
, nfs_cb cb
, void *private_data
);
1125 * Sync chown(<name>)
1127 * Like chown except if the destination is a symbolic link, it acts on the
1128 * symbolic link itself.
1131 * 0 : The operation was successfull.
1132 * -errno : The command failed.
1134 EXTERN
int nfs_lchown(struct nfs_context
*nfs
, const char *path
, int uid
, int gid
);
1142 * Async fchown(<handle>)
1144 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1145 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1147 * When the callback is invoked, status indicates the result:
1150 * -errno : An error occured.
1151 * data is the error string.
1153 EXTERN
int nfs_fchown_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int uid
, int gid
, nfs_cb cb
, void *private_data
);
1155 * Sync fchown(<handle>)
1157 * 0 : The operation was successfull.
1158 * -errno : The command failed.
1160 EXTERN
int nfs_fchown(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int uid
, int gid
);
1169 * Async utimes(<path>)
1171 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1172 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1174 * When the callback is invoked, status indicates the result:
1177 * -errno : An error occured.
1178 * data is the error string.
1180 EXTERN
int nfs_utimes_async(struct nfs_context
*nfs
, const char *path
, struct timeval
*times
, nfs_cb cb
, void *private_data
);
1182 * Sync utimes(<path>)
1184 * 0 : The operation was successfull.
1185 * -errno : The command failed.
1187 EXTERN
int nfs_utimes(struct nfs_context
*nfs
, const char *path
, struct timeval
*times
);
1189 * Async utimes(<path>)
1191 * Like utimes except if the destination is a symbolic link, it acts on the
1192 * symbolic link itself.
1195 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1196 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1198 * When the callback is invoked, status indicates the result:
1201 * -errno : An error occured.
1202 * data is the error string.
1204 EXTERN
int nfs_lutimes_async(struct nfs_context
*nfs
, const char *path
, struct timeval
*times
, nfs_cb cb
, void *private_data
);
1206 * Sync utimes(<path>)
1208 * Like utimes except if the destination is a symbolic link, it acts on the
1209 * symbolic link itself.
1212 * 0 : The operation was successfull.
1213 * -errno : The command failed.
1215 EXTERN
int nfs_lutimes(struct nfs_context
*nfs
, const char *path
, struct timeval
*times
);
1222 * Async utime(<path>)
1224 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1225 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1227 * When the callback is invoked, status indicates the result:
1230 * -errno : An error occured.
1231 * data is the error string.
1234 EXTERN
int nfs_utime_async(struct nfs_context
*nfs
, const char *path
, struct utimbuf
*times
, nfs_cb cb
, void *private_data
);
1236 * Sync utime(<path>)
1238 * 0 : The operation was successfull.
1239 * -errno : The command failed.
1241 EXTERN
int nfs_utime(struct nfs_context
*nfs
, const char *path
, struct utimbuf
*times
);
1250 * Async access(<path>)
1252 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1253 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1255 * When the callback is invoked, status indicates the result:
1258 * -errno : An error occured.
1259 * data is the error string.
1261 EXTERN
int nfs_access_async(struct nfs_context
*nfs
, const char *path
, int mode
, nfs_cb cb
, void *private_data
);
1263 * Sync access(<path>)
1265 * 0 : The operation was successfull.
1266 * -errno : The command failed.
1268 EXTERN
int nfs_access(struct nfs_context
*nfs
, const char *path
, int mode
);
1277 * Async symlink(<path>)
1279 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1280 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1282 * When the callback is invoked, status indicates the result:
1285 * -errno : An error occured.
1286 * data is the error string.
1288 EXTERN
int nfs_symlink_async(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
, nfs_cb cb
, void *private_data
);
1290 * Sync symlink(<path>)
1292 * 0 : The operation was successfull.
1293 * -errno : The command failed.
1295 EXTERN
int nfs_symlink(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
);
1302 * Async rename(<oldpath>, <newpath>)
1304 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1305 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1307 * When the callback is invoked, status indicates the result:
1310 * -errno : An error occured.
1311 * data is the error string.
1313 EXTERN
int nfs_rename_async(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
, nfs_cb cb
, void *private_data
);
1315 * Sync rename(<oldpath>, <newpath>)
1317 * 0 : The operation was successfull.
1318 * -errno : The command failed.
1320 EXTERN
int nfs_rename(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
);
1328 * Async link(<oldpath>, <newpath>)
1330 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1331 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1333 * When the callback is invoked, status indicates the result:
1336 * -errno : An error occured.
1337 * data is the error string.
1339 EXTERN
int nfs_link_async(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
, nfs_cb cb
, void *private_data
);
1341 * Sync link(<oldpath>, <newpath>)
1343 * 0 : The operation was successfull.
1344 * -errno : The command failed.
1346 EXTERN
int nfs_link(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
);
1353 * Async getexports()
1354 * NOTE: You must include 'libnfs-raw-mount.h' to get the definitions of the
1355 * returned structures.
1357 * This function will return the list of exports from an NFS server.
1360 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1361 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1363 * When the callback is invoked, status indicates the result:
1365 * data is a pointer to an exports pointer:
1366 * exports export = *(exports *)data;
1367 * -errno : An error occured.
1368 * data is the error string.
1370 EXTERN
int mount_getexports_async(struct rpc_context
*rpc
, const char *server
, rpc_cb cb
, void *private_data
);
1372 * Sync getexports(<server>)
1374 * NULL : something failed
1375 * exports export : a linked list of exported directories
1377 * returned data must be freed by calling mount_free_export_list(exportnode);
1379 EXTERN
struct exportnode
*mount_getexports(const char *server
);
1381 EXTERN
void mount_free_export_list(struct exportnode
*exports
);
1384 //qqq replace later with lseek(cur, 0)
1385 uint64_t nfs_get_current_offset(struct nfsfh
*nfsfh
);
1391 struct nfs_server_list
{
1392 struct nfs_server_list
*next
;
1397 * Sync find_local_servers(<server>)
1398 * This function will probe all local networks for NFS server. This function will
1399 * block for one second while awaiting for all nfs servers to respond.
1402 * NULL : something failed
1404 * struct nfs_server_list : a linked list of all discovered servers
1406 * returned data must be freed by nfs_free_srvr_list(srv);
1408 struct nfs_server_list
*nfs_find_local_servers(void);
1409 void free_nfs_srvr_list(struct nfs_server_list
*srv
);
1415 #endif /* !_LIBNFS_H_ */