X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=lib%2Flibnfs.c;h=06eea35a343c9a3d63a0bfe72f02b3761bd85131;hb=17ef62fad77b6fa5682dbb5a33ff5a608274dce4;hp=f4e8b0136c5b53b171cb4807153f00c19d3e3736;hpb=f4b9cb0e0f3775612130933709b4f326e562bbb0;p=deb_libnfs.git 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; +}