From: Ronnie Sahlberg Date: Tue, 31 May 2011 14:08:29 +0000 (+1000) Subject: Read the max read/write sizes supported when connecting to NFS X-Git-Tag: upstream/1.9.6^2~413 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=17ef62fad77b6fa5682dbb5a33ff5a608274dce4;p=deb_libnfs.git Read the max read/write sizes supported when connecting to NFS and store in the nfs context. Privide accessor functions to read the max sizes. --- diff --git a/include/libnfs.h b/include/libnfs.h index 2debb8b..8defc10 100644 --- a/include/libnfs.h +++ b/include/libnfs.h @@ -67,6 +67,16 @@ void nfs_destroy_context(struct nfs_context *nfs); struct nfsfh; +/* + * Get the maximum supported READ3 size by the server + */ +size_t nfs_get_readmax(struct nfs_context *nfs); + +/* + * Get the maximum supported WRITE3 size by the server + */ +size_t nfs_get_writemax(struct nfs_context *nfs); + /* * MOUNT THE EXPORT diff --git a/lib/libnfs.c b/lib/libnfs.c index f4e8b01..06eea35 100644 --- a/lib/libnfs.c +++ b/lib/libnfs.c @@ -63,6 +63,8 @@ struct nfs_context { char *server; char *export; struct nfs_fh3 rootfh; + size_t readmax; + size_t writemax; }; struct nfs_cb_data; @@ -178,7 +180,7 @@ void free_nfs_cb_data(struct nfs_cb_data *data) -static void nfs_mount_9_cb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data) +static void nfs_mount_10_cb(struct rpc_context *rpc _U_, int status, void *command_data, void *private_data) { struct nfs_cb_data *data = private_data; struct nfs_context *nfs = data->nfs; @@ -198,10 +200,11 @@ static void nfs_mount_9_cb(struct rpc_context *rpc _U_, int status, void *comman free_nfs_cb_data(data); } -static void nfs_mount_8_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data) +static void nfs_mount_9_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data) { struct nfs_cb_data *data = private_data; struct nfs_context *nfs = data->nfs; + FSINFO3res *res = command_data; if (status == RPC_STATUS_ERROR) { data->cb(-EFAULT, nfs, command_data, data->private_data); @@ -214,14 +217,40 @@ static void nfs_mount_8_cb(struct rpc_context *rpc, int status, void *command_da return; } + nfs->readmax = res->FSINFO3res_u.resok.rtmax; + nfs->writemax = res->FSINFO3res_u.resok.wtmax; - if (rpc_nfs_getattr_async(rpc, nfs_mount_9_cb, &nfs->rootfh, data) != 0) { + if (rpc_nfs_getattr_async(rpc, nfs_mount_10_cb, &nfs->rootfh, data) != 0) { data->cb(-ENOMEM, nfs, command_data, data->private_data); free_nfs_cb_data(data); return; } } +static void nfs_mount_8_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data) +{ + struct nfs_cb_data *data = private_data; + struct nfs_context *nfs = data->nfs; + + if (status == RPC_STATUS_ERROR) { + data->cb(-EFAULT, nfs, command_data, data->private_data); + free_nfs_cb_data(data); + return; + } + if (status == RPC_STATUS_CANCEL) { + data->cb(-EINTR, nfs, "Command was cancelled", data->private_data); + free_nfs_cb_data(data); + return; + } + + if (rpc_nfs_fsinfo_async(rpc, nfs_mount_9_cb, &nfs->rootfh, data) != 0) { + data->cb(-ENOMEM, nfs, command_data, data->private_data); + free_nfs_cb_data(data); + return; + } +} + + static void nfs_mount_7_cb(struct rpc_context *rpc, int status, void *command_data, void *private_data) { struct nfs_cb_data *data = private_data; @@ -2703,3 +2732,20 @@ off_t nfs_get_current_offset(struct nfsfh *nfsfh) return nfsfh->offset; } + + +/* + * Get the maximum supported READ3 size by the server + */ +size_t nfs_get_readmax(struct nfs_context *nfs) +{ + return nfs->readmax; +} + +/* + * Get the maximum supported WRITE3 size by the server + */ +size_t nfs_get_writemax(struct nfs_context *nfs) +{ + return nfs->writemax; +}