Skip to content

Commit

Permalink
make mkdir_async take a full MKDIR3args argument
Browse files Browse the repository at this point in the history
  • Loading branch information
sahlberg committed Jan 12, 2012
1 parent bac0bc5 commit 7edc902
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
3 changes: 2 additions & 1 deletion include/libnfs-raw.h
Expand Up @@ -414,7 +414,8 @@ int rpc_nfs_setattr_async(struct rpc_context *rpc, rpc_cb cb, struct SETATTR3arg
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
int rpc_nfs_mkdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *dir, void *private_data);
struct MKDIR3args;
int rpc_nfs_mkdir_async(struct rpc_context *rpc, rpc_cb cb, struct MKDIR3args *args, void *private_data);



Expand Down
12 changes: 10 additions & 2 deletions lib/libnfs.c
Expand Up @@ -1436,10 +1436,18 @@ static void nfs_mkdir_cb(struct rpc_context *rpc _U_, int status, void *command_
static int nfs_mkdir_continue_internal(struct nfs_context *nfs, struct nfs_cb_data *data)
{
char *str = data->continue_data;

MKDIR3args args;

str = &str[strlen(str) + 1];

if (rpc_nfs_mkdir_async(nfs->rpc, nfs_mkdir_cb, &data->fh, str, data) != 0) {
memset(&args, 0, sizeof(MKDIR3args));
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.attributes.mode.set_it = 1;
args.attributes.mode.set_mode3_u.mode = 0755;

if (rpc_nfs_mkdir_async(nfs->rpc, nfs_mkdir_cb, &args, data) != 0) {
rpc_set_error(nfs->rpc, "RPC error: Failed to send MKDIR call for %s", data->path);
data->cb(-ENOMEM, nfs, rpc_get_error(nfs->rpc), data->private_data);
free_nfs_cb_data(data);
Expand Down
12 changes: 2 additions & 10 deletions nfs/nfs.c
Expand Up @@ -342,25 +342,17 @@ int rpc_nfs_setattr_async(struct rpc_context *rpc, rpc_cb cb, SETATTR3args *args



int rpc_nfs_mkdir_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, char *dir, void *private_data)
int rpc_nfs_mkdir_async(struct rpc_context *rpc, rpc_cb cb, MKDIR3args *args, void *private_data)
{
struct rpc_pdu *pdu;
MKDIR3args args;

pdu = rpc_allocate_pdu(rpc, NFS_PROGRAM, NFS_V3, NFS3_MKDIR, cb, private_data, (xdrproc_t)xdr_MKDIR3res, sizeof(MKDIR3res));
if (pdu == NULL) {
rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfs/setattr call");
return -1;
}

memset(&args, 0, sizeof(MKDIR3args));
args.where.dir.data.data_len = fh->data.data_len;
args.where.dir.data.data_val = fh->data.data_val;
args.where.name = dir;
args.attributes.mode.set_it = 1;
args.attributes.mode.set_mode3_u.mode = 0755;

if (xdr_MKDIR3args(&pdu->xdr, &args) == 0) {
if (xdr_MKDIR3args(&pdu->xdr, args) == 0) {
rpc_set_error(rpc, "XDR error: Failed to encode MKDIR3args");
rpc_free_pdu(rpc, pdu);
return -2;
Expand Down

0 comments on commit 7edc902

Please sign in to comment.