smbd/ioctl: match WS2016 ReFS get compression behaviour
authorDavid Disseldorp <ddiss@samba.org>
Mon, 3 Oct 2016 23:09:37 +0000 (01:09 +0200)
committerJeremy Allison <jra@samba.org>
Thu, 6 Oct 2016 00:30:17 +0000 (02:30 +0200)
ReFS doesn't support compression, but responds to get-compression FSCTLs
with a successful COMPRESSION_FORMAT_NONE response. set-compression
results in NT_STATUS_NOT_SUPPORTED.

This commit modifies Samba to match the ReFS behaviour, when run atop
a VFS that doesn't expose compression support.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=12144

Reported-by: Nick Barrett
Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/smb2_ioctl_filesys.c

index 6e4a7856b06288b82bf633eb2915755805b1d586..55ce3f24c01bb1b6508da238bd1d29e4b9205c4b 100644 (file)
@@ -48,19 +48,24 @@ static NTSTATUS fsctl_get_cmprn(TALLOC_CTX *mem_ctx,
 
        /* Windows doesn't check for SEC_FILE_READ_ATTRIBUTE permission here */
 
-       if ((fsp->conn->fs_capabilities & FILE_FILE_COMPRESSION) == 0) {
-               DEBUG(4, ("FS does not advertise compression support\n"));
-               return NT_STATUS_NOT_SUPPORTED;
-       }
-
        ZERO_STRUCT(cmpr_state);
-       status = SMB_VFS_GET_COMPRESSION(fsp->conn,
-                                        mem_ctx,
-                                        fsp,
-                                        NULL,
-                                        &cmpr_state.format);
-       if (!NT_STATUS_IS_OK(status)) {
-               return status;
+       if (fsp->conn->fs_capabilities & FILE_FILE_COMPRESSION) {
+               status = SMB_VFS_GET_COMPRESSION(fsp->conn,
+                                                mem_ctx,
+                                                fsp,
+                                                NULL,
+                                                &cmpr_state.format);
+               if (!NT_STATUS_IS_OK(status)) {
+                       return status;
+               }
+       } else {
+               /*
+                * bso#12144: The underlying filesystem doesn't support
+                * compression, so we should respond with "not-compressed"
+                * (like WS2016 ReFS) instead of STATUS_NOT_SUPPORTED or
+                * NT_STATUS_INVALID_DEVICE_REQUEST.
+                */
+               cmpr_state.format = COMPRESSION_FORMAT_NONE;
        }
 
        ndr_ret = ndr_push_struct_blob(&output, mem_ctx,