cifs-utils/0005-smbinfo-add-GETCOMPRESSION-support.patch
Paulo Alcantara 9f24f9e262 Accepting request 723800 from home:aaptel:cifs-utils-6.9
- add for-next changes, update changelog date
  * add 0001-smbinfo-Improve-help-usage-and-add-h-option.patch
  * add 0002-smbinfo-Add-bash-completion-support-for-smbinfo.patch
  * add 0003-getcifsacl-Add-support-to-accept-more-paths.patch
  * add 0004-getcifsacl-Fix-usage-message-to-include-multiple-fil.patch
  * add 0005-smbinfo-add-GETCOMPRESSION-support.patch
  * add 0006-getcifsacl-Add-support-for-R-recursive-option.patch
  * add 0007-smbinfo-add-bash-completion-support-for-getcompressi.patch
  * add 0008-mount.cifs.c-fix-memory-leaks-in-main-func.patch
  * add 0009-Zero-fill-the-allocated-memory-for-new-struct-cifs_n.patch
  * add 0010-Zero-fill-the-allocated-memory-for-a-new-ACE.patch

OBS-URL: https://build.opensuse.org/request/show/723800
OBS-URL: https://build.opensuse.org/package/show/network:samba:STABLE/cifs-utils?expand=0&rev=172
2019-08-15 21:02:09 +00:00

101 lines
2.5 KiB
Diff

From 1e4fca25948d52fc29410963663f3af72275bcb6 Mon Sep 17 00:00:00 2001
From: Ronnie Sahlberg <lsahlber@redhat.com>
Date: Thu, 11 Apr 2019 12:23:06 +1000
Subject: [PATCH] smbinfo: add GETCOMPRESSION support
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
smbinfo.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
smbinfo.rst | 2 ++
2 files changed, 50 insertions(+)
diff --git a/smbinfo.c b/smbinfo.c
index 6e258c2..b4d497b 100644
--- a/smbinfo.c
+++ b/smbinfo.c
@@ -89,6 +89,8 @@ usage(char *name)
" Prints FileStandardInfo for a cifs file.\n"
" fsctl-getobjid:\n"
" Prints the objectid of the file and GUID of the underlying volume.\n"
+ " getcompression:\n"
+ " Prints the compression setting for the file.\n"
" list-snapshots:\n"
" List the previous versions of the volume that backs this file.\n"
" quota:\n"
@@ -252,6 +254,50 @@ fsctlgetobjid(int f)
free(qi);
}
+static void
+print_getcompression(uint8_t *sd)
+{
+ uint16_t u16;
+
+ memcpy(&u16, &sd[0], 2);
+ u16 = le16toh(u16);
+
+ printf("Compression: ");
+ switch (u16) {
+ case 0:
+ printf("(0) NONE\n");
+ break;
+ case 2:
+ printf("(2) LZNT1\n");
+ break;
+ default:
+ printf("(%d) UNKNOWN\n", u16);
+ break;
+ }
+}
+
+static void
+getcompression(int f)
+{
+ struct smb_query_info *qi;
+
+ qi = malloc(sizeof(struct smb_query_info) + 2);
+ memset(qi, 0, sizeof(qi) + 2);
+ qi->info_type = 0x9003c;
+ qi->file_info_class = 0;
+ qi->additional_information = 0;
+ qi->input_buffer_length = 2;
+ qi->flags = PASSTHRU_FSCTL;
+
+ if (ioctl(f, CIFS_QUERY_INFO, qi) < 0) {
+ fprintf(stderr, "ioctl failed with %s\n", strerror(errno));
+ exit(1);
+ }
+ print_getcompression((uint8_t *)(&qi[1]));
+
+ free(qi);
+}
+
static void
print_fileaccessinfo(uint8_t *sd, int type)
{
@@ -1135,6 +1181,8 @@ int main(int argc, char *argv[])
filestandardinfo(f);
else if (!strcmp(argv[optind], "fsctl-getobjid"))
fsctlgetobjid(f);
+ else if (!strcmp(argv[optind], "getcompression"))
+ getcompression(f);
else if (!strcmp(argv[optind], "list-snapshots"))
list_snapshots(f);
else if (!strcmp(argv[optind], "quota"))
diff --git a/smbinfo.rst b/smbinfo.rst
index be4c829..500ce0e 100644
--- a/smbinfo.rst
+++ b/smbinfo.rst
@@ -67,6 +67,8 @@ COMMAND
`fsctl-getobjid`: Prints the ObjectID
+`getcompression`: Prints the compression setting for the file.
+
`list-snapshots`: Lists the previous versions of the volume that backs this file
`quota`: Print the quota for the volume in the form
--
2.16.4