2 Copyright (C) 2010 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>.
18 * This is the highlevel interface to access NFS resources using a posix-like interface
31 #if defined(__APPLE__) && defined(__MACH__)
39 #define LIBNFS_FEATURE_READAHEAD
40 #define NFS_BLKSIZE 4096
52 #define EXTERN __declspec( dllexport )
81 * Used for interfacing the async version of the api into an external eventsystem
83 EXTERN
int nfs_get_fd(struct nfs_context
*nfs
);
84 EXTERN
int nfs_which_events(struct nfs_context
*nfs
);
85 EXTERN
int nfs_service(struct nfs_context
*nfs
, int revents
);
86 EXTERN
int nfs_queue_length(struct nfs_context
*nfs
);
89 * Used if you need different credentials than the default for the current user.
92 EXTERN
void nfs_set_auth(struct nfs_context
*nfs
, struct AUTH
*auth
);
95 * When an operation failed, this function can extract a detailed error string.
97 EXTERN
char *nfs_get_error(struct nfs_context
*nfs
);
101 * Callback for all ASYNC nfs functions
103 typedef void (*nfs_cb
)(int err
, struct nfs_context
*nfs
, void *data
, void *private_data
);
106 * Callback for all ASYNC rpc functions
108 typedef void (*rpc_cb
)(struct rpc_context
*rpc
, int status
, void *data
, void *private_data
);
116 * Create an NFS c, the context.
118 * NULL : Failed to create a context.
119 * *nfs : A pointer to an nfs context.
121 EXTERN
struct nfs_context
*nfs_init_context(void);
123 * Destroy an nfs context.
125 EXTERN
void nfs_destroy_context(struct nfs_context
*nfs
);
129 * URL parsing functions.
130 * These functions all parse a URL of the form
131 * nfs://server/path/file?argv=val[&arg=val]*
132 * and returns a nfs_url.
134 * Apart from parsing the URL the functions will also update
135 * the nfs context to reflect settings controlled via url arguments.
137 * Current URL arguments are :
138 * tcp-syncnt=<int> : Number of SYNs to send during the seccion establish
139 * before failing settin up the tcp connection to the
141 * uid=<int> : UID value to use when talking to the server.
142 * default it 65534 on Windows and getuid() on unixen.
143 * gid=<int> : GID value to use when talking to the server.
144 * default it 65534 on Windows and getgid() on unixen.
147 * Parse a complete NFS URL including, server, path and
148 * filename. Fail if any component is missing.
150 EXTERN
struct nfs_url
*nfs_parse_url_full(struct nfs_context
*nfs
, const char *url
);
153 * Parse an NFS URL, but do not split path and file. File
154 * in the resulting struct remains NULL.
156 EXTERN
struct nfs_url
*nfs_parse_url_dir(struct nfs_context
*nfs
, const char *url
);
159 * Parse an NFS URL, but do not fail if file, path or even server is missing.
160 * Check elements of the resulting struct for NULL.
162 EXTERN
struct nfs_url
*nfs_parse_url_incomplete(struct nfs_context
*nfs
, const char *url
);
166 * Free the URL struct returned by the nfs_parse_url_* functions.
168 EXTERN
void nfs_destroy_url(struct nfs_url
*url
);
174 * Get the maximum supported READ3 size by the server
176 EXTERN
uint64_t nfs_get_readmax(struct nfs_context
*nfs
);
179 * Get the maximum supported WRITE3 size by the server
181 EXTERN
uint64_t nfs_get_writemax(struct nfs_context
*nfs
);
184 * MODIFY CONNECT PARAMTERS
187 EXTERN
void nfs_set_tcp_syncnt(struct nfs_context
*nfs
, int v
);
188 EXTERN
void nfs_set_uid(struct nfs_context
*nfs
, int uid
);
189 EXTERN
void nfs_set_gid(struct nfs_context
*nfs
, int gid
);
190 EXTERN
void nfs_set_readahead(struct nfs_context
*nfs
, uint32_t v
);
198 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
199 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
201 * When the callback is invoked, status indicates the result:
204 * -errno : An error occured.
205 * data is the error string.
207 EXTERN
int nfs_mount_async(struct nfs_context
*nfs
, const char *server
, const char *exportname
, nfs_cb cb
, void *private_data
);
211 * 0 : The operation was successfull.
212 * -errno : The command failed.
214 EXTERN
int nfs_mount(struct nfs_context
*nfs
, const char *server
, const char *exportname
);
223 * Async stat(<filename>)
225 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
226 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
228 * When the callback is invoked, status indicates the result:
230 * data is struct stat *
231 * -errno : An error occured.
232 * data is the error string.
234 /* This function is deprecated. Use nfs_stat64_async() instead */
236 EXTERN
int nfs_stat_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
238 * Sync stat(<filename>)
240 * 0 : The operation was successfull.
241 * -errno : The command failed.
243 /* This function is deprecated. Use nfs_stat64() instead */
245 EXTERN
int nfs_stat(struct nfs_context
*nfs
, const char *path
, struct __stat64
*st
);
247 EXTERN
int nfs_stat(struct nfs_context
*nfs
, const char *path
, struct stat
*st
);
252 * 64 bit version if stat. All fields are always 64bit.
253 * Use these functions instead of nfs_stat[_async](), especially if you
254 * have weird stat structures.
268 uint64_t nfs_blksize
;
276 * Async stat(<filename>)
278 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
279 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
281 * When the callback is invoked, status indicates the result:
283 * data is struct nfs_stat_64 *
284 * -errno : An error occured.
285 * data is the error string.
287 EXTERN
int nfs_stat64_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
289 * Sync stat(<filename>)
291 * 0 : The operation was successfull.
292 * -errno : The command failed.
294 EXTERN
int nfs_stat64(struct nfs_context
*nfs
, const char *path
, struct nfs_stat_64
*st
);
300 * Async fstat(nfsfh *)
302 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
303 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
305 * When the callback is invoked, status indicates the result:
307 * data is struct stat *
308 * -errno : An error occured.
309 * data is the error string.
311 EXTERN
int nfs_fstat_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, nfs_cb cb
, void *private_data
);
313 * Sync fstat(nfsfh *)
315 * 0 : The operation was successfull.
316 * -errno : The command failed.
319 EXTERN
int nfs_fstat(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, struct __stat64
*st
);
321 EXTERN
int nfs_fstat(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, struct stat
*st
);
330 * Async open(<filename>)
332 * mode is a combination of the flags :
333 * O_RDOLNY, O_WRONLY, O_RDWR , O_SYNC, O_APPEND
336 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
337 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
339 * Supported flags are
344 * O_TRUNC (Only valid with O_RDWR or O_WRONLY. Ignored otherwise.)
346 * When the callback is invoked, status indicates the result:
348 * data is a struct *nfsfh;
349 * The nfsfh is close using nfs_close().
350 * -errno : An error occured.
351 * data is the error string.
353 EXTERN
int nfs_open_async(struct nfs_context
*nfs
, const char *path
, int flags
, nfs_cb cb
, void *private_data
);
355 * Sync open(<filename>)
357 * 0 : The operation was successfull. *nfsfh is filled in.
358 * -errno : The command failed.
360 EXTERN
int nfs_open(struct nfs_context
*nfs
, const char *path
, int flags
, struct nfsfh
**nfsfh
);
372 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
373 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
375 * When the callback is invoked, status indicates the result:
378 * -errno : An error occured.
379 * data is the error string.
381 EXTERN
int nfs_close_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, nfs_cb cb
, void *private_data
);
385 * 0 : The operation was successfull.
386 * -errno : The command failed.
388 EXTERN
int nfs_close(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
);
398 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
399 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
401 * When the callback is invoked, status indicates the result:
403 * status is numer of bytes read.
404 * data is a pointer to the returned data.
405 * -errno : An error occured.
406 * data is the error string.
408 EXTERN
int nfs_pread_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t offset
, uint64_t count
, nfs_cb cb
, void *private_data
);
412 * >=0 : numer of bytes read.
413 * -errno : An error occured.
415 EXTERN
int nfs_pread(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t offset
, uint64_t count
, char *buf
);
426 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
427 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
429 * When the callback is invoked, status indicates the result:
431 * status is numer of bytes read.
432 * data is a pointer to the returned data.
433 * -errno : An error occured.
434 * data is the error string.
436 EXTERN
int nfs_read_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t count
, nfs_cb cb
, void *private_data
);
440 * >=0 : numer of bytes read.
441 * -errno : An error occured.
443 EXTERN
int nfs_read(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t count
, char *buf
);
455 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
456 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
458 * When the callback is invoked, status indicates the result:
460 * status is numer of bytes written.
461 * -errno : An error occured.
462 * data is the error string.
464 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
);
468 * >=0 : numer of bytes written.
469 * -errno : An error occured.
471 EXTERN
int nfs_pwrite(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t offset
, uint64_t count
, char *buf
);
481 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
482 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
484 * When the callback is invoked, status indicates the result:
486 * status is numer of bytes written.
487 * -errno : An error occured.
488 * data is the error string.
490 EXTERN
int nfs_write_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t count
, char *buf
, nfs_cb cb
, void *private_data
);
494 * >=0 : numer of bytes written.
495 * -errno : An error occured.
497 EXTERN
int nfs_write(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t count
, char *buf
);
507 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
508 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
510 * When the callback is invoked, status indicates the result:
512 * data is uint64_t * for the current position.
513 * -errno : An error occured.
514 * data is the error string.
516 EXTERN
int nfs_lseek_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int64_t offset
, int whence
, nfs_cb cb
, void *private_data
);
520 * >=0 : numer of bytes read.
521 * -errno : An error occured.
523 EXTERN
int nfs_lseek(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int64_t offset
, int whence
, uint64_t *current_offset
);
533 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
534 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
536 * When the callback is invoked, status indicates the result:
538 * -errno : An error occured.
539 * data is the error string.
541 EXTERN
int nfs_fsync_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, nfs_cb cb
, void *private_data
);
546 * -errno : An error occured.
548 EXTERN
int nfs_fsync(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
);
559 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
560 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
562 * When the callback is invoked, status indicates the result:
564 * -errno : An error occured.
565 * data is the error string.
567 EXTERN
int nfs_truncate_async(struct nfs_context
*nfs
, const char *path
, uint64_t length
, nfs_cb cb
, void *private_data
);
572 * -errno : An error occured.
574 EXTERN
int nfs_truncate(struct nfs_context
*nfs
, const char *path
, uint64_t length
);
585 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
586 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
588 * When the callback is invoked, status indicates the result:
590 * -errno : An error occured.
591 * data is the error string.
593 EXTERN
int nfs_ftruncate_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t length
, nfs_cb cb
, void *private_data
);
598 * -errno : An error occured.
600 EXTERN
int nfs_ftruncate(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, uint64_t length
);
614 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
615 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
617 * When the callback is invoked, status indicates the result:
619 * -errno : An error occured.
620 * data is the error string.
622 EXTERN
int nfs_mkdir_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
627 * -errno : An error occured.
629 EXTERN
int nfs_mkdir(struct nfs_context
*nfs
, const char *path
);
640 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
641 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
643 * When the callback is invoked, status indicates the result:
645 * -errno : An error occured.
646 * data is the error string.
648 EXTERN
int nfs_rmdir_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
653 * -errno : An error occured.
655 EXTERN
int nfs_rmdir(struct nfs_context
*nfs
, const char *path
);
667 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
668 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
670 * When the callback is invoked, status indicates the result:
672 * data is a struct *nfsfh;
673 * -errno : An error occured.
674 * data is the error string.
676 EXTERN
int nfs_creat_async(struct nfs_context
*nfs
, const char *path
, int mode
, nfs_cb cb
, void *private_data
);
681 * -errno : An error occured.
683 EXTERN
int nfs_creat(struct nfs_context
*nfs
, const char *path
, int mode
, struct nfsfh
**nfsfh
);
693 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
694 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
696 * When the callback is invoked, status indicates the result:
698 * -errno : An error occured.
699 * data is the error string.
701 EXTERN
int nfs_mknod_async(struct nfs_context
*nfs
, const char *path
, int mode
, int dev
, nfs_cb cb
, void *private_data
);
706 * -errno : An error occured.
708 EXTERN
int nfs_mknod(struct nfs_context
*nfs
, const char *path
, int mode
, int dev
);
719 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
720 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
722 * When the callback is invoked, status indicates the result:
725 * -errno : An error occured.
726 * data is the error string.
728 EXTERN
int nfs_unlink_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
733 * -errno : An error occured.
735 EXTERN
int nfs_unlink(struct nfs_context
*nfs
, const char *path
);
748 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
749 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
751 * When struct nfsdir * is returned, this resource is closed/freed by calling nfs_closedir()
753 * When the callback is invoked, status indicates the result:
755 * data is struct nfsdir *
756 * -errno : An error occured.
757 * data is the error string.
759 EXTERN
int nfs_opendir_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
764 * -errno : An error occured.
766 EXTERN
int nfs_opendir(struct nfs_context
*nfs
, const char *path
, struct nfsdir
**nfsdir
);
774 struct nfsdirent
*next
;
778 /* Some extra fields we get for free through the READDIRPLUS3 call.
779 You need libnfs-raw-nfs.h for type/mode constants */
780 uint32_t type
; /* NF3REG, NF3DIR, NF3BLK, ... */
783 struct timeval atime
;
784 struct timeval mtime
;
785 struct timeval ctime
;
791 * nfs_readdir() never blocks, so no special sync/async versions are available
793 EXTERN
struct nfsdirent
*nfs_readdir(struct nfs_context
*nfs
, struct nfsdir
*nfsdir
);
801 * nfs_closedir() never blocks, so no special sync/async versions are available
803 EXTERN
void nfs_closedir(struct nfs_context
*nfs
, struct nfsdir
*nfsdir
);
810 * Async chdir(<path>)
813 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
814 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
816 * When the callback is invoked, status indicates the result:
819 * -errno : An error occured.
820 * data is the error string.
822 EXTERN
int nfs_chdir_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
826 * 0 : The operation was successfull.
827 * -errno : The command failed.
829 EXTERN
int nfs_chdir(struct nfs_context
*nfs
, const char *path
);
835 * nfs_getcwd() never blocks, so no special sync/async versions are available
839 * This function returns a pointer to the current working directory.
840 * This pointer is only stable until the next [f]chdir or when the
841 * context is destroyed.
844 * 0 : The operation was successfull and *cwd is filled in.
845 * -errno : The command failed.
847 EXTERN
void nfs_getcwd(struct nfs_context
*nfs
, const char **cwd
);
854 * Async statvfs(<dirname>)
856 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
857 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
859 * When the callback is invoked, status indicates the result:
861 * data is struct statvfs *
862 * -errno : An error occured.
863 * data is the error string.
866 EXTERN
int nfs_statvfs_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
868 * Sync statvfs(<dirname>)
870 * 0 : The operation was successfull.
871 * -errno : The command failed.
873 EXTERN
int nfs_statvfs(struct nfs_context
*nfs
, const char *path
, struct statvfs
*svfs
);
880 * Async readlink(<name>)
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 * data is only valid during the callback and is automatically freed when the callback returns.
889 * -errno : An error occured.
890 * data is the error string.
893 EXTERN
int nfs_readlink_async(struct nfs_context
*nfs
, const char *path
, nfs_cb cb
, void *private_data
);
895 * Sync readlink(<name>)
897 * 0 : The operation was successfull.
898 * -errno : The command failed.
900 EXTERN
int nfs_readlink(struct nfs_context
*nfs
, const char *path
, char *buf
, int bufsize
);
908 * Async chmod(<name>)
910 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
911 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
913 * When the callback is invoked, status indicates the result:
916 * -errno : An error occured.
917 * data is the error string.
919 EXTERN
int nfs_chmod_async(struct nfs_context
*nfs
, const char *path
, int mode
, nfs_cb cb
, void *private_data
);
923 * 0 : The operation was successfull.
924 * -errno : The command failed.
926 EXTERN
int nfs_chmod(struct nfs_context
*nfs
, const char *path
, int mode
);
934 * Async fchmod(<handle>)
936 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
937 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
939 * When the callback is invoked, status indicates the result:
942 * -errno : An error occured.
943 * data is the error string.
945 EXTERN
int nfs_fchmod_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int mode
, nfs_cb cb
, void *private_data
);
947 * Sync fchmod(<handle>)
949 * 0 : The operation was successfull.
950 * -errno : The command failed.
952 EXTERN
int nfs_fchmod(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int mode
);
960 * Async chown(<name>)
962 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
963 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
965 * When the callback is invoked, status indicates the result:
968 * -errno : An error occured.
969 * data is the error string.
971 EXTERN
int nfs_chown_async(struct nfs_context
*nfs
, const char *path
, int uid
, int gid
, nfs_cb cb
, void *private_data
);
975 * 0 : The operation was successfull.
976 * -errno : The command failed.
978 EXTERN
int nfs_chown(struct nfs_context
*nfs
, const char *path
, int uid
, int gid
);
986 * Async fchown(<handle>)
988 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
989 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
991 * When the callback is invoked, status indicates the result:
994 * -errno : An error occured.
995 * data is the error string.
997 EXTERN
int nfs_fchown_async(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int uid
, int gid
, nfs_cb cb
, void *private_data
);
999 * Sync fchown(<handle>)
1001 * 0 : The operation was successfull.
1002 * -errno : The command failed.
1004 EXTERN
int nfs_fchown(struct nfs_context
*nfs
, struct nfsfh
*nfsfh
, int uid
, int gid
);
1013 * Async utimes(<path>)
1015 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1016 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1018 * When the callback is invoked, status indicates the result:
1021 * -errno : An error occured.
1022 * data is the error string.
1024 EXTERN
int nfs_utimes_async(struct nfs_context
*nfs
, const char *path
, struct timeval
*times
, nfs_cb cb
, void *private_data
);
1026 * Sync utimes(<path>)
1028 * 0 : The operation was successfull.
1029 * -errno : The command failed.
1031 EXTERN
int nfs_utimes(struct nfs_context
*nfs
, const char *path
, struct timeval
*times
);
1038 * Async utime(<path>)
1040 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1041 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1043 * When the callback is invoked, status indicates the result:
1046 * -errno : An error occured.
1047 * data is the error string.
1050 EXTERN
int nfs_utime_async(struct nfs_context
*nfs
, const char *path
, struct utimbuf
*times
, nfs_cb cb
, void *private_data
);
1052 * Sync utime(<path>)
1054 * 0 : The operation was successfull.
1055 * -errno : The command failed.
1057 EXTERN
int nfs_utime(struct nfs_context
*nfs
, const char *path
, struct utimbuf
*times
);
1066 * Async access(<path>)
1068 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1069 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1071 * When the callback is invoked, status indicates the result:
1074 * -errno : An error occured.
1075 * data is the error string.
1077 EXTERN
int nfs_access_async(struct nfs_context
*nfs
, const char *path
, int mode
, nfs_cb cb
, void *private_data
);
1079 * Sync access(<path>)
1081 * 0 : The operation was successfull.
1082 * -errno : The command failed.
1084 EXTERN
int nfs_access(struct nfs_context
*nfs
, const char *path
, int mode
);
1093 * Async symlink(<path>)
1095 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1096 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1098 * When the callback is invoked, status indicates the result:
1101 * -errno : An error occured.
1102 * data is the error string.
1104 EXTERN
int nfs_symlink_async(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
, nfs_cb cb
, void *private_data
);
1106 * Sync symlink(<path>)
1108 * 0 : The operation was successfull.
1109 * -errno : The command failed.
1111 EXTERN
int nfs_symlink(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
);
1118 * Async rename(<oldpath>, <newpath>)
1120 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1121 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1123 * When the callback is invoked, status indicates the result:
1126 * -errno : An error occured.
1127 * data is the error string.
1129 EXTERN
int nfs_rename_async(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
, nfs_cb cb
, void *private_data
);
1131 * Sync rename(<oldpath>, <newpath>)
1133 * 0 : The operation was successfull.
1134 * -errno : The command failed.
1136 EXTERN
int nfs_rename(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
);
1144 * Async link(<oldpath>, <newpath>)
1146 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1147 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1149 * When the callback is invoked, status indicates the result:
1152 * -errno : An error occured.
1153 * data is the error string.
1155 EXTERN
int nfs_link_async(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
, nfs_cb cb
, void *private_data
);
1157 * Sync link(<oldpath>, <newpath>)
1159 * 0 : The operation was successfull.
1160 * -errno : The command failed.
1162 EXTERN
int nfs_link(struct nfs_context
*nfs
, const char *oldpath
, const char *newpath
);
1169 * Async getexports()
1170 * NOTE: You must include 'libnfs-raw-mount.h' to get the definitions of the
1171 * returned structures.
1173 * This function will return the list of exports from an NFS server.
1176 * 0 : The operation was initiated. Once the operation finishes, the callback will be invoked.
1177 * <0 : An error occured when trying to set up the operation. The callback will not be invoked.
1179 * When the callback is invoked, status indicates the result:
1181 * data is a pointer to an exports pointer:
1182 * exports export = *(exports *)data;
1183 * -errno : An error occured.
1184 * data is the error string.
1186 EXTERN
int mount_getexports_async(struct rpc_context
*rpc
, const char *server
, rpc_cb cb
, void *private_data
);
1188 * Sync getexports(<server>)
1190 * NULL : something failed
1191 * exports export : a linked list of exported directories
1193 * returned data must be freed by calling mount_free_export_list(exportnode);
1195 EXTERN
struct exportnode
*mount_getexports(const char *server
);
1197 EXTERN
void mount_free_export_list(struct exportnode
*exports
);
1200 //qqq replace later with lseek(cur, 0)
1201 uint64_t nfs_get_current_offset(struct nfsfh
*nfsfh
);
1207 struct nfs_server_list
{
1208 struct nfs_server_list
*next
;
1213 * Sync find_local_servers(<server>)
1214 * This function will probe all local networks for NFS server. This function will
1215 * block for one second while awaiting for all nfs servers to respond.
1218 * NULL : something failed
1220 * struct nfs_server_list : a linked list of all discovered servers
1222 * returned data must be freed by nfs_free_srvr_list(srv);
1224 struct nfs_server_list
*nfs_find_local_servers(void);
1225 void free_nfs_srvr_list(struct nfs_server_list
*srv
);
1231 #endif /* !_LIBNFS_H_ */