s3-vfs: Fix stream_depot vfs module on btrfs.
authorAndreas Schneider <asn@samba.org>
Fri, 8 Nov 2013 14:10:03 +0000 (15:10 +0100)
committerJeremy Allison <jra@samba.org>
Fri, 8 Nov 2013 17:42:20 +0000 (09:42 -0800)
Checking if the directory is empty using 'nlink == 2' only checks if
there are no subdirectories. It doesn't indicate if there are files in
the directory. However checking link count for no subdirectories is
wrong and applications shouldn't rely on it, see:

https://lkml.org/lkml/2012/2/1/756

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_streams_depot.c

index 3ada92eeb5ee3417cc5b7261657341575e4c3343..f33d998b4e02753e5d8c4243683834735e586073 100644 (file)
@@ -665,6 +665,7 @@ static int streams_depot_unlink(vfs_handle_struct *handle,
 static int streams_depot_rmdir(vfs_handle_struct *handle, const char *path)
 {
        struct smb_filename *smb_fname_base = NULL;
+       char *dirname;
        int ret = -1;
 
        DEBUG(10, ("streams_depot_rmdir called for %s\n", path));
@@ -690,15 +691,14 @@ static int streams_depot_rmdir(vfs_handle_struct *handle, const char *path)
                return -1;
        }
 
-       if (smb_fname_base->st.st_ex_nlink == 2) {
-               char *dirname = stream_dir(handle, smb_fname_base,
-                                          &smb_fname_base->st, false);
-
-               if (dirname != NULL) {
-                       SMB_VFS_NEXT_RMDIR(handle, dirname);
-               }
-               TALLOC_FREE(dirname);
+       dirname = stream_dir(handle,
+                            smb_fname_base,
+                            &smb_fname_base->st,
+                            false);
+       if (dirname != NULL) {
+               SMB_VFS_NEXT_RMDIR(handle, dirname);
        }
+       TALLOC_FREE(dirname);
 
        ret = SMB_VFS_NEXT_RMDIR(handle, path);