diff --git a/daemon/open.c b/daemon/open.c index 9323311..4197fce 100644 --- a/daemon/open.c +++ b/daemon/open.c @@ -790,7 +790,7 @@ static int handle_close(nfs41_upcall *upcall) if (args->renamed) { dprintf(1, "removing a renamed file %s\n", name->name); - create_silly_rename(&state->path, &state->file.fh, name); + create_silly_rename(&state->path, name); status = do_nfs41_close(state); if (status) goto out; diff --git a/daemon/setattr.c b/daemon/setattr.c index cad4b79..863551f 100644 --- a/daemon/setattr.c +++ b/daemon/setattr.c @@ -209,7 +209,7 @@ static int handle_nfs41_rename(setattr_upcall_args *args) path_fh_init(&dst_dir, &dst_path); fh_copy(&dst_dir.fh, &state->parent.fh); - create_silly_rename(&dst_path, &state->file.fh, &dst_name); + create_silly_rename(&dst_path, &dst_name); dprintf(1, "silly rename: %s -> %s\n", src_name->name, dst_name.name); /* break any delegations and truncate before silly rename */ diff --git a/daemon/util.c b/daemon/util.c index 86f9e77..dd42175 100644 --- a/daemon/util.c +++ b/daemon/util.c @@ -347,35 +347,35 @@ void path_fh_copy( fh_copy(&dst->fh, &src->fh); } +/* DWORD MAX_DWORD = 4294967295 -- max string for the timestamp */ int create_silly_rename( IN nfs41_abs_path *path, - IN const nfs41_fh *fh, OUT nfs41_component *silly) { const char *end = path->path + NFS41_MAX_PATH_LEN; - const unsigned short extra_len = 2 + 2*(unsigned short)fh->len; - char name[NFS41_MAX_COMPONENT_LEN+1]; - char *tmp; - uint32_t i; + char name[NFS41_MAX_COMPONENT_LEN+1], *tmp, stime[13]; int status = NO_ERROR; + const DWORD ntime = GetTickCount(); - if (path->len + extra_len >= NFS41_MAX_PATH_LEN) { + StringCchPrintf(stime, 13, "%u", ntime); + if (path->len + 13 >= NFS41_MAX_PATH_LEN) { status = ERROR_BUFFER_OVERFLOW; goto out; } last_component(path->path, path->path + path->len, silly); + if (silly->len + 13 > NFS41_MAX_COMPONENT_LEN) { + status = ERROR_BUFFER_OVERFLOW; + goto out; + } + StringCchCopyNA(name, NFS41_MAX_COMPONENT_LEN+1, silly->name, silly->len); tmp = (char*)silly->name; - StringCchPrintf(tmp, end - tmp, ".%s.", name); - tmp += silly->len + 2; + StringCchPrintf(tmp, end - tmp, ".%s.%s", name, stime); - for (i = 0; i < fh->len; i++, tmp += 2) - StringCchPrintf(tmp, end - tmp, "%02x", fh->fh[i]); - - path->len = path->len + extra_len; - silly->len = silly->len + extra_len; + path->len = (unsigned short)strlen(path->path); + silly->len = (unsigned short)strlen(silly->name); out: return status; -} +} \ No newline at end of file diff --git a/daemon/util.h b/daemon/util.h index 07acf15..0cf2c4a 100644 --- a/daemon/util.h +++ b/daemon/util.h @@ -153,7 +153,6 @@ static __inline void nfstime_abs( int create_silly_rename( IN nfs41_abs_path *path, - IN const nfs41_fh *fh, OUT nfs41_component *silly); bool_t multi_addr_find(