pvfs_rename: implement RAW_RENAME_NTTRANS as noop as w2k3
[samba.git] / source4 / ntvfs / posix / pvfs_rename.c
index 3c60c00247442829cb37443325772b74185ebc0c..5c2a627084c6c98bdeddfc9d8e51623d1139a1a1 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 {
@@ -134,12 +140,12 @@ static const char *pvfs_resolve_wildcard_component(TALLOC_CTX *mem_ctx,
   resolve a wildcard rename pattern.
 */
 static const char *pvfs_resolve_wildcard(TALLOC_CTX *mem_ctx, 
+                                        struct smb_iconv_convenience *iconv_convenience,
                                         const char *fname, 
                                         const char *pattern)
 {
        const char *base1, *base2;
        const char *ext1, *ext2;
-       struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm);
        char *p;
 
        /* break into base part plus extension */
@@ -274,7 +280,7 @@ static NTSTATUS pvfs_rename_one(struct pvfs_state *pvfs,
        NTSTATUS status;
 
        /* resolve the wildcard pattern for this name */
-       fname2 = pvfs_resolve_wildcard(mem_ctx, fname1, fname2);
+       fname2 = pvfs_resolve_wildcard(mem_ctx, lp_iconv_convenience(pvfs->ntvfs->ctx->lp_ctx), fname1, fname2);
        if (fname2 == NULL) {
                return NT_STATUS_NO_MEMORY;
        }
@@ -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;
 
@@ -569,6 +568,9 @@ static NTSTATUS pvfs_rename_nt(struct ntvfs_module_context *ntvfs,
 NTSTATUS pvfs_rename(struct ntvfs_module_context *ntvfs,
                     struct ntvfs_request *req, union smb_rename *ren)
 {
+       struct pvfs_state *pvfs = ntvfs->private_data;
+       struct pvfs_file *f;
+
        switch (ren->generic.level) {
        case RAW_RENAME_RENAME:
                return pvfs_rename_mv(ntvfs, req, ren);
@@ -576,6 +578,15 @@ NTSTATUS pvfs_rename(struct ntvfs_module_context *ntvfs,
        case RAW_RENAME_NTRENAME:
                return pvfs_rename_nt(ntvfs, req, ren);
 
+       case RAW_RENAME_NTTRANS:
+               f = pvfs_find_fd(pvfs, req, ren->nttrans.in.file.ntvfs);
+               if (!f) {
+                       return NT_STATUS_INVALID_HANDLE;
+               }
+
+               /* wk23 ignores the request */
+               return NT_STATUS_OK;
+
        default:
                break;
        }