]> git.itanic.dy.fi Git - linux-stable/commitdiff
remove directory incorrectly tries to set delete on close on non-empty directories
authorSteve French <smfrench@gmail.com>
Fri, 13 May 2016 02:20:36 +0000 (21:20 -0500)
committerJiri Slaby <jslaby@suse.cz>
Wed, 15 Jun 2016 07:32:02 +0000 (09:32 +0200)
commit 897fba1172d637d344f009d700f7eb8a1fa262f1 upstream.

Wrong return code was being returned on SMB3 rmdir of
non-empty directory.

For SMB3 (unlike for cifs), we attempt to delete a directory by
set of delete on close flag on the open. Windows clients set
this flag via a set info (SET_FILE_DISPOSITION to set this flag)
which properly checks if the directory is empty.

With this patch on smb3 mounts we correctly return
 "DIRECTORY NOT EMPTY"
on attempts to remove a non-empty directory.

Signed-off-by: Steve French <steve.french@primarydata.com>
Acked-by: Sachin Prabhu <sprabhu@redhat.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
fs/cifs/smb2glob.h
fs/cifs/smb2inode.c
fs/cifs/smb2pdu.c
fs/cifs/smb2proto.h

index bc0bb9c34f72aaef62383760a06fa55c72d5b70b..0ffa180943357c5514b5ae025f61e4b19f574f38 100644 (file)
@@ -44,6 +44,7 @@
 #define SMB2_OP_DELETE 7
 #define SMB2_OP_HARDLINK 8
 #define SMB2_OP_SET_EOF 9
+#define SMB2_OP_RMDIR 10
 
 /* Used when constructing chained read requests. */
 #define CHAINED_REQUEST 1
index 215f8d3e3e5305095521f33857de77eda44f59c1..f970c5d5b2534cf06a58cb2bc14fddc1d4d3f4aa 100644 (file)
@@ -80,6 +80,10 @@ smb2_open_op_close(const unsigned int xid, struct cifs_tcon *tcon,
                 * SMB2_open() call.
                 */
                break;
+       case SMB2_OP_RMDIR:
+               tmprc = SMB2_rmdir(xid, tcon, fid.persistent_fid,
+                                  fid.volatile_fid);
+               break;
        case SMB2_OP_RENAME:
                tmprc = SMB2_rename(xid, tcon, fid.persistent_fid,
                                    fid.volatile_fid, (__le16 *)data);
@@ -191,8 +195,8 @@ smb2_rmdir(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
           struct cifs_sb_info *cifs_sb)
 {
        return smb2_open_op_close(xid, tcon, cifs_sb, name, DELETE, FILE_OPEN,
-                                 CREATE_NOT_FILE | CREATE_DELETE_ON_CLOSE,
-                                 NULL, SMB2_OP_DELETE);
+                                 CREATE_NOT_FILE,
+                                 NULL, SMB2_OP_RMDIR);
 }
 
 int
index a47ac835145bac59ed05d69bbd77b761b33e0fde..439cb86ed488a26cbf427e1b1393fd973bc5523d 100644 (file)
@@ -2253,6 +2253,22 @@ SMB2_rename(const unsigned int xid, struct cifs_tcon *tcon,
        return rc;
 }
 
+int
+SMB2_rmdir(const unsigned int xid, struct cifs_tcon *tcon,
+                 u64 persistent_fid, u64 volatile_fid)
+{
+       __u8 delete_pending = 1;
+       void *data;
+       unsigned int size;
+
+       data = &delete_pending;
+       size = 1; /* sizeof __u8 */
+
+       return send_set_info(xid, tcon, persistent_fid, volatile_fid,
+                       current->tgid, FILE_DISPOSITION_INFORMATION, 1, &data,
+                       &size);
+}
+
 int
 SMB2_set_hardlink(const unsigned int xid, struct cifs_tcon *tcon,
                  u64 persistent_fid, u64 volatile_fid, __le16 *target_file)
index d18b19ec1145ce9a6e60a1b1abede010cbf6cc81..5793f3e39a31667a61a275005c2303ae5f59c387 100644 (file)
@@ -133,6 +133,8 @@ extern int SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
 extern int SMB2_rename(const unsigned int xid, struct cifs_tcon *tcon,
                       u64 persistent_fid, u64 volatile_fid,
                       __le16 *target_file);
+extern int SMB2_rmdir(const unsigned int xid, struct cifs_tcon *tcon,
+                     u64 persistent_fid, u64 volatile_fid);
 extern int SMB2_set_hardlink(const unsigned int xid, struct cifs_tcon *tcon,
                             u64 persistent_fid, u64 volatile_fid,
                             __le16 *target_file);