vfs: Simplify streams_xattr_unlinkat()
authorVolker Lendecke <vl@samba.org>
Fri, 11 Feb 2022 09:20:54 +0000 (10:20 +0100)
committerJeremy Allison <jra@samba.org>
Fri, 11 Feb 2022 20:54:37 +0000 (20:54 +0000)
It would be a logic error to call rmdir on a stream. This simplifies
the logic a bit.

Signed-off-by: Volker Lendecke <vl@samba.org>
source3/modules/vfs_streams_xattr.c

index 156a1d6513370656863e1196483758e95fa02598..48fc1cd134b2b52ec20260930dec5d3be485dedf 100644 (file)
@@ -474,7 +474,7 @@ static int streams_xattr_close(vfs_handle_struct *handle,
        return ret;
 }
 
-static int streams_xattr_unlink_internal(vfs_handle_struct *handle,
+static int streams_xattr_unlinkat(vfs_handle_struct *handle,
                        struct files_struct *dirfsp,
                        const struct smb_filename *smb_fname,
                        int flags)
@@ -490,6 +490,9 @@ static int streams_xattr_unlink_internal(vfs_handle_struct *handle,
                                        flags);
        }
 
+       /* A stream can never be rmdir'ed */
+       SMB_ASSERT((flags & AT_REMOVEDIR) == 0);
+
        status = streams_xattr_get_name(handle, talloc_tos(),
                                        smb_fname->stream_name, &xattr_name);
        if (!NT_STATUS_IS_OK(status)) {
@@ -514,26 +517,6 @@ static int streams_xattr_unlink_internal(vfs_handle_struct *handle,
        return ret;
 }
 
-static int streams_xattr_unlinkat(vfs_handle_struct *handle,
-                       struct files_struct *dirfsp,
-                       const struct smb_filename *smb_fname,
-                       int flags)
-{
-       int ret;
-       if (flags & AT_REMOVEDIR) {
-               ret = SMB_VFS_NEXT_UNLINKAT(handle,
-                               dirfsp,
-                               smb_fname,
-                               flags);
-       } else {
-               ret = streams_xattr_unlink_internal(handle,
-                               dirfsp,
-                               smb_fname,
-                               flags);
-       }
-       return ret;
-}
-
 static int streams_xattr_renameat(vfs_handle_struct *handle,
                                files_struct *srcfsp,
                                const struct smb_filename *smb_fname_src,