From c985c015f2be8d3f87a4b89923c83755feb393f2 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Thu, 12 Jan 2012 15:31:49 +1100 Subject: [PATCH] change crate_async low level function to take a full RATE3args structure as argument instead of just name and mode --- include/libnfs-raw.h | 3 ++- lib/libnfs.c | 14 ++++++++++++-- nfs/nfs.c | 11 +---------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/include/libnfs-raw.h b/include/libnfs-raw.h index 6698030..df940c5 100644 --- a/include/libnfs-raw.h +++ b/include/libnfs-raw.h @@ -453,7 +453,8 @@ int rpc_nfs_rmdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete. * data is NULL. */ -int rpc_nfs_create_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *name, int mode, void *private_data); +struct CREATE3args; +int rpc_nfs_create_async(struct rpc_context *rpc, rpc_cb cb, struct CREATE3args *args, void *private_data); /* diff --git a/lib/libnfs.c b/lib/libnfs.c index 8c7ad4e..8fe84b8 100644 --- a/lib/libnfs.c +++ b/lib/libnfs.c @@ -1649,10 +1649,20 @@ static void nfs_creat_1_cb(struct rpc_context *rpc _U_, int status, void *comman static int nfs_creat_continue_internal(struct nfs_context *nfs, struct nfs_cb_data *data) { char *str = data->continue_data; - + CREATE3args args; + str = &str[strlen(str) + 1]; - if (rpc_nfs_create_async(nfs->rpc, nfs_creat_1_cb, &data->fh, str, data->continue_int, data) != 0) { + + memset(&args, 0, sizeof(CREATE3args)); + args.where.dir.data.data_len = data->fh.data.data_len; + args.where.dir.data.data_val = data->fh.data.data_val; + args.where.name = str; + args.how.mode = UNCHECKED; + args.how.createhow3_u.obj_attributes.mode.set_it = 1; + args.how.createhow3_u.obj_attributes.mode.set_mode3_u.mode = data->continue_int; + + if (rpc_nfs_create_async(nfs->rpc, nfs_creat_1_cb, &args, data) != 0) { rpc_set_error(nfs->rpc, "RPC error: Failed to send CREATE call for %s/%s", data->path, str); 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 48f9008..5945252 100644 --- a/nfs/nfs.c +++ b/nfs/nfs.c @@ -411,10 +411,9 @@ int rpc_nfs_rmdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, -int rpc_nfs_create_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *file, int mode, void *private_data) +int rpc_nfs_create_async(struct rpc_context *rpc, rpc_cb cb, CREATE3args *args, void *private_data) { struct rpc_pdu *pdu; - CREATE3args args; pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_CREATE, cb, private_data, (xdrproc_t)xdr_CREATE3res, sizeof(CREATE3res)); if (pdu == NULL) { @@ -422,14 +421,6 @@ int rpc_nfs_create_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, return -1; } - memset(&args, 0, sizeof(CREATE3args)); - args.where.dir.data.data_len = fh->data.data_len; - args.where.dir.data.data_val = fh->data.data_val; - args.where.name = file; - args.how.mode = UNCHECKED; - args.how.createhow3_u.obj_attributes.mode.set_it = 1; - args.how.createhow3_u.obj_attributes.mode.set_mode3_u.mode = mode; - if (xdr_CREATE3args(&pdu->xdr, &args) == 0) { rpc_set_error(rpc, "XDR error: Failed to encode CREATE3args"); rpc_free_pdu(rpc, pdu); -- 2.34.1