From 463d59bf8e5ff1a3ac27ab4fedf77b237394d1a6 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Tue, 24 Dec 2013 11:16:21 -0800 Subject: [PATCH] NFS: Add new function signatures for rpc_nfs3_ that takes *3args arguments to match the XDR. Leave the existing ad-hoc rpc_nfs_* functions for backward compatibility. --- include/nfsc/libnfs-raw.h | 141 ++++++----- lib/libnfs-win32.def | 22 ++ lib/libnfs.c | 115 ++++++++- nfs/nfs.c | 497 +++++++++++++++++++++++--------------- 4 files changed, 506 insertions(+), 269 deletions(-) diff --git a/include/nfsc/libnfs-raw.h b/include/nfsc/libnfs-raw.h index dad1c15..d13aeaa 100644 --- a/include/nfsc/libnfs-raw.h +++ b/include/nfsc/libnfs-raw.h @@ -135,7 +135,7 @@ EXTERN int rpc_pmap_null_async(struct rpc_context *rpc, rpc_cb cb, void *private * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete. * data is NULL. */ -int rpc_pmap_getport_async(struct rpc_context *rpc, int program, int version, int protocol, rpc_cb cb, void *private_data); +EXTERN int rpc_pmap_getport_async(struct rpc_context *rpc, int program, int version, int protocol, rpc_cb cb, void *private_data); /* * Call PORTMAPPER/SET @@ -151,7 +151,7 @@ int rpc_pmap_getport_async(struct rpc_context *rpc, int program, int version, in * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete. * data is NULL. */ -int rpc_pmap_set_async(struct rpc_context *rpc, int program, int version, int protocol, int port, rpc_cb cb, void *private_data); +EXTERN int rpc_pmap_set_async(struct rpc_context *rpc, int program, int version, int protocol, int port, rpc_cb cb, void *private_data); /* * Call PORTMAPPER/UNSET @@ -167,7 +167,7 @@ int rpc_pmap_set_async(struct rpc_context *rpc, int program, int version, int pr * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete. * data is NULL. */ -int rpc_pmap_unset_async(struct rpc_context *rpc, int program, int version, int protocol, int port, rpc_cb cb, void *private_data); +EXTERN int rpc_pmap_unset_async(struct rpc_context *rpc, int program, int version, int protocol, int port, rpc_cb cb, void *private_data); /* * Call PORTMAPPER/CALLIT. @@ -183,7 +183,7 @@ int rpc_pmap_unset_async(struct rpc_context *rpc, int program, int version, int * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete. * data is NULL. */ -int rpc_pmap_callit_async(struct rpc_context *rpc, int program, int version, int procedure, char *data, int datalen, rpc_cb cb, void *private_data); +EXTERN int rpc_pmap_callit_async(struct rpc_context *rpc, int program, int version, int procedure, char *data, int datalen, rpc_cb cb, void *private_data); /* * MOUNT FUNCTIONS @@ -295,14 +295,14 @@ EXTERN int rpc_mount_export_async(struct rpc_context *rpc, rpc_cb cb, void *priv /* - * NFS FUNCTIONS + * NFS v3 FUNCTIONS */ struct nfs_fh3; char *nfsstat3_to_str(int error); int nfsstat3_to_errno(int error); /* - * Call NFS/NULL + * Call NFS3/NULL * Function returns * 0 : The call was initiated. The callback will be invoked when the call completes. * <0 : An error occured when trying to set up the call. The callback will not be invoked. @@ -315,10 +315,11 @@ int nfsstat3_to_errno(int error); * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete. * data is NULL. */ +EXTERN int rpc_nfs3_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data); EXTERN int rpc_nfs_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data); /* - * Call NFS/GETATTR + * Call NFS3/GETATTR * Function returns * 0 : The call was initiated. The callback will be invoked when the call completes. * <0 : An error occured when trying to set up the call. The callback will not be invoked. @@ -331,10 +332,12 @@ EXTERN int rpc_nfs_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_ * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete. * data is NULL. */ +struct GETATTR3args; +EXTERN int rpc_nfs3_getattr_async(struct rpc_context *rpc, rpc_cb cb, struct GETATTR3args *args, void *private_data); EXTERN int rpc_nfs_getattr_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data); /* - * Call NFS/PATHCONF + * Call NFS3/PATHCONF * Function returns * 0 : The call was initiated. The callback will be invoked when the call completes. * <0 : An error occured when trying to set up the call. The callback will not be invoked. @@ -347,10 +350,12 @@ EXTERN int rpc_nfs_getattr_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_ * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete. * data is NULL. */ +struct PATHCONF3args; +EXTERN int rpc_nfs3_pathconf_async(struct rpc_context *rpc, rpc_cb cb, struct PATHCONF3args *args, void *private_data); EXTERN int rpc_nfs_pathconf_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data); /* - * Call NFS/LOOKUP + * Call NFS3/LOOKUP * Function returns * 0 : The call was initiated. The callback will be invoked when the call completes. * <0 : An error occured when trying to set up the call. The callback will not be invoked. @@ -363,10 +368,12 @@ EXTERN int rpc_nfs_pathconf_async(struct rpc_context *rpc, rpc_cb cb, struct nfs * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete. * data is NULL. */ +struct LOOKUP3args; +EXTERN int rpc_nfs3_lookup_async(struct rpc_context *rpc, rpc_cb cb, struct LOOKUP3args *args, void *private_data); EXTERN int rpc_nfs_lookup_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *name, void *private_data); /* - * Call NFS/ACCESS + * Call NFS3/ACCESS * Function returns * 0 : The call was initiated. The callback will be invoked when the call completes. * <0 : An error occured when trying to set up the call. The callback will not be invoked. @@ -379,10 +386,12 @@ EXTERN int rpc_nfs_lookup_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_f * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete. * data is NULL. */ +struct ACCESS3args; +EXTERN int rpc_nfs3_access_async(struct rpc_context *rpc, rpc_cb cb, struct ACCESS3args *args, void *private_data); EXTERN int rpc_nfs_access_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, int access, void *private_data); /* - * Call NFS/READ + * Call NFS3/READ * Function returns * 0 : The call was initiated. The callback will be invoked when the call completes. * <0 : An error occured when trying to set up the call. The callback will not be invoked. @@ -395,10 +404,12 @@ EXTERN int rpc_nfs_access_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_f * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete. * data is NULL. */ +struct READ3args; +EXTERN int rpc_nfs3_read_async(struct rpc_context *rpc, rpc_cb cb, struct READ3args *args, void *private_data); EXTERN int rpc_nfs_read_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, uint64_t offset, uint64_t count, void *private_data); /* - * Call NFS/WRITE + * Call NFS3/WRITE * Function returns * 0 : The call was initiated. The callback will be invoked when the call completes. * <0 : An error occured when trying to set up the call. The callback will not be invoked. @@ -411,10 +422,12 @@ EXTERN int rpc_nfs_read_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete. * data is NULL. */ +struct WRITE3args; +EXTERN int rpc_nfs3_write_async(struct rpc_context *rpc, rpc_cb cb, struct WRITE3args *args, void *private_data); EXTERN int rpc_nfs_write_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *buf, uint64_t offset, uint64_t count, int stable_how, void *private_data); /* - * Call NFS/COMMIT + * Call NFS3/COMMIT * Function returns * 0 : The call was initiated. The callback will be invoked when the call completes. * <0 : An error occured when trying to set up the call. The callback will not be invoked. @@ -427,11 +440,12 @@ EXTERN int rpc_nfs_write_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete. * data is NULL. */ +struct COMMIT3args; +EXTERN int rpc_nfs3_commit_async(struct rpc_context *rpc, rpc_cb cb, struct COMMIT3args *args, void *private_data); EXTERN int rpc_nfs_commit_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data); - /* - * Call NFS/SETATTR + * Call NFS3/SETATTR * Function returns * 0 : The call was initiated. The callback will be invoked when the call completes. * <0 : An error occured when trying to set up the call. The callback will not be invoked. @@ -445,12 +459,11 @@ EXTERN int rpc_nfs_commit_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_f * data is NULL. */ struct SETATTR3args; +EXTERN int rpc_nfs3_setattr_async(struct rpc_context *rpc, rpc_cb cb, struct SETATTR3args *args, void *private_data); EXTERN int rpc_nfs_setattr_async(struct rpc_context *rpc, rpc_cb cb, struct SETATTR3args *args, void *private_data); - - /* - * Call NFS/MKDIR + * Call NFS3/MKDIR * Function returns * 0 : The call was initiated. The callback will be invoked when the call completes. * <0 : An error occured when trying to set up the call. The callback will not be invoked. @@ -464,14 +477,11 @@ EXTERN int rpc_nfs_setattr_async(struct rpc_context *rpc, rpc_cb cb, struct SETA * data is NULL. */ struct MKDIR3args; +EXTERN int rpc_nfs3_mkdir_async(struct rpc_context *rpc, rpc_cb cb, struct MKDIR3args *args, void *private_data); EXTERN int rpc_nfs_mkdir_async(struct rpc_context *rpc, rpc_cb cb, struct MKDIR3args *args, void *private_data); - - - - /* - * Call NFS/RMDIR + * Call NFS3/RMDIR * Function returns * 0 : The call was initiated. The callback will be invoked when the call completes. * <0 : An error occured when trying to set up the call. The callback will not be invoked. @@ -484,13 +494,12 @@ EXTERN int rpc_nfs_mkdir_async(struct rpc_context *rpc, rpc_cb cb, struct MKDIR3 * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete. * data is NULL. */ +struct RMDIR3args; +EXTERN int rpc_nfs3_rmdir_async(struct rpc_context *rpc, rpc_cb cb, struct RMDIR3args *args, void *private_data); EXTERN int rpc_nfs_rmdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *dir, void *private_data); - - - /* - * Call NFS/CREATE + * Call NFS3/CREATE * Function returns * 0 : The call was initiated. The callback will be invoked when the call completes. * <0 : An error occured when trying to set up the call. The callback will not be invoked. @@ -504,11 +513,11 @@ EXTERN int rpc_nfs_rmdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh * data is NULL. */ struct CREATE3args; +EXTERN int rpc_nfs3_create_async(struct rpc_context *rpc, rpc_cb cb, struct CREATE3args *args, void *private_data); EXTERN int rpc_nfs_create_async(struct rpc_context *rpc, rpc_cb cb, struct CREATE3args *args, void *private_data); - /* - * Call NFS/MKNOD + * Call NFS3/MKNOD * Function returns * 0 : The call was initiated. The callback will be invoked when the call completes. * <0 : An error occured when trying to set up the call. The callback will not be invoked. @@ -521,11 +530,12 @@ EXTERN int rpc_nfs_create_async(struct rpc_context *rpc, rpc_cb cb, struct CREAT * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete. * data is NULL. */ +struct MKNOD3args; +EXTERN int rpc_nfs3_mknod_async(struct rpc_context *rpc, rpc_cb cb, struct MKNOD3args *args, void *private_data); EXTERN int rpc_nfs_mknod_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *file, int mode, int major, int minor, void *private_data); - /* - * Call NFS/REMOVE + * Call NFS3/REMOVE * Function returns * 0 : The call was initiated. The callback will be invoked when the call completes. * <0 : An error occured when trying to set up the call. The callback will not be invoked. @@ -538,12 +548,12 @@ EXTERN int rpc_nfs_mknod_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete. * data is NULL. */ +struct REMOVE3args; +EXTERN int rpc_nfs3_remove_async(struct rpc_context *rpc, rpc_cb cb, struct REMOVE3args *args, void *private_data); EXTERN int rpc_nfs_remove_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *name, void *private_data); - - /* - * Call NFS/READDIR + * Call NFS3/READDIR * Function returns * 0 : The call was initiated. The callback will be invoked when the call completes. * <0 : An error occured when trying to set up the call. The callback will not be invoked. @@ -556,10 +566,12 @@ EXTERN int rpc_nfs_remove_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_f * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete. * data is NULL. */ +struct READDIR3args; +EXTERN int rpc_nfs3_readdir_async(struct rpc_context *rpc, rpc_cb cb, struct READDIR3args *args, void *private_data); EXTERN int rpc_nfs_readdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, uint64_t cookie, char *cookieverf, int count, void *private_data); /* - * Call NFS/READDIRPLUS + * Call NFS3/READDIRPLUS * Function returns * 0 : The call was initiated. The callback will be invoked when the call completes. * <0 : An error occured when trying to set up the call. The callback will not be invoked. @@ -572,10 +584,12 @@ EXTERN int rpc_nfs_readdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_ * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete. * data is NULL. */ +struct READDIRPLUS3args; +EXTERN int rpc_nfs3_readdirplus_async(struct rpc_context *rpc, rpc_cb cb, struct READDIRPLUS3args *args, void *private_data); EXTERN int rpc_nfs_readdirplus_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, uint64_t cookie, char *cookieverf, int count, void *private_data); /* - * Call NFS/FSSTAT + * Call NFS3/FSSTAT * Function returns * 0 : The call was initiated. The callback will be invoked when the call completes. * <0 : An error occured when trying to set up the call. The callback will not be invoked. @@ -588,12 +602,12 @@ EXTERN int rpc_nfs_readdirplus_async(struct rpc_context *rpc, rpc_cb cb, struct * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete. * data is NULL. */ +struct FSSTAT3args; +EXTERN int rpc_nfs3_fsstat_async(struct rpc_context *rpc, rpc_cb cb, struct FSSTAT3args *args, void *private_data); EXTERN int rpc_nfs_fsstat_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data); - - /* - * Call NFS/FSINFO + * Call NFS3/FSINFO * Function returns * 0 : The call was initiated. The callback will be invoked when the call completes. * <0 : An error occured when trying to set up the call. The callback will not be invoked. @@ -606,12 +620,12 @@ EXTERN int rpc_nfs_fsstat_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_f * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete. * data is NULL. */ +struct FSINFO3args; +EXTERN int rpc_nfs3_fsinfo_async(struct rpc_context *rpc, rpc_cb cb, struct FSINFO3args *args, void *private_data); EXTERN int rpc_nfs_fsinfo_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data); - - /* - * Call NFS/READLINK + * Call NFS3/READLINK * Function returns * 0 : The call was initiated. The callback will be invoked when the call completes. * <0 : An error occured when trying to set up the call. The callback will not be invoked. @@ -625,12 +639,11 @@ EXTERN int rpc_nfs_fsinfo_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_f * data is NULL. */ struct READLINK3args; +EXTERN int rpc_nfs3_readlink_async(struct rpc_context *rpc, rpc_cb cb, struct READLINK3args *args, void *private_data); EXTERN int rpc_nfs_readlink_async(struct rpc_context *rpc, rpc_cb cb, struct READLINK3args *args, void *private_data); - - /* - * Call NFS/SYMLINK + * Call NFS3/SYMLINK * Function returns * 0 : The call was initiated. The callback will be invoked when the call completes. * <0 : An error occured when trying to set up the call. The callback will not be invoked. @@ -644,11 +657,11 @@ EXTERN int rpc_nfs_readlink_async(struct rpc_context *rpc, rpc_cb cb, struct REA * data is NULL. */ struct SYMLINK3args; +EXTERN int rpc_nfs3_symlink_async(struct rpc_context *rpc, rpc_cb cb, struct SYMLINK3args *args, void *private_data); EXTERN int rpc_nfs_symlink_async(struct rpc_context *rpc, rpc_cb cb, struct SYMLINK3args *args, void *private_data); - /* - * Call NFS/RENAME + * Call NFS3/RENAME * Function returns * 0 : The call was initiated. The callback will be invoked when the call completes. * <0 : An error occured when trying to set up the call. The callback will not be invoked. @@ -661,12 +674,12 @@ EXTERN int rpc_nfs_symlink_async(struct rpc_context *rpc, rpc_cb cb, struct SYML * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete. * data is NULL. */ +struct RENAME3args; +EXTERN int rpc_nfs3_rename_async(struct rpc_context *rpc, rpc_cb cb, struct RENAME3args *args, void *private_data); EXTERN int rpc_nfs_rename_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *olddir, char *oldname, struct nfs_fh3 *newdir, char *newname, void *private_data); - - /* - * Call NFS/LINK + * Call NFS3/LINK * Function returns * 0 : The call was initiated. The callback will be invoked when the call completes. * <0 : An error occured when trying to set up the call. The callback will not be invoked. @@ -679,11 +692,11 @@ EXTERN int rpc_nfs_rename_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_f * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete. * data is NULL. */ +struct LINK3args; +EXTERN int rpc_nfs3_link_async(struct rpc_context *rpc, rpc_cb cb, struct LINK3args *args, void *private_data); EXTERN int rpc_nfs_link_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *file, struct nfs_fh3 *newdir, char *newname, void *private_data); - - /* * RQUOTA FUNCTIONS */ @@ -878,7 +891,7 @@ char *nlmstat4_to_str(int stat); * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete. * data is NULL. */ -int rpc_nlm4_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data); +EXTERN int rpc_nlm4_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data); /* * Call NLM/TEST @@ -897,7 +910,7 @@ int rpc_nlm4_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data); * data is NULL. */ struct NLM4_TESTargs; -int rpc_nlm4_test_async(struct rpc_context *rpc, rpc_cb cb, struct NLM4_TESTargs *args, void *private_data); +EXTERN int rpc_nlm4_test_async(struct rpc_context *rpc, rpc_cb cb, struct NLM4_TESTargs *args, void *private_data); /* * Call NLM/LOCK @@ -916,7 +929,7 @@ int rpc_nlm4_test_async(struct rpc_context *rpc, rpc_cb cb, struct NLM4_TESTargs * data is NULL. */ struct NLM4_LOCKargs; -int rpc_nlm4_lock_async(struct rpc_context *rpc, rpc_cb cb, struct NLM4_LOCKargs *args, void *private_data); +EXTERN int rpc_nlm4_lock_async(struct rpc_context *rpc, rpc_cb cb, struct NLM4_LOCKargs *args, void *private_data); /* * Call NLM/CANCEL @@ -935,7 +948,7 @@ int rpc_nlm4_lock_async(struct rpc_context *rpc, rpc_cb cb, struct NLM4_LOCKargs * data is NULL. */ struct NLM4_CANCargs; -int rpc_nlm4_cancel_async(struct rpc_context *rpc, rpc_cb cb, struct NLM4_CANCargs *args, void *private_data); +EXTERN int rpc_nlm4_cancel_async(struct rpc_context *rpc, rpc_cb cb, struct NLM4_CANCargs *args, void *private_data); /* * Call NLM/UNLOCK @@ -954,7 +967,7 @@ int rpc_nlm4_cancel_async(struct rpc_context *rpc, rpc_cb cb, struct NLM4_CANCar * data is NULL. */ struct NLM4_UNLOCKargs; -int rpc_nlm4_unlock_async(struct rpc_context *rpc, rpc_cb cb, struct NLM4_UNLOCKargs *args, void *private_data); +EXTERN int rpc_nlm4_unlock_async(struct rpc_context *rpc, rpc_cb cb, struct NLM4_UNLOCKargs *args, void *private_data); /* * NSM functions @@ -977,7 +990,7 @@ char *nsmstat1_to_str(int stat); * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete. * data is NULL. */ -int rpc_nsm1_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data); +EXTERN int rpc_nsm1_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data); /* * Call NSM/STAT @@ -996,7 +1009,7 @@ int rpc_nsm1_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data); * data is NULL. */ struct NSM1_STATargs; -int rpc_nsm1_stat_async(struct rpc_context *rpc, rpc_cb cb, struct NSM1_STATargs *args, void *private_data); +EXTERN int rpc_nsm1_stat_async(struct rpc_context *rpc, rpc_cb cb, struct NSM1_STATargs *args, void *private_data); /* * Call NSM/MON @@ -1015,7 +1028,7 @@ int rpc_nsm1_stat_async(struct rpc_context *rpc, rpc_cb cb, struct NSM1_STATargs * data is NULL. */ struct NSM1_MONargs; -int rpc_nsm1_mon_async(struct rpc_context *rpc, rpc_cb cb, struct NSM1_MONargs *args, void *private_data); +EXTERN int rpc_nsm1_mon_async(struct rpc_context *rpc, rpc_cb cb, struct NSM1_MONargs *args, void *private_data); /* * Call NSM/UNMON @@ -1034,7 +1047,7 @@ int rpc_nsm1_mon_async(struct rpc_context *rpc, rpc_cb cb, struct NSM1_MONargs * * data is NULL. */ struct NSM1_UNMONargs; -int rpc_nsm1_unmon_async(struct rpc_context *rpc, rpc_cb cb, struct NSM1_UNMONargs *args, void *private_data); +EXTERN int rpc_nsm1_unmon_async(struct rpc_context *rpc, rpc_cb cb, struct NSM1_UNMONargs *args, void *private_data); /* * Call NSM/UNMONALL @@ -1053,7 +1066,7 @@ int rpc_nsm1_unmon_async(struct rpc_context *rpc, rpc_cb cb, struct NSM1_UNMONar * data is NULL. */ struct NSM1_UNMONALLargs; -int rpc_nsm1_unmonall_async(struct rpc_context *rpc, rpc_cb cb, struct NSM1_UNMONALLargs *args, void *private_data); +EXTERN int rpc_nsm1_unmonall_async(struct rpc_context *rpc, rpc_cb cb, struct NSM1_UNMONALLargs *args, void *private_data); /* * Call NSM/SIMUCRASH @@ -1071,7 +1084,7 @@ int rpc_nsm1_unmonall_async(struct rpc_context *rpc, rpc_cb cb, struct NSM1_UNMO * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete. * data is NULL. */ -int rpc_nsm1_simucrash_async(struct rpc_context *rpc, rpc_cb cb, void *private_data); +EXTERN int rpc_nsm1_simucrash_async(struct rpc_context *rpc, rpc_cb cb, void *private_data); /* * Call NSM/NOTIFY @@ -1090,6 +1103,6 @@ int rpc_nsm1_simucrash_async(struct rpc_context *rpc, rpc_cb cb, void *private_d * data is NULL. */ struct NSM1_NOTIFYargs; -int rpc_nsm1_notify_async(struct rpc_context *rpc, rpc_cb cb, struct NSM1_NOTIFYargs *args, void *private_data); +EXTERN int rpc_nsm1_notify_async(struct rpc_context *rpc, rpc_cb cb, struct NSM1_NOTIFYargs *args, void *private_data); #endif diff --git a/lib/libnfs-win32.def b/lib/libnfs-win32.def index feec9aa..c0b19df 100644 --- a/lib/libnfs-win32.def +++ b/lib/libnfs-win32.def @@ -121,6 +121,28 @@ rpc_nfs_readlink_async rpc_nfs_symlink_async rpc_nfs_rename_async rpc_nfs_link_async +rpc_nfs3_null_async +rpc_nfs3_getattr_async +rpc_nfs3_pathconf_async +rpc_nfs3_lookup_async +rpc_nfs3_access_async +rpc_nfs3_read_async +rpc_nfs3_write_async +rpc_nfs3_commit_async +rpc_nfs3_setattr_async +rpc_nfs3_mkdir_async +rpc_nfs3_rmdir_async +rpc_nfs3_create_async +rpc_nfs3_mknod_async +rpc_nfs3_remove_async +rpc_nfs3_readdir_async +rpc_nfs3_readdirplus_async +rpc_nfs3_fsstat_async +rpc_nfs3_fsinfo_async +rpc_nfs3_readlink_async +rpc_nfs3_symlink_async +rpc_nfs3_rename_async +rpc_nfs3_link_async rpc_nlm4_null_async rpc_nlm4_test_async rpc_nlm4_lock_async diff --git a/lib/libnfs.c b/lib/libnfs.c index 2e3e7f2..e99c561 100644 --- a/lib/libnfs.c +++ b/lib/libnfs.c @@ -424,6 +424,7 @@ static void nfs_mount_9_cb(struct rpc_context *rpc, int status, void *command_da struct nfs_cb_data *data = private_data; struct nfs_context *nfs = data->nfs; FSINFO3res *res = command_data; + struct GETATTR3args args; assert(rpc->magic == RPC_CONTEXT_MAGIC); @@ -441,7 +442,11 @@ static void nfs_mount_9_cb(struct rpc_context *rpc, int status, void *command_da nfs->readmax = res->FSINFO3res_u.resok.rtmax; nfs->writemax = res->FSINFO3res_u.resok.wtmax; - if (rpc_nfs_getattr_async(rpc, nfs_mount_10_cb, &nfs->rootfh, data) != 0) { + memset(&args, 0, sizeof(GETATTR3args)); + args.object.data.data_len = nfs->rootfh.data.data_len; + args.object.data.data_val = nfs->rootfh.data.data_val; + + if (rpc_nfs3_getattr_async(rpc, nfs_mount_10_cb, &args, data) != 0) { data->cb(-ENOMEM, nfs, command_data, data->private_data); free_nfs_cb_data(data); return; @@ -774,6 +779,7 @@ static void nfs_lookup_path_1_cb(struct rpc_context *rpc, int status, void *comm static int nfs_lookup_path_async_internal(struct nfs_context *nfs, struct nfs_cb_data *data, struct nfs_fh3 *fh) { char *path, *str; + LOOKUP3args args; while (*data->path == '/') { data->path++; @@ -804,7 +810,13 @@ static int nfs_lookup_path_async_internal(struct nfs_context *nfs, struct nfs_cb return 0; } - if (rpc_nfs_lookup_async(nfs->rpc, nfs_lookup_path_1_cb, fh, path, data) != 0) { + + memset(&args, 0, sizeof(LOOKUP3args)); + args.what.dir.data.data_len = fh->data.data_len; + args.what.dir.data.data_val = fh->data.data_val; + args.what.name = path; + + if (rpc_nfs3_lookup_async(nfs->rpc, nfs_lookup_path_1_cb, &args, data) != 0) { rpc_set_error(nfs->rpc, "RPC error: Failed to send lookup call for %s", data->path); data->cb(-ENOMEM, nfs, rpc_get_error(nfs->rpc), data->private_data); free_nfs_cb_data(data); @@ -913,7 +925,13 @@ static void nfs_stat_1_cb(struct rpc_context *rpc, int status, void *command_dat static int nfs_stat_continue_internal(struct nfs_context *nfs, struct nfs_cb_data *data) { - if (rpc_nfs_getattr_async(nfs->rpc, nfs_stat_1_cb, &data->fh, data) != 0) { + struct GETATTR3args args; + + memset(&args, 0, sizeof(GETATTR3args)); + args.object.data.data_len = data->fh.data.data_len; + args.object.data.data_val = data->fh.data.data_val; + + if (rpc_nfs3_getattr_async(nfs->rpc, nfs_stat_1_cb, &args, data) != 0) { rpc_set_error(nfs->rpc, "RPC error: Failed to send STAT GETATTR call for %s", data->path); data->cb(-ENOMEM, nfs, rpc_get_error(nfs->rpc), data->private_data); free_nfs_cb_data(data); @@ -1017,6 +1035,7 @@ static void nfs_open_cb(struct rpc_context *rpc, int status, void *command_data, static int nfs_open_continue_internal(struct nfs_context *nfs, struct nfs_cb_data *data) { int nfsmode = 0; + ACCESS3args args; if (data->continue_int & O_WRONLY) { nfsmode |= ACCESS3_MODIFY; @@ -1028,7 +1047,12 @@ static int nfs_open_continue_internal(struct nfs_context *nfs, struct nfs_cb_dat nfsmode |= ACCESS3_READ; } - if (rpc_nfs_access_async(nfs->rpc, nfs_open_cb, &data->fh, nfsmode, data) != 0) { + memset(&args, 0, sizeof(ACCESS3args)); + args.object.data.data_len = data->fh.data.data_len; + args.object.data.data_val = data->fh.data.data_val; + args.access = nfsmode; + + if (rpc_nfs3_access_async(nfs->rpc, nfs_open_cb, &args, data) != 0) { rpc_set_error(nfs->rpc, "RPC error: Failed to send OPEN ACCESS call for %s", data->path); data->cb(-ENOMEM, nfs, rpc_get_error(nfs->rpc), data->private_data); free_nfs_cb_data(data); @@ -1166,7 +1190,15 @@ int nfs_pread_async(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offse nfsfh->offset = offset; if (count <= nfs_get_readmax(nfs)) { - if (rpc_nfs_read_async(nfs->rpc, nfs_pread_cb, &nfsfh->fh, offset, count, data) != 0) { + READ3args args; + + memset(&args, 0, sizeof(READ3args)); + args.file.data.data_len = nfsfh->fh.data.data_len; + args.file.data.data_val = nfsfh->fh.data.data_val; + args.offset = offset; + args.count = count; + + if (rpc_nfs3_read_async(nfs->rpc, nfs_pread_cb, &args, data) != 0) { rpc_set_error(nfs->rpc, "RPC error: Failed to send READ call for %s", data->path); data->cb(-ENOMEM, nfs, rpc_get_error(nfs->rpc), data->private_data); free_nfs_cb_data(data); @@ -1193,6 +1225,7 @@ int nfs_pread_async(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offse while (count > 0) { uint64_t readcount = count; struct nfs_mcb_data *mdata; + READ3args args; if (readcount > nfs_get_readmax(nfs)) { readcount = nfs_get_readmax(nfs); @@ -1207,7 +1240,14 @@ int nfs_pread_async(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offse mdata->data = data; mdata->offset = offset; mdata->count = readcount; - if (rpc_nfs_read_async(nfs->rpc, nfs_pread_mcb, &nfsfh->fh, offset, readcount, mdata) != 0) { + + memset(&args, 0, sizeof(READ3args)); + args.file.data.data_len = nfsfh->fh.data.data_len; + args.file.data.data_val = nfsfh->fh.data.data_val; + args.offset = offset; + args.count = readcount; + + if (rpc_nfs3_read_async(nfs->rpc, nfs_pread_mcb, &args, mdata) != 0) { rpc_set_error(nfs->rpc, "RPC error: Failed to send READ call for %s", data->path); data->cb(-ENOMEM, nfs, rpc_get_error(nfs->rpc), data->private_data); free(mdata); @@ -1346,7 +1386,18 @@ int nfs_pwrite_async(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offs nfsfh->offset = offset; if (count <= nfs_get_writemax(nfs)) { - if (rpc_nfs_write_async(nfs->rpc, nfs_pwrite_cb, &nfsfh->fh, buf, offset, count, nfsfh->is_sync?FILE_SYNC:UNSTABLE, data) != 0) { + WRITE3args args; + + memset(&args, 0, sizeof(WRITE3args)); + args.file.data.data_len = nfsfh->fh.data.data_len; + args.file.data.data_val = nfsfh->fh.data.data_val; + args.offset = offset; + args.count = count; + args.stable = nfsfh->is_sync?FILE_SYNC:UNSTABLE; + args.data.data_len = count; + args.data.data_val = buf; + + if (rpc_nfs3_write_async(nfs->rpc, nfs_pwrite_cb, &args, data) != 0) { rpc_set_error(nfs->rpc, "RPC error: Failed to send WRITE call for %s", data->path); data->cb(-ENOMEM, nfs, rpc_get_error(nfs->rpc), data->private_data); free_nfs_cb_data(data); @@ -1365,6 +1416,7 @@ int nfs_pwrite_async(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offs while (count > 0) { uint64_t writecount = count; struct nfs_mcb_data *mdata; + WRITE3args args; if (writecount > nfs_get_writemax(nfs)) { writecount = nfs_get_writemax(nfs); @@ -1380,7 +1432,16 @@ int nfs_pwrite_async(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offs mdata->offset = offset; mdata->count = writecount; - if (rpc_nfs_write_async(nfs->rpc, nfs_pwrite_mcb, &nfsfh->fh, &buf[offset - data->start_offset], offset, writecount, nfsfh->is_sync?FILE_SYNC:UNSTABLE, mdata) != 0) { + memset(&args, 0, sizeof(WRITE3args)); + args.file.data.data_len = nfsfh->fh.data.data_len; + args.file.data.data_val = nfsfh->fh.data.data_val; + args.offset = offset; + args.count = writecount; + args.stable = nfsfh->is_sync?FILE_SYNC:UNSTABLE; + args.data.data_len = writecount; + args.data.data_val = &buf[offset - data->start_offset]; + + if (rpc_nfs3_write_async(nfs->rpc, nfs_pwrite_mcb, &args, mdata) != 0) { rpc_set_error(nfs->rpc, "RPC error: Failed to send WRITE call for %s", data->path); data->cb(-ENOMEM, nfs, rpc_get_error(nfs->rpc), data->private_data); free(mdata); @@ -1432,6 +1493,7 @@ int nfs_close_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, voi int nfs_fstat_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, void *private_data) { struct nfs_cb_data *data; + struct GETATTR3args args; data = malloc(sizeof(struct nfs_cb_data)); if (data == NULL) { @@ -1443,7 +1505,11 @@ int nfs_fstat_async(struct nfs_context *nfs, struct nfsfh *nfsfh, nfs_cb cb, voi data->cb = cb; data->private_data = private_data; - if (rpc_nfs_getattr_async(nfs->rpc, nfs_stat_1_cb, &nfsfh->fh, data) != 0) { + memset(&args, 0, sizeof(GETATTR3args)); + args.object.data.data_len = nfsfh->fh.data.data_len; + args.object.data.data_val = nfsfh->fh.data.data_val; + + if (rpc_nfs3_getattr_async(nfs->rpc, nfs_stat_1_cb, &args, data) != 0) { rpc_set_error(nfs->rpc, "RPC error: Failed to send STAT GETATTR call for %s", data->path); data->cb(-ENOMEM, nfs, rpc_get_error(nfs->rpc), data->private_data); free_nfs_cb_data(data); @@ -1849,6 +1915,7 @@ static void nfs_creat_1_cb(struct rpc_context *rpc, int status, void *command_da struct nfs_cb_data *data = private_data; struct nfs_context *nfs = data->nfs; char *str = data->continue_data; + LOOKUP3args args; assert(rpc->magic == RPC_CONTEXT_MAGIC); @@ -1872,7 +1939,12 @@ static void nfs_creat_1_cb(struct rpc_context *rpc, int status, void *command_da return; } - if (rpc_nfs_lookup_async(nfs->rpc, nfs_create_2_cb, &data->fh, str, data) != 0) { + memset(&args, 0, sizeof(LOOKUP3args)); + args.what.dir.data.data_len = data->fh.data.data_len; + args.what.dir.data.data_val = data->fh.data.data_val; + args.what.name = str; + + if (rpc_nfs3_lookup_async(nfs->rpc, nfs_create_2_cb, &args, data) != 0) { rpc_set_error(nfs->rpc, "RPC error: Failed to send lookup call for %s/%s", data->saved_path, str); data->cb(-ENOMEM, nfs, rpc_get_error(nfs->rpc), data->private_data); free_nfs_cb_data(data); @@ -2282,12 +2354,18 @@ static void nfs_opendir2_cb(struct rpc_context *rpc, int status, void *command_d rdpe_cb_data->data = data; for (nfsdirent = nfsdir->entries; nfsdirent; nfsdirent = nfsdirent->next) { struct rdpe_lookup_cb_data *rdpe_lookup_cb_data; + LOOKUP3args args; rdpe_lookup_cb_data = malloc(sizeof(struct rdpe_lookup_cb_data)); rdpe_lookup_cb_data->rdpe_cb_data = rdpe_cb_data; rdpe_lookup_cb_data->nfsdirent = nfsdirent; - if (rpc_nfs_lookup_async(nfs->rpc, nfs_opendir3_cb, &data->fh, nfsdirent->name, rdpe_lookup_cb_data) != 0) { + memset(&args, 0, sizeof(LOOKUP3args)); + args.what.dir.data.data_len = data->fh.data.data_len; + args.what.dir.data.data_val = data->fh.data.data_val; + args.what.name = nfsdirent->name; + + if (rpc_nfs3_lookup_async(nfs->rpc, nfs_opendir3_cb, &args, rdpe_lookup_cb_data) != 0) { rpc_set_error(nfs->rpc, "RPC error: Failed to send READDIR LOOKUP call"); /* if we have already commands in flight, we cant just stop, we have to wait for the @@ -2518,6 +2596,7 @@ static void nfs_lseek_1_cb(struct rpc_context *rpc, int status, void *command_da int nfs_lseek_async(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offset, int whence, nfs_cb cb, void *private_data) { struct lseek_cb_data *data; + struct GETATTR3args args; if (whence == SEEK_SET) { nfsfh->offset = offset; @@ -2542,7 +2621,11 @@ int nfs_lseek_async(struct nfs_context *nfs, struct nfsfh *nfsfh, uint64_t offse data->cb = cb; data->private_data = private_data; - if (rpc_nfs_getattr_async(nfs->rpc, nfs_lseek_1_cb, &nfsfh->fh, data) != 0) { + memset(&args, 0, sizeof(GETATTR3args)); + args.object.data.data_len = nfsfh->fh.data.data_len; + args.object.data.data_val = nfsfh->fh.data.data_val; + + if (rpc_nfs3_getattr_async(nfs->rpc, nfs_lseek_1_cb, &args, data) != 0) { rpc_set_error(nfs->rpc, "RPC error: Failed to send LSEEK GETATTR call"); free(data); return -1; @@ -3104,6 +3187,7 @@ static void nfs_access_cb(struct rpc_context *rpc, int status, void *command_dat static int nfs_access_continue_internal(struct nfs_context *nfs, struct nfs_cb_data *data) { int nfsmode = 0; + ACCESS3args args; if (data->continue_int & R_OK) { nfsmode |= ACCESS3_READ; @@ -3115,7 +3199,12 @@ static int nfs_access_continue_internal(struct nfs_context *nfs, struct nfs_cb_d nfsmode |= ACCESS3_EXECUTE; } - if (rpc_nfs_access_async(nfs->rpc, nfs_access_cb, &data->fh, nfsmode, data) != 0) { + memset(&args, 0, sizeof(ACCESS3args)); + args.object.data.data_len = data->fh.data.data_len; + args.object.data.data_val = data->fh.data.data_val; + args.access = nfsmode; + + if (rpc_nfs3_access_async(nfs->rpc, nfs_access_cb, &args, data) != 0) { rpc_set_error(nfs->rpc, "RPC error: Failed to send OPEN ACCESS call for %s", data->path); data->cb(-ENOMEM, nfs, rpc_get_error(nfs->rpc), data->private_data); free_nfs_cb_data(data); diff --git a/nfs/nfs.c b/nfs/nfs.c index c3cebc4..576145b 100644 --- a/nfs/nfs.c +++ b/nfs/nfs.c @@ -103,18 +103,21 @@ int nfsstat3_to_errno(int error) } -int rpc_nfs_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data) +/* + * NFSv3 + */ +int rpc_nfs3_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data) { struct rpc_pdu *pdu; pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_NULL, cb, private_data, (zdrproc_t)zdr_void, 0); if (pdu == NULL) { - rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/null call"); + rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/NULL call"); return -1; } if (rpc_queue_pdu(rpc, pdu) != 0) { - rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfs/null call"); + rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/NULL call"); rpc_free_pdu(rpc, pdu); return -2; } @@ -122,28 +125,29 @@ int rpc_nfs_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data) return 0; } -int rpc_nfs_getattr_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data) +int rpc_nfs_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data) +{ + return rpc_nfs3_null_async(rpc, cb, private_data); +} + +int rpc_nfs3_getattr_async(struct rpc_context *rpc, rpc_cb cb, struct GETATTR3args *args, void *private_data) { struct rpc_pdu *pdu; - GETATTR3args args; pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_GETATTR, cb, private_data, (zdrproc_t)zdr_GETATTR3res, sizeof(GETATTR3res)); if (pdu == NULL) { - rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/null call"); + rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/GETATTR call"); return -1; } - args.object.data.data_len = fh->data.data_len; - args.object.data.data_val = fh->data.data_val; - - if (zdr_GETATTR3args(&pdu->zdr, &args) == 0) { + if (zdr_GETATTR3args(&pdu->zdr, args) == 0) { rpc_set_error(rpc, "ZDR error: Failed to encode GETATTR3args"); rpc_free_pdu(rpc, pdu); return -2; } if (rpc_queue_pdu(rpc, pdu) != 0) { - rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfs/getattr call"); + rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/GETATTR call"); rpc_free_pdu(rpc, pdu); return -3; } @@ -151,28 +155,35 @@ int rpc_nfs_getattr_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh return 0; } -int rpc_nfs_pathconf_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data) +int rpc_nfs_getattr_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data) +{ + GETATTR3args args; + + memset(&args, 0, sizeof(GETATTR3args)); + args.object.data.data_len = fh->data.data_len; + args.object.data.data_val = fh->data.data_val; + + return rpc_nfs3_getattr_async(rpc, cb, &args, private_data); +} + +int rpc_nfs3_pathconf_async(struct rpc_context *rpc, rpc_cb cb, struct PATHCONF3args *args, void *private_data) { struct rpc_pdu *pdu; - PATHCONF3args args; pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_PATHCONF, cb, private_data, (zdrproc_t)zdr_PATHCONF3res, sizeof(PATHCONF3res)); if (pdu == NULL) { - rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/pathconf call"); + rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/PATHCONF call"); return -1; } - args.object.data.data_len = fh->data.data_len; - args.object.data.data_val = fh->data.data_val; - - if (zdr_PATHCONF3args(&pdu->zdr, &args) == 0) { + if (zdr_PATHCONF3args(&pdu->zdr, args) == 0) { rpc_set_error(rpc, "ZDR error: Failed to encode PATHCONF3args"); rpc_free_pdu(rpc, pdu); return -2; } if (rpc_queue_pdu(rpc, pdu) != 0) { - rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfs/pathconf call"); + rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/PATHCONF call"); rpc_free_pdu(rpc, pdu); return -3; } @@ -180,29 +191,35 @@ int rpc_nfs_pathconf_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *f return 0; } -int rpc_nfs_lookup_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *name, void *private_data) +int rpc_nfs_pathconf_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data) +{ + PATHCONF3args args; + + memset(&args, 0, sizeof(PATHCONF3args)); + args.object.data.data_len = fh->data.data_len; + args.object.data.data_val = fh->data.data_val; + + return rpc_nfs3_pathconf_async(rpc, cb, &args, private_data); +} + +int rpc_nfs3_lookup_async(struct rpc_context *rpc, rpc_cb cb, struct LOOKUP3args *args, void *private_data) { struct rpc_pdu *pdu; - LOOKUP3args args; pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_LOOKUP, cb, private_data, (zdrproc_t)zdr_LOOKUP3res, sizeof(LOOKUP3res)); if (pdu == NULL) { - rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/lookup call"); + rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/LOOKUP call"); return -1; } - args.what.dir.data.data_len = fh->data.data_len; - args.what.dir.data.data_val = fh->data.data_val; - args.what.name = name; - - if (zdr_LOOKUP3args(&pdu->zdr, &args) == 0) { + if (zdr_LOOKUP3args(&pdu->zdr, args) == 0) { rpc_set_error(rpc, "ZDR error: Failed to encode LOOKUP3args"); rpc_free_pdu(rpc, pdu); return -2; } if (rpc_queue_pdu(rpc, pdu) != 0) { - rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfs/lookup call"); + rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/LOOKUP call"); rpc_free_pdu(rpc, pdu); return -3; } @@ -210,30 +227,36 @@ int rpc_nfs_lookup_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, return 0; } +int rpc_nfs_lookup_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *name, void *private_data) +{ + LOOKUP3args args; -int rpc_nfs_access_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, int access, void *private_data) + memset(&args, 0, sizeof(LOOKUP3args)); + args.what.dir.data.data_len = fh->data.data_len; + args.what.dir.data.data_val = fh->data.data_val; + args.what.name = name; + + return rpc_nfs3_lookup_async(rpc, cb, &args, private_data); +} + +int rpc_nfs3_access_async(struct rpc_context *rpc, rpc_cb cb, struct ACCESS3args *args, void *private_data) { struct rpc_pdu *pdu; - ACCESS3args args; pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_ACCESS, cb, private_data, (zdrproc_t)zdr_ACCESS3res, sizeof(ACCESS3res)); if (pdu == NULL) { - rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/access call"); + rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/ACCESS call"); return -1; } - args.object.data.data_len = fh->data.data_len; - args.object.data.data_val = fh->data.data_val; - args.access = access; - - if (zdr_ACCESS3args(&pdu->zdr, &args) == 0) { + if (zdr_ACCESS3args(&pdu->zdr, args) == 0) { rpc_set_error(rpc, "ZDR error: Failed to encode ACCESS3args"); rpc_free_pdu(rpc, pdu); return -2; } if (rpc_queue_pdu(rpc, pdu) != 0) { - rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfs/access call"); + rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/ACCESS call"); rpc_free_pdu(rpc, pdu); return -3; } @@ -241,32 +264,36 @@ int rpc_nfs_access_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, return 0; } +int rpc_nfs_access_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, int access, void *private_data) +{ + ACCESS3args args; + + memset(&args, 0, sizeof(ACCESS3args)); + args.object.data.data_len = fh->data.data_len; + args.object.data.data_val = fh->data.data_val; + args.access = access; + return rpc_nfs3_access_async(rpc, cb, &args, private_data); +} -int rpc_nfs_read_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, uint64_t offset, uint64_t count, void *private_data) +int rpc_nfs3_read_async(struct rpc_context *rpc, rpc_cb cb, struct READ3args *args, void *private_data) { struct rpc_pdu *pdu; - READ3args args; pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_READ, cb, private_data, (zdrproc_t)zdr_READ3res, sizeof(READ3res)); if (pdu == NULL) { - rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/read call"); + rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/READ call"); return -1; } - args.file.data.data_len = fh->data.data_len; - args.file.data.data_val = fh->data.data_val; - args.offset = offset; - args.count = count; - - if (zdr_READ3args(&pdu->zdr, &args) == 0) { + if (zdr_READ3args(&pdu->zdr, args) == 0) { rpc_set_error(rpc, "ZDR error: Failed to encode READ3args"); rpc_free_pdu(rpc, pdu); return -2; } if (rpc_queue_pdu(rpc, pdu) != 0) { - rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfs/read call"); + rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/READ call"); rpc_free_pdu(rpc, pdu); return -3; } @@ -274,34 +301,37 @@ int rpc_nfs_read_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, u return 0; } +int rpc_nfs_read_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, uint64_t offset, uint64_t count, void *private_data) +{ + READ3args args; -int rpc_nfs_write_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *buf, uint64_t offset, uint64_t count, int stable_how, void *private_data) + memset(&args, 0, sizeof(READ3args)); + args.file.data.data_len = fh->data.data_len; + args.file.data.data_val = fh->data.data_val; + args.offset = offset; + args.count = count; + + return rpc_nfs3_read_async(rpc, cb, &args, private_data); +} + +int rpc_nfs3_write_async(struct rpc_context *rpc, rpc_cb cb, struct WRITE3args *args, void *private_data) { struct rpc_pdu *pdu; - WRITE3args args; pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_WRITE, cb, private_data, (zdrproc_t)zdr_WRITE3res, sizeof(WRITE3res)); if (pdu == NULL) { - rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/write call"); + rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/WRITE call"); return -1; } - args.file.data.data_len = fh->data.data_len; - args.file.data.data_val = fh->data.data_val; - args.offset = offset; - args.count = count; - args.stable = stable_how; - args.data.data_len = count; - args.data.data_val = buf; - - if (zdr_WRITE3args(&pdu->zdr, &args) == 0) { + if (zdr_WRITE3args(&pdu->zdr, args) == 0) { rpc_set_error(rpc, "ZDR error: Failed to encode WRITE3args"); rpc_free_pdu(rpc, pdu); return -2; } if (rpc_queue_pdu(rpc, pdu) != 0) { - rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfs/write call"); + rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/WRITE call"); rpc_free_pdu(rpc, pdu); return -3; } @@ -309,32 +339,40 @@ int rpc_nfs_write_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, return 0; } +int rpc_nfs_write_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *buf, uint64_t offset, uint64_t count, int stable_how, void *private_data) +{ + WRITE3args args; + + memset(&args, 0, sizeof(WRITE3args)); + args.file.data.data_len = fh->data.data_len; + args.file.data.data_val = fh->data.data_val; + args.offset = offset; + args.count = count; + args.stable = stable_how; + args.data.data_len = count; + args.data.data_val = buf; + return rpc_nfs3_write_async(rpc, cb, &args, private_data); +} -int rpc_nfs_commit_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data) +int rpc_nfs3_commit_async(struct rpc_context *rpc, rpc_cb cb, struct COMMIT3args *args, void *private_data) { struct rpc_pdu *pdu; - COMMIT3args args; pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_COMMIT, cb, private_data, (zdrproc_t)zdr_COMMIT3res, sizeof(COMMIT3res)); if (pdu == NULL) { - rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/commit call"); + rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/COMMIT call"); return -1; } - args.file.data.data_len = fh->data.data_len; - args.file.data.data_val = fh->data.data_val; - args.offset = 0; - args.count = 0; - - if (zdr_COMMIT3args(&pdu->zdr, &args) == 0) { - rpc_set_error(rpc, "ZDR error: Failed to encode WRITE3args"); + if (zdr_COMMIT3args(&pdu->zdr, args) == 0) { + rpc_set_error(rpc, "ZDR error: Failed to encode COMMIT3args"); rpc_free_pdu(rpc, pdu); return -2; } if (rpc_queue_pdu(rpc, pdu) != 0) { - rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfs/commit call"); + rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/COMMIT call"); rpc_free_pdu(rpc, pdu); return -3; } @@ -342,14 +380,26 @@ int rpc_nfs_commit_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, return 0; } +int rpc_nfs_commit_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data) +{ + COMMIT3args args; -int rpc_nfs_setattr_async(struct rpc_context *rpc, rpc_cb cb, SETATTR3args *args, void *private_data) + memset(&args, 0, sizeof(COMMIT3args)); + args.file.data.data_len = fh->data.data_len; + args.file.data.data_val = fh->data.data_val; + args.offset = 0; + args.count = 0; + + return rpc_nfs3_commit_async(rpc, cb, &args, private_data); +} + +int rpc_nfs3_setattr_async(struct rpc_context *rpc, rpc_cb cb, SETATTR3args *args, void *private_data) { struct rpc_pdu *pdu; pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_SETATTR, cb, private_data, (zdrproc_t)zdr_SETATTR3res, sizeof(SETATTR3res)); if (pdu == NULL) { - rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/setattr call"); + rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/SETATTR call"); return -1; } @@ -360,7 +410,7 @@ int rpc_nfs_setattr_async(struct rpc_context *rpc, rpc_cb cb, SETATTR3args *args } if (rpc_queue_pdu(rpc, pdu) != 0) { - rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfs/setattr call"); + rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/SETATTR call"); rpc_free_pdu(rpc, pdu); return -3; } @@ -368,15 +418,18 @@ int rpc_nfs_setattr_async(struct rpc_context *rpc, rpc_cb cb, SETATTR3args *args return 0; } +int rpc_nfs_setattr_async(struct rpc_context *rpc, rpc_cb cb, SETATTR3args *args, void *private_data) +{ + return rpc_nfs3_setattr_async(rpc, cb, args, private_data); +} - -int rpc_nfs_mkdir_async(struct rpc_context *rpc, rpc_cb cb, MKDIR3args *args, void *private_data) +int rpc_nfs3_mkdir_async(struct rpc_context *rpc, rpc_cb cb, MKDIR3args *args, void *private_data) { struct rpc_pdu *pdu; pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_MKDIR, cb, private_data, (zdrproc_t)zdr_MKDIR3res, sizeof(MKDIR3res)); if (pdu == NULL) { - rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/setattr call"); + rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/MKDIR call"); return -1; } @@ -387,7 +440,7 @@ int rpc_nfs_mkdir_async(struct rpc_context *rpc, rpc_cb cb, MKDIR3args *args, vo } if (rpc_queue_pdu(rpc, pdu) != 0) { - rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfs/mkdir call"); + rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/MKDIR call"); rpc_free_pdu(rpc, pdu); return -3; } @@ -395,33 +448,29 @@ int rpc_nfs_mkdir_async(struct rpc_context *rpc, rpc_cb cb, MKDIR3args *args, vo return 0; } +int rpc_nfs_mkdir_async(struct rpc_context *rpc, rpc_cb cb, MKDIR3args *args, void *private_data) +{ + return rpc_nfs3_mkdir_async(rpc, cb, args, private_data); +} - - -int rpc_nfs_rmdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *dir, void *private_data) +int rpc_nfs3_rmdir_async(struct rpc_context *rpc, rpc_cb cb, struct RMDIR3args *args, void *private_data) { struct rpc_pdu *pdu; - RMDIR3args args; pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_RMDIR, cb, private_data, (zdrproc_t)zdr_RMDIR3res, sizeof(RMDIR3res)); if (pdu == NULL) { - rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/rmdir call"); + rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/RMDIR call"); return -1; } - memset(&args, 0, sizeof(RMDIR3args)); - args.object.dir.data.data_len = fh->data.data_len; - args.object.dir.data.data_val = fh->data.data_val; - args.object.name = dir; - - if (zdr_RMDIR3args(&pdu->zdr, &args) == 0) { + if (zdr_RMDIR3args(&pdu->zdr, args) == 0) { rpc_set_error(rpc, "ZDR error: Failed to encode RMDIR3args"); rpc_free_pdu(rpc, pdu); return -2; } if (rpc_queue_pdu(rpc, pdu) != 0) { - rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfs/rmdir call"); + rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/RMDIR call"); rpc_free_pdu(rpc, pdu); return -3; } @@ -429,15 +478,25 @@ int rpc_nfs_rmdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, return 0; } +int rpc_nfs_rmdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *dir, void *private_data) +{ + RMDIR3args args; + + memset(&args, 0, sizeof(RMDIR3args)); + args.object.dir.data.data_len = fh->data.data_len; + args.object.dir.data.data_val = fh->data.data_val; + args.object.name = dir; + return rpc_nfs3_rmdir_async(rpc, cb, &args, private_data); +} -int rpc_nfs_create_async(struct rpc_context *rpc, rpc_cb cb, CREATE3args *args, void *private_data) +int rpc_nfs3_create_async(struct rpc_context *rpc, rpc_cb cb, CREATE3args *args, void *private_data) { struct rpc_pdu *pdu; pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_CREATE, cb, private_data, (zdrproc_t)zdr_CREATE3res, sizeof(CREATE3res)); if (pdu == NULL) { - rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/create call"); + rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/CREATE call"); return -1; } @@ -448,7 +507,7 @@ int rpc_nfs_create_async(struct rpc_context *rpc, rpc_cb cb, CREATE3args *args, } if (rpc_queue_pdu(rpc, pdu) != 0) { - rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfs/create call"); + rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/CREATE call"); rpc_free_pdu(rpc, pdu); return -3; } @@ -456,23 +515,45 @@ int rpc_nfs_create_async(struct rpc_context *rpc, rpc_cb cb, CREATE3args *args, return 0; } +int rpc_nfs_create_async(struct rpc_context *rpc, rpc_cb cb, CREATE3args *args, void *private_data) +{ + return rpc_nfs3_create_async(rpc, cb, args, private_data); +} - -int rpc_nfs_mknod_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *file, int mode, int major, int minor, void *private_data) +int rpc_nfs3_mknod_async(struct rpc_context *rpc, rpc_cb cb, struct MKNOD3args *args, void *private_data) { struct rpc_pdu *pdu; - MKNOD3args args; pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_MKNOD, cb, private_data, (zdrproc_t)zdr_MKNOD3res, sizeof(MKNOD3res)); if (pdu == NULL) { - rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/mknod call"); + rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/MKNOD call"); return -1; } + if (zdr_MKNOD3args(&pdu->zdr, args) == 0) { + rpc_set_error(rpc, "ZDR error: Failed to encode MKNOD3args"); + rpc_free_pdu(rpc, pdu); + return -2; + } + + if (rpc_queue_pdu(rpc, pdu) != 0) { + rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/MKNOD call"); + rpc_free_pdu(rpc, pdu); + return -3; + } + + return 0; +} + +int rpc_nfs_mknod_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *file, int mode, int major, int minor, void *private_data) +{ + MKNOD3args args; + memset(&args, 0, sizeof(MKNOD3args)); args.where.dir.data.data_len = fh->data.data_len; args.where.dir.data.data_val = fh->data.data_val; args.where.name = file; + switch (mode & S_IFMT) { case S_IFCHR: args.what.type = NF3CHR; @@ -498,19 +579,31 @@ int rpc_nfs_mknod_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, args.what.mknoddata3_u.pipe_attributes.mode.set_mode3_u.mode = mode & (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH); break; default: - rpc_set_error(rpc, "Invalid file type for nfs/mknod call"); - rpc_free_pdu(rpc, pdu); + rpc_set_error(rpc, "Invalid file type for NFS3/MKNOD call"); return -1; } - if (zdr_MKNOD3args(&pdu->zdr, &args) == 0) { - rpc_set_error(rpc, "ZDR error: Failed to encode MKNOD3args"); + return rpc_nfs3_mknod_async(rpc, cb, &args, private_data); +} + +int rpc_nfs3_remove_async(struct rpc_context *rpc, rpc_cb cb, struct REMOVE3args *args, void *private_data) +{ + struct rpc_pdu *pdu; + + pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_REMOVE, cb, private_data, (zdrproc_t)zdr_REMOVE3res, sizeof(REMOVE3res)); + if (pdu == NULL) { + rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/REMOVE call"); + return -1; + } + + if (zdr_REMOVE3args(&pdu->zdr, args) == 0) { + rpc_set_error(rpc, "ZDR error: Failed to encode REMOVE3args"); rpc_free_pdu(rpc, pdu); return -2; } if (rpc_queue_pdu(rpc, pdu) != 0) { - rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfs/mknod call"); + rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/REMOVE call"); rpc_free_pdu(rpc, pdu); return -3; } @@ -518,31 +611,36 @@ int rpc_nfs_mknod_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, return 0; } - int rpc_nfs_remove_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *file, void *private_data) { - struct rpc_pdu *pdu; REMOVE3args args; - pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_REMOVE, cb, private_data, (zdrproc_t)zdr_REMOVE3res, sizeof(REMOVE3res)); - if (pdu == NULL) { - rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/remove call"); - return -1; - } - memset(&args, 0, sizeof(REMOVE3args)); args.object.dir.data.data_len = fh->data.data_len; args.object.dir.data.data_val = fh->data.data_val; args.object.name = file; - if (zdr_REMOVE3args(&pdu->zdr, &args) == 0) { - rpc_set_error(rpc, "ZDR error: Failed to encode REMOVE3args"); + return rpc_nfs3_remove_async(rpc, cb, &args, private_data); +} + +int rpc_nfs3_readdir_async(struct rpc_context *rpc, rpc_cb cb, struct READDIR3args *args, void *private_data) +{ + struct rpc_pdu *pdu; + + pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_READDIR, cb, private_data, (zdrproc_t)zdr_READDIR3res, sizeof(READDIR3res)); + if (pdu == NULL) { + rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/READDIR call"); + return -1; + } + + if (zdr_READDIR3args(&pdu->zdr, args) == 0) { + rpc_set_error(rpc, "ZDR error: Failed to encode READDIR3args"); rpc_free_pdu(rpc, pdu); return -2; } if (rpc_queue_pdu(rpc, pdu) != 0) { - rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfs/remove call"); + rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/READDIR call"); rpc_free_pdu(rpc, pdu); return -3; } @@ -552,15 +650,8 @@ int rpc_nfs_remove_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, int rpc_nfs_readdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, uint64_t cookie, char *cookieverf, int count, void *private_data) { - struct rpc_pdu *pdu; READDIR3args args; - pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_READDIR, cb, private_data, (zdrproc_t)zdr_READDIR3res, sizeof(READDIR3res)); - if (pdu == NULL) { - rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/readdir call"); - return -1; - } - memset(&args, 0, sizeof(READDIR3args)); args.dir.data.data_len = fh->data.data_len; args.dir.data.data_val = fh->data.data_val; @@ -568,14 +659,27 @@ int rpc_nfs_readdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh memcpy(&args.cookieverf, cookieverf, sizeof(cookieverf3)); args.count = count; - if (zdr_READDIR3args(&pdu->zdr, &args) == 0) { - rpc_set_error(rpc, "ZDR error: Failed to encode READDIR3args"); + return rpc_nfs3_readdir_async(rpc, cb, &args, private_data); +} + +int rpc_nfs3_readdirplus_async(struct rpc_context *rpc, rpc_cb cb, struct READDIRPLUS3args *args, void *private_data) +{ + struct rpc_pdu *pdu; + + pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_READDIRPLUS, cb, private_data, (zdrproc_t)zdr_READDIRPLUS3res, sizeof(READDIRPLUS3res)); + if (pdu == NULL) { + rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/READDIRPLUS call"); + return -1; + } + + if (zdr_READDIRPLUS3args(&pdu->zdr, args) == 0) { + rpc_set_error(rpc, "ZDR error: Failed to encode READDIRPLUS3args"); rpc_free_pdu(rpc, pdu); return -2; } if (rpc_queue_pdu(rpc, pdu) != 0) { - rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfs/readdir call"); + rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/READDIRPLUS call"); rpc_free_pdu(rpc, pdu); return -3; } @@ -585,15 +689,8 @@ int rpc_nfs_readdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh int rpc_nfs_readdirplus_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, uint64_t cookie, char *cookieverf, int count, void *private_data) { - struct rpc_pdu *pdu; READDIRPLUS3args args; - pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_READDIRPLUS, cb, private_data, (zdrproc_t)zdr_READDIRPLUS3res, sizeof(READDIRPLUS3res)); - if (pdu == NULL) { - rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/readdirplus call"); - return -1; - } - memset(&args, 0, sizeof(READDIRPLUS3args)); args.dir.data.data_len = fh->data.data_len; args.dir.data.data_val = fh->data.data_val; @@ -602,43 +699,27 @@ int rpc_nfs_readdirplus_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 args.dircount = count; args.maxcount = count; - if (zdr_READDIRPLUS3args(&pdu->zdr, &args) == 0) { - rpc_set_error(rpc, "ZDR error: Failed to encode READDIRPLUS3args"); - rpc_free_pdu(rpc, pdu); - return -2; - } - - if (rpc_queue_pdu(rpc, pdu) != 0) { - rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfs/readdirplus call"); - rpc_free_pdu(rpc, pdu); - return -3; - } - - return 0; + return rpc_nfs3_readdirplus_async(rpc, cb, &args, private_data); } -int rpc_nfs_fsstat_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data) +int rpc_nfs3_fsstat_async(struct rpc_context *rpc, rpc_cb cb, struct FSSTAT3args *args, void *private_data) { struct rpc_pdu *pdu; - FSSTAT3args args; pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_FSSTAT, cb, private_data, (zdrproc_t)zdr_FSSTAT3res, sizeof(FSSTAT3res)); if (pdu == NULL) { - rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/fsstat call"); + rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/FSSTAT call"); return -1; } - args.fsroot.data.data_len = fh->data.data_len; - args.fsroot.data.data_val = fh->data.data_val; - - if (zdr_FSSTAT3args(&pdu->zdr, &args) == 0) { + if (zdr_FSSTAT3args(&pdu->zdr, args) == 0) { rpc_set_error(rpc, "ZDR error: Failed to encode FSSTAT3args"); rpc_free_pdu(rpc, pdu); return -2; } if (rpc_queue_pdu(rpc, pdu) != 0) { - rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfs/fsstat call"); + rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/FSSTAT call"); rpc_free_pdu(rpc, pdu); return -3; } @@ -646,28 +727,35 @@ int rpc_nfs_fsstat_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, return 0; } -int rpc_nfs_fsinfo_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data) +int rpc_nfs_fsstat_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data) +{ + FSSTAT3args args; + + memset(&args, 0, sizeof(FSSTAT3args)); + args.fsroot.data.data_len = fh->data.data_len; + args.fsroot.data.data_val = fh->data.data_val; + + return rpc_nfs3_fsstat_async(rpc, cb, &args, private_data); +} + +int rpc_nfs3_fsinfo_async(struct rpc_context *rpc, rpc_cb cb, struct FSINFO3args *args, void *private_data) { struct rpc_pdu *pdu; - FSINFO3args args; pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_FSINFO, cb, private_data, (zdrproc_t)zdr_FSINFO3res, sizeof(FSINFO3res)); if (pdu == NULL) { - rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/fsinfo call"); + rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/FSINFO call"); return -1; } - args.fsroot.data.data_len = fh->data.data_len; - args.fsroot.data.data_val = fh->data.data_val; - - if (zdr_FSINFO3args(&pdu->zdr, &args) == 0) { + if (zdr_FSINFO3args(&pdu->zdr, args) == 0) { rpc_set_error(rpc, "ZDR error: Failed to encode FSINFO3args"); rpc_free_pdu(rpc, pdu); return -2; } if (rpc_queue_pdu(rpc, pdu) != 0) { - rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfs/fsinfo call"); + rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/FSINFO call"); rpc_free_pdu(rpc, pdu); return -3; } @@ -675,13 +763,24 @@ int rpc_nfs_fsinfo_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, return 0; } -int rpc_nfs_readlink_async(struct rpc_context *rpc, rpc_cb cb, READLINK3args *args, void *private_data) +int rpc_nfs_fsinfo_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data) +{ + FSINFO3args args; + + memset(&args, 0, sizeof(FSINFO3args)); + args.fsroot.data.data_len = fh->data.data_len; + args.fsroot.data.data_val = fh->data.data_val; + + return rpc_nfs3_fsinfo_async(rpc, cb, fh, private_data); +} + +int rpc_nfs3_readlink_async(struct rpc_context *rpc, rpc_cb cb, READLINK3args *args, void *private_data) { struct rpc_pdu *pdu; pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_READLINK, cb, private_data, (zdrproc_t)zdr_READLINK3res, sizeof(READLINK3res)); if (pdu == NULL) { - rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/readlink call"); + rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/READLINK call"); return -1; } @@ -692,7 +791,7 @@ int rpc_nfs_readlink_async(struct rpc_context *rpc, rpc_cb cb, READLINK3args *ar } if (rpc_queue_pdu(rpc, pdu) != 0) { - rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfs/readlink call"); + rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/READLINK call"); rpc_free_pdu(rpc, pdu); return -3; } @@ -700,14 +799,18 @@ int rpc_nfs_readlink_async(struct rpc_context *rpc, rpc_cb cb, READLINK3args *ar return 0; } +int rpc_nfs_readlink_async(struct rpc_context *rpc, rpc_cb cb, READLINK3args *args, void *private_data) +{ + return rpc_nfs3_readlink_async(rpc, cb, args, private_data); +} -int rpc_nfs_symlink_async(struct rpc_context *rpc, rpc_cb cb, SYMLINK3args *args, void *private_data) +int rpc_nfs3_symlink_async(struct rpc_context *rpc, rpc_cb cb, SYMLINK3args *args, void *private_data) { struct rpc_pdu *pdu; pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_SYMLINK, cb, private_data, (zdrproc_t)zdr_SYMLINK3res, sizeof(SYMLINK3res)); if (pdu == NULL) { - rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/symlink call"); + rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/SYMLINK call"); return -1; } @@ -718,7 +821,7 @@ int rpc_nfs_symlink_async(struct rpc_context *rpc, rpc_cb cb, SYMLINK3args *args } if (rpc_queue_pdu(rpc, pdu) != 0) { - rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfs/symlink call"); + rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/SYMLINK call"); rpc_free_pdu(rpc, pdu); return -3; } @@ -726,36 +829,29 @@ int rpc_nfs_symlink_async(struct rpc_context *rpc, rpc_cb cb, SYMLINK3args *args return 0; } +int rpc_nfs_symlink_async(struct rpc_context *rpc, rpc_cb cb, SYMLINK3args *args, void *private_data) +{ + return rpc_nfs3_symlink_async(rpc, cb, args, private_data); +} - - -int rpc_nfs_rename_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *olddir, char *oldname, struct nfs_fh3 *newdir, char *newname, void *private_data) +int rpc_nfs3_rename_async(struct rpc_context *rpc, rpc_cb cb, struct RENAME3args *args, void *private_data) { struct rpc_pdu *pdu; - RENAME3args args; pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_RENAME, cb, private_data, (zdrproc_t)zdr_RENAME3res, sizeof(RENAME3res)); if (pdu == NULL) { - rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/rename call"); + rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/RENAME call"); return -1; } - memset(&args, 0, sizeof(RENAME3args)); - args.from.dir.data.data_len = olddir->data.data_len; - args.from.dir.data.data_val = olddir->data.data_val; - args.from.name = oldname; - args.to.dir.data.data_len = newdir->data.data_len; - args.to.dir.data.data_val = newdir->data.data_val; - args.to.name = newname; - - if (zdr_RENAME3args(&pdu->zdr, &args) == 0) { + if (zdr_RENAME3args(&pdu->zdr, args) == 0) { rpc_set_error(rpc, "ZDR error: Failed to encode RENAME3args"); rpc_free_pdu(rpc, pdu); return -2; } if (rpc_queue_pdu(rpc, pdu) != 0) { - rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfs/rename call"); + rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/RENAME call"); rpc_free_pdu(rpc, pdu); return -3; } @@ -763,35 +859,39 @@ int rpc_nfs_rename_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *old return 0; } +int rpc_nfs_rename_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *olddir, char *oldname, struct nfs_fh3 *newdir, char *newname, void *private_data) +{ + RENAME3args args; + memset(&args, 0, sizeof(RENAME3args)); + args.from.dir.data.data_len = olddir->data.data_len; + args.from.dir.data.data_val = olddir->data.data_val; + args.from.name = oldname; + args.to.dir.data.data_len = newdir->data.data_len; + args.to.dir.data.data_val = newdir->data.data_val; + args.to.name = newname; + return rpc_nfs3_rename_async(rpc, cb, &args, private_data); +} -int rpc_nfs_link_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *file, struct nfs_fh3 *newdir, char *newname, void *private_data) +int rpc_nfs3_link_async(struct rpc_context *rpc, rpc_cb cb, struct LINK3args *args, void *private_data) { struct rpc_pdu *pdu; - LINK3args args; pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_LINK, cb, private_data, (zdrproc_t)zdr_LINK3res, sizeof(LINK3res)); if (pdu == NULL) { - rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/link call"); + rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for NFS3/LINK call"); return -1; } - memset(&args, 0, sizeof(LINK3args)); - args.file.data.data_len = file->data.data_len; - args.file.data.data_val = file->data.data_val; - args.link.dir.data.data_len = newdir->data.data_len; - args.link.dir.data.data_val = newdir->data.data_val; - args.link.name = newname; - - if (zdr_LINK3args(&pdu->zdr, &args) == 0) { + if (zdr_LINK3args(&pdu->zdr, args) == 0) { rpc_set_error(rpc, "ZDR error: Failed to encode LINK3args"); rpc_free_pdu(rpc, pdu); return -2; } if (rpc_queue_pdu(rpc, pdu) != 0) { - rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfs/link call"); + rpc_set_error(rpc, "Out of memory. Failed to queue pdu for NFS3/LINK call"); rpc_free_pdu(rpc, pdu); return -3; } @@ -799,6 +899,19 @@ int rpc_nfs_link_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *file, return 0; } +int rpc_nfs_link_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *file, struct nfs_fh3 *newdir, char *newname, void *private_data) +{ + LINK3args args; + + memset(&args, 0, sizeof(LINK3args)); + args.file.data.data_len = file->data.data_len; + args.file.data.data_val = file->data.data_val; + args.link.dir.data.data_len = newdir->data.data_len; + args.link.dir.data.data_val = newdir->data.data_val; + args.link.name = newname; + + return rpc_nfs3_link_async(rpc, cb, &args, private_data); +} -- 2.34.1