pvfs_rename: move odb_rename() onto pvfs_do_rename()
authorStefan Metzmacher <metze@samba.org>
Sat, 1 Mar 2008 09:05:25 +0000 (10:05 +0100)
committerStefan Metzmacher <metze@samba.org>
Sat, 1 Mar 2008 09:29:56 +0000 (10:29 +0100)
metze

source/ntvfs/posix/pvfs_rename.c
source/ntvfs/posix/pvfs_setfileinfo.c

index 185e35f8007268f58c28726b0217c05f244e5954..29b2d030059a2ca5e8a110de8c0cc559308e2f7f 100644 (file)
 /*
   do a file rename, and send any notify triggers
 */
-NTSTATUS pvfs_do_rename(struct pvfs_state *pvfs, const struct pvfs_filename *name1, 
+NTSTATUS pvfs_do_rename(struct pvfs_state *pvfs,
+                       struct odb_lock *lck,
+                       const struct pvfs_filename *name1,
                        const char *name2)
 {
        const char *r1, *r2;
        uint32_t mask;
+       NTSTATUS status;
 
        if (rename(name1->full_name, name2) == -1) {
                return pvfs_map_errno(pvfs, errno);
        }
 
+       status = odb_rename(lck, name2);
+       NT_STATUS_NOT_OK_RETURN(status);
+
        if (name1->dos.attrib & FILE_ATTRIBUTE_DIRECTORY) {
                mask = FILE_NOTIFY_CHANGE_DIR_NAME;
        } else {
@@ -315,11 +321,7 @@ static NTSTATUS pvfs_rename_one(struct pvfs_state *pvfs,
                return NT_STATUS_NO_MEMORY;
        }
 
-       status = pvfs_do_rename(pvfs, name1, fname2);
-
-       if (NT_STATUS_IS_OK(status)) {
-               status = odb_rename(lck, fname2);
-       }
+       status = pvfs_do_rename(pvfs, lck, name1, fname2);
 
 failed:
        talloc_free(mem_ctx);
@@ -448,9 +450,9 @@ static NTSTATUS pvfs_rename_mv(struct ntvfs_module_context *ntvfs,
                return status;
        }
 
-       status = pvfs_do_rename(pvfs, name1, name2->full_name);
-       if (NT_STATUS_IS_OK(status)) {
-               status = odb_rename(lck, name2->full_name);
+       status = pvfs_do_rename(pvfs, lck, name1, name2->full_name);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
        }
        
        return NT_STATUS_OK;
@@ -532,10 +534,7 @@ static NTSTATUS pvfs_rename_nt(struct ntvfs_module_context *ntvfs,
        case RENAME_FLAG_RENAME:
                status = pvfs_access_check_parent(pvfs, req, name2, SEC_DIR_ADD_FILE);
                NT_STATUS_NOT_OK_RETURN(status);
-               status = pvfs_do_rename(pvfs, name1, name2->full_name);
-               if (NT_STATUS_IS_OK(status)) {
-                       status = odb_rename(lck, name2->full_name);
-               }
+               status = pvfs_do_rename(pvfs, lck, name1, name2->full_name);
                NT_STATUS_NOT_OK_RETURN(status);
                break;
 
index 5ac9cedc48177c13a9f07d38b841516d3d28a9c7..ad47fe90c9bf643ae3e01c5a1b64d984e2aca4cc 100644 (file)
@@ -171,10 +171,7 @@ static NTSTATUS pvfs_setfileinfo_rename(struct pvfs_state *pvfs,
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
        }
 
-       status = pvfs_do_rename(pvfs, name, name2->full_name);
-       if (NT_STATUS_IS_OK(status)) {
-               status = odb_rename(lck, name2->full_name);
-       }
+       status = pvfs_do_rename(pvfs, lck, name, name2->full_name);
        talloc_free(lck);
        NT_STATUS_NOT_OK_RETURN(status);
        if (NT_STATUS_IS_OK(status)) {