diff options
author | David Disseldorp <ddiss@samba.org> | 2013-11-18 14:54:36 +0100 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2013-11-22 08:56:45 -0800 |
commit | 8bc4e6a9e0b09c744351e60f66c33c4d22dcfb6e (patch) | |
tree | 967d27f240ae6965dfcdf8103cac1602b9fec2cc /source3/smbd | |
parent | a18e0e3aae7e69705cbf78a3bc73617eef630897 (diff) | |
download | samba-8bc4e6a9e0b09c744351e60f66c33c4d22dcfb6e.tar.gz samba-8bc4e6a9e0b09c744351e60f66c33c4d22dcfb6e.tar.xz samba-8bc4e6a9e0b09c744351e60f66c33c4d22dcfb6e.zip |
s3-smbd: support FILE_ATTRIBUTE_COMPRESSED
The FILE_ATTRIBUTE_COMPRESSED flag is computed based on whether the
filesystem exposes the FILE_FILE_COMPRESSION capability, and whether
SMB_VFS_GET_COMPRESSION() reports that the file or directory is
currently compressed.
Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/dosmode.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c index 93bc8349173..29cd93e0945 100644 --- a/source3/smbd/dosmode.c +++ b/source3/smbd/dosmode.c @@ -21,6 +21,7 @@ #include "includes.h" #include "system/filesys.h" #include "librpc/gen_ndr/ndr_xattr.h" +#include "librpc/gen_ndr/ioctl.h" #include "../libcli/security/security.h" #include "smbd/smbd.h" #include "lib/param/loadparm.h" @@ -50,6 +51,9 @@ static void dos_mode_debug_print(uint32_t mode) if (mode & FILE_ATTRIBUTE_OFFLINE) { DEBUG(8, ("[offline]")); } + if (mode & FILE_ATTRIBUTE_COMPRESSED) { + DEBUG(8, ("[compressed]")); + } DEBUG(8,("\n")); } @@ -646,6 +650,40 @@ static bool set_stat_dos_flags(connection_struct *conn, } #endif /* HAVE_STAT_DOS_FLAGS */ +/* + * check whether a file or directory is flagged as compressed. + */ +static NTSTATUS dos_mode_check_compressed(connection_struct *conn, + struct smb_filename *smb_fname, + bool *is_compressed) +{ + NTSTATUS status; + uint16_t compression_fmt; + TALLOC_CTX *tmp_ctx = talloc_new(NULL); + if (tmp_ctx == NULL) { + status = NT_STATUS_NO_MEMORY; + goto err_out; + } + + status = SMB_VFS_GET_COMPRESSION(conn, tmp_ctx, NULL, smb_fname, + &compression_fmt); + if (!NT_STATUS_IS_OK(status)) { + goto err_ctx_free; + } + + if (compression_fmt == COMPRESSION_FORMAT_LZNT1) { + *is_compressed = true; + } else { + *is_compressed = false; + } + status = NT_STATUS_OK; + +err_ctx_free: + talloc_free(tmp_ctx); +err_out: + return status; +} + /**************************************************************************** Change a unix mode to a dos mode. May also read the create timespec into the stat struct in smb_fname @@ -695,6 +733,15 @@ uint32 dos_mode(connection_struct *conn, struct smb_filename *smb_fname) result |= FILE_ATTRIBUTE_OFFLINE; } + if (conn->fs_capabilities & FILE_FILE_COMPRESSION) { + bool compressed = false; + NTSTATUS status = dos_mode_check_compressed(conn, smb_fname, + &compressed); + if (NT_STATUS_IS_OK(status) && compressed) { + result |= FILE_ATTRIBUTE_COMPRESSED; + } + } + /* Optimization : Only call is_hidden_path if it's not already hidden. */ if (!(result & FILE_ATTRIBUTE_HIDDEN) && |