From 1058201ef0ba4ea34e71f07a3e3582c19ee93a1e Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Tue, 31 May 2011 23:50:18 +1000 Subject: [PATCH] Add support for async version of NFS/FSINFO3 call --- include/libnfs-raw.h | 17 +++++++++++++++++ nfs/nfs.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/include/libnfs-raw.h b/include/libnfs-raw.h index f3a413f..b141e61 100644 --- a/include/libnfs-raw.h +++ b/include/libnfs-raw.h @@ -462,6 +462,23 @@ int rpc_nfs_fsstat_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, +/* + * Call NFS/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. + * + * When the callback is invoked, status indicates the result: + * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon. + * data is FSINFO3res + * RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon. + * data is the error string. + * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete. + * data is NULL. + */ +int rpc_nfs_fsinfo_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data); + + /* * Call NFS/READLINK diff --git a/nfs/nfs.c b/nfs/nfs.c index 34c0859..c21046a 100644 --- a/nfs/nfs.c +++ b/nfs/nfs.c @@ -537,6 +537,34 @@ 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) +{ + struct rpc_pdu *pdu; + FSINFO3args args; + + pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_FSINFO, cb, private_data, (xdrproc_t)xdr_FSINFO3res, sizeof(FSINFO3res)); + if (pdu == NULL) { + rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/fsinfo call"); + return -1; + } + + args.fsroot.data.data_len = fh->data.data_len; + args.fsroot.data.data_val = fh->data.data_val; + + if (xdr_FSINFO3args(&pdu->xdr, &args) == 0) { + rpc_set_error(rpc, "XDR 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_free_pdu(rpc, pdu); + return -3; + } + + return 0; +} int rpc_nfs_readlink_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, void *private_data) { -- 2.34.1