From 83cab313f0d3a9d2bcbaa8e4d0658170e0a1a4ed Mon Sep 17 00:00:00 2001 From: Olga Kornievskaia Date: Tue, 20 Mar 2012 16:37:53 -0400 Subject: [PATCH] propagate attrs on dir creation --- daemon/nfs41_ops.c | 13 +++++++------ daemon/nfs41_ops.h | 3 ++- daemon/open.c | 16 +++++++--------- daemon/symlink.c | 3 ++- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/daemon/nfs41_ops.c b/daemon/nfs41_ops.c index 903ecba..efb2e32 100644 --- a/daemon/nfs41_ops.c +++ b/daemon/nfs41_ops.c @@ -532,7 +532,8 @@ int nfs41_create( IN uint32_t mode, IN OPTIONAL const char *symlink, IN nfs41_path_fh *parent, - OUT nfs41_path_fh *file) + OUT nfs41_path_fh *file, + OUT nfs41_file_info *info) { int status; nfs41_compound compound; @@ -548,7 +549,7 @@ int nfs41_create( nfs41_getattr_args getattr_args; nfs41_getattr_res getattr_res, pgetattr_res; bitmap4 attr_request; - nfs41_file_info file_info, dir_info; + nfs41_file_info dir_info; nfs41_savefh_res savefh_res; nfs41_restorefh_res restorefh_res; @@ -585,7 +586,7 @@ int nfs41_create( compound_add_op(&compound, OP_GETATTR, &getattr_args, &getattr_res); getattr_args.attr_request = &attr_request; getattr_res.obj_attributes.attr_vals_len = NFS4_OPAQUE_LIMIT; - getattr_res.info = &file_info; + getattr_res.info = info; compound_add_op(&compound, OP_RESTOREFH, NULL, &restorefh_res); @@ -602,7 +603,7 @@ int nfs41_create( goto out; /* fill in the file handle's fileid and superblock */ - file->fh.fileid = file_info.fileid; + file->fh.fileid = info->fileid; file->fh.superblock = parent->fh.superblock; /* update the attributes of the parent directory */ @@ -612,12 +613,12 @@ int nfs41_create( parent->fh.fileid, &dir_info); /* add the new file handle and attributes to the name cache */ - memcpy(&file_info.attrmask, &getattr_res.obj_attributes.attrmask, + memcpy(&info->attrmask, &getattr_res.obj_attributes.attrmask, sizeof(bitmap4)); AcquireSRWLockShared(&file->path->lock); nfs41_name_cache_insert(session_name_cache(session), file->path->path, &file->name, &file->fh, - &file_info, &create_res.cinfo, OPEN_DELEGATE_NONE); + info, &create_res.cinfo, OPEN_DELEGATE_NONE); ReleaseSRWLockShared(&file->path->lock); nfs41_superblock_space_changed(file->fh.superblock); diff --git a/daemon/nfs41_ops.h b/daemon/nfs41_ops.h index faa247b..d8cccce 100644 --- a/daemon/nfs41_ops.h +++ b/daemon/nfs41_ops.h @@ -1057,7 +1057,8 @@ int nfs41_create( IN uint32_t mode, IN OPTIONAL const char *symlink, IN nfs41_path_fh *parent, - OUT nfs41_path_fh *file); + OUT nfs41_path_fh *file, + OUT nfs41_file_info *info); int nfs41_close( IN nfs41_session *session, diff --git a/daemon/open.c b/daemon/open.c index af7500b..9323311 100644 --- a/daemon/open.c +++ b/daemon/open.c @@ -615,20 +615,13 @@ supersede_retry: if (create == OPEN4_CREATE && (args->create_opts & FILE_DIRECTORY_FILE)) { status = nfs41_create(state->session, NF4DIR, args->mode, NULL, - &state->parent, &state->file); - args->std_info.Directory = 1; + &state->parent, &state->file, &info); args->created = status == NFS4_OK ? TRUE : FALSE; } else { status = open_or_delegate(state, create, createhowmode, args->mode, TRUE, &info); - if (status == NFS4_OK) { - nfs_to_basic_info(&info, &args->basic_info); - nfs_to_standard_info(&info, &args->std_info); - args->mode = info.mode; - args->changeattr = info.change; - if (state->delegation.state) + if (status == NFS4_OK && state->delegation.state) args->deleg_type = state->delegation.state->state.type; - } } if (status) { dprintf(1, "%s failed with %s\n", (create == OPEN4_CREATE && @@ -638,6 +631,11 @@ supersede_retry: goto supersede_retry; status = nfs_to_windows_error(status, ERROR_FILE_NOT_FOUND); goto out_free_state; + } else { + nfs_to_basic_info(&info, &args->basic_info); + nfs_to_standard_info(&info, &args->std_info); + args->mode = info.mode; + args->changeattr = info.change; } } upcall->state_ref = state; diff --git a/daemon/symlink.c b/daemon/symlink.c index 2b57825..c02cbc1 100644 --- a/daemon/symlink.c +++ b/daemon/symlink.c @@ -225,6 +225,7 @@ static int handle_symlink(nfs41_upcall *upcall) int status = NO_ERROR; if (args->set) { + nfs41_file_info info; /* don't send windows slashes to the server */ char *p; for (p = args->target_set; *p; p++) if (*p == '\\') *p = '/'; @@ -241,7 +242,7 @@ static int handle_symlink(nfs41_upcall *upcall) /* create the symlink */ status = nfs41_create(state->session, NF4LNK, 0777, - args->target_set, &state->parent, &state->file); + args->target_set, &state->parent, &state->file, &info); if (status) { eprintf("nfs41_create() for symlink=%s failed with %s\n", args->target_set, nfs_error_string(status));