linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Add get/set compression support to smbinfo
@ 2019-04-11  2:23 Ronnie Sahlberg
  2019-04-11  2:23 ` [PATCH 1/2] smbinfo: add GETCOMPRESSION support Ronnie Sahlberg
  2019-04-11  2:23 ` [PATCH 2/2] smbinfo: Add SETCOMPRESSION support Ronnie Sahlberg
  0 siblings, 2 replies; 6+ messages in thread
From: Ronnie Sahlberg @ 2019-04-11  2:23 UTC (permalink / raw)
  To: linux-cifs; +Cc: Steve French, Pavel Shilovsky

Pavel,
Two small patches to add get/set compression support to smbinfo.

The second patch will not work until we get fsctl passthrough support
for writing data to the server into cifs.ko.
I sent a patch to cifs.ko to the list.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] smbinfo: add GETCOMPRESSION support
  2019-04-11  2:23 [PATCH 0/2] Add get/set compression support to smbinfo Ronnie Sahlberg
@ 2019-04-11  2:23 ` Ronnie Sahlberg
  2019-05-07 22:54   ` Pavel Shilovsky
  2019-04-11  2:23 ` [PATCH 2/2] smbinfo: Add SETCOMPRESSION support Ronnie Sahlberg
  1 sibling, 1 reply; 6+ messages in thread
From: Ronnie Sahlberg @ 2019-04-11  2:23 UTC (permalink / raw)
  To: linux-cifs; +Cc: Steve French, Pavel Shilovsky, Ronnie Sahlberg

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 4bc503a..db569b2 100644
--- a/smbinfo.c
+++ b/smbinfo.c
@@ -87,6 +87,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"
@@ -243,6 +245,50 @@ fsctlgetobjid(int f)
 }
 
 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)
 {
 	uint32_t access_flags;
@@ -1118,6 +1164,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 0c96050..ca99b07 100644
--- a/smbinfo.rst
+++ b/smbinfo.rst
@@ -64,6 +64,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.13.6


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] smbinfo: Add SETCOMPRESSION support
  2019-04-11  2:23 [PATCH 0/2] Add get/set compression support to smbinfo Ronnie Sahlberg
  2019-04-11  2:23 ` [PATCH 1/2] smbinfo: add GETCOMPRESSION support Ronnie Sahlberg
@ 2019-04-11  2:23 ` Ronnie Sahlberg
  2019-04-17 21:47   ` Pavel Shilovsky
  1 sibling, 1 reply; 6+ messages in thread
From: Ronnie Sahlberg @ 2019-04-11  2:23 UTC (permalink / raw)
  To: linux-cifs; +Cc: Steve French, Pavel Shilovsky, Ronnie Sahlberg

Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
 smbinfo.c   | 28 ++++++++++++++++++++++++++++
 smbinfo.rst |  5 +++++
 2 files changed, 33 insertions(+)

diff --git a/smbinfo.c b/smbinfo.c
index db569b2..b87cca4 100644
--- a/smbinfo.c
+++ b/smbinfo.c
@@ -89,6 +89,8 @@ usage(char *name)
 		"      Prints the objectid of the file and GUID of the underlying volume.\n"
 		"  getcompression:\n"
 		"      Prints the compression setting for the file.\n"
+		"  setcompression <0|1|2>:\n"
+		"      Sets the compression level for the file.\n"
 		"  list-snapshots:\n"
 		"      List the previous versions of the volume that backs this file.\n"
 		"  quota:\n"
@@ -289,6 +291,30 @@ getcompression(int f)
 }
 
 static void
+setcompression(int f, uint16_t level)
+{
+	struct smb_query_info *qi;
+
+	qi = malloc(sizeof(struct smb_query_info) + 2);
+	memset(qi, 0, sizeof(qi) + 2);
+	qi->info_type = 0x9c040;
+	qi->file_info_class = 0;
+	qi->additional_information = 0;
+	qi->output_buffer_length = 2;
+	qi->flags = PASSTHRU_FSCTL;
+
+	level = htole16(level);
+	memcpy(&qi[1], &level, 2);
+
+	if (ioctl(f, CIFS_QUERY_INFO, qi) < 0) {
+		fprintf(stderr, "ioctl failed with %s\n", strerror(errno));
+		exit(1);
+	}
+
+	free(qi);
+}
+
+static void
 print_fileaccessinfo(uint8_t *sd, int type)
 {
 	uint32_t access_flags;
@@ -1166,6 +1192,8 @@ int main(int argc, char *argv[])
 		fsctlgetobjid(f);
 	else if (!strcmp(argv[optind], "getcompression"))
 		getcompression(f);
+	else if (!strcmp(argv[optind], "setcompression"))
+		setcompression(f, strtol(argv[optind + 2], NULL, 10));
 	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 ca99b07..af97b7f 100644
--- a/smbinfo.rst
+++ b/smbinfo.rst
@@ -66,6 +66,11 @@ COMMAND
 
 `getcompression`: Prints the compression setting for the file.
 
+`setcompression <0|1|2>`: Sets the compression setting for the file.
+- 0 No compression
+- 1 Default compression
+- 2 LZNT1
+
 `list-snapshots`: Lists the previous versions of the volume that backs this file
 
 `quota`: Print the quota for the volume in the form
-- 
2.13.6


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] smbinfo: Add SETCOMPRESSION support
  2019-04-11  2:23 ` [PATCH 2/2] smbinfo: Add SETCOMPRESSION support Ronnie Sahlberg
@ 2019-04-17 21:47   ` Pavel Shilovsky
  2019-05-07 22:45     ` Pavel Shilovsky
  0 siblings, 1 reply; 6+ messages in thread
From: Pavel Shilovsky @ 2019-04-17 21:47 UTC (permalink / raw)
  To: Ronnie Sahlberg; +Cc: linux-cifs, Steve French, Pavel Shilovsky

ср, 10 апр. 2019 г. в 19:24, Ronnie Sahlberg <lsahlber@redhat.com>:
>
> Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
> ---
>  smbinfo.c   | 28 ++++++++++++++++++++++++++++
>  smbinfo.rst |  5 +++++
>  2 files changed, 33 insertions(+)
>
> diff --git a/smbinfo.c b/smbinfo.c
> index db569b2..b87cca4 100644
> --- a/smbinfo.c
> +++ b/smbinfo.c
> @@ -89,6 +89,8 @@ usage(char *name)
>                 "      Prints the objectid of the file and GUID of the underlying volume.\n"
>                 "  getcompression:\n"
>                 "      Prints the compression setting for the file.\n"
> +               "  setcompression <0|1|2>:\n"
> +               "      Sets the compression level for the file.\n"
>                 "  list-snapshots:\n"
>                 "      List the previous versions of the volume that backs this file.\n"
>                 "  quota:\n"
> @@ -289,6 +291,30 @@ getcompression(int f)
>  }
>
>  static void
> +setcompression(int f, uint16_t level)
> +{
> +       struct smb_query_info *qi;
> +
> +       qi = malloc(sizeof(struct smb_query_info) + 2);
> +       memset(qi, 0, sizeof(qi) + 2);
> +       qi->info_type = 0x9c040;
> +       qi->file_info_class = 0;
> +       qi->additional_information = 0;
> +       qi->output_buffer_length = 2;
> +       qi->flags = PASSTHRU_FSCTL;
> +
> +       level = htole16(level);
> +       memcpy(&qi[1], &level, 2);
> +
> +       if (ioctl(f, CIFS_QUERY_INFO, qi) < 0) {
> +               fprintf(stderr, "ioctl failed with %s\n", strerror(errno));
> +               exit(1);
> +       }
> +
> +       free(qi);
> +}
> +
> +static void
>  print_fileaccessinfo(uint8_t *sd, int type)
>  {
>         uint32_t access_flags;
> @@ -1166,6 +1192,8 @@ int main(int argc, char *argv[])
>                 fsctlgetobjid(f);
>         else if (!strcmp(argv[optind], "getcompression"))
>                 getcompression(f);
> +       else if (!strcmp(argv[optind], "setcompression"))
> +               setcompression(f, strtol(argv[optind + 2], NULL, 10));
>         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 ca99b07..af97b7f 100644
> --- a/smbinfo.rst
> +++ b/smbinfo.rst
> @@ -66,6 +66,11 @@ COMMAND
>
>  `getcompression`: Prints the compression setting for the file.
>
> +`setcompression <0|1|2>`: Sets the compression setting for the file.
> +- 0 No compression
> +- 1 Default compression
> +- 2 LZNT1

0, 1 and 2 don't look obvious, how about "no", "default", "lznt1"?
--
Best regards,
Pavel Shilovsky

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] smbinfo: Add SETCOMPRESSION support
  2019-04-17 21:47   ` Pavel Shilovsky
@ 2019-05-07 22:45     ` Pavel Shilovsky
  0 siblings, 0 replies; 6+ messages in thread
From: Pavel Shilovsky @ 2019-05-07 22:45 UTC (permalink / raw)
  To: Ronnie Sahlberg; +Cc: linux-cifs, Steve French, Pavel Shilovsky

ср, 17 апр. 2019 г. в 14:47, Pavel Shilovsky <piastryyy@gmail.com>:
>
> ср, 10 апр. 2019 г. в 19:24, Ronnie Sahlberg <lsahlber@redhat.com>:
> >
> > Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
> > ---
> >  smbinfo.c   | 28 ++++++++++++++++++++++++++++
> >  smbinfo.rst |  5 +++++
> >  2 files changed, 33 insertions(+)
> >
> > diff --git a/smbinfo.c b/smbinfo.c
> > index db569b2..b87cca4 100644
> > --- a/smbinfo.c
> > +++ b/smbinfo.c
> > @@ -89,6 +89,8 @@ usage(char *name)
> >                 "      Prints the objectid of the file and GUID of the underlying volume.\n"
> >                 "  getcompression:\n"
> >                 "      Prints the compression setting for the file.\n"
> > +               "  setcompression <0|1|2>:\n"
> > +               "      Sets the compression level for the file.\n"
> >                 "  list-snapshots:\n"
> >                 "      List the previous versions of the volume that backs this file.\n"
> >                 "  quota:\n"
> > @@ -289,6 +291,30 @@ getcompression(int f)
> >  }
> >
> >  static void
> > +setcompression(int f, uint16_t level)
> > +{
> > +       struct smb_query_info *qi;
> > +
> > +       qi = malloc(sizeof(struct smb_query_info) + 2);
> > +       memset(qi, 0, sizeof(qi) + 2);
> > +       qi->info_type = 0x9c040;
> > +       qi->file_info_class = 0;
> > +       qi->additional_information = 0;
> > +       qi->output_buffer_length = 2;
> > +       qi->flags = PASSTHRU_FSCTL;
> > +
> > +       level = htole16(level);
> > +       memcpy(&qi[1], &level, 2);
> > +
> > +       if (ioctl(f, CIFS_QUERY_INFO, qi) < 0) {
> > +               fprintf(stderr, "ioctl failed with %s\n", strerror(errno));
> > +               exit(1);
> > +       }
> > +
> > +       free(qi);
> > +}
> > +
> > +static void
> >  print_fileaccessinfo(uint8_t *sd, int type)
> >  {
> >         uint32_t access_flags;
> > @@ -1166,6 +1192,8 @@ int main(int argc, char *argv[])
> >                 fsctlgetobjid(f);
> >         else if (!strcmp(argv[optind], "getcompression"))
> >                 getcompression(f);
> > +       else if (!strcmp(argv[optind], "setcompression"))
> > +               setcompression(f, strtol(argv[optind + 2], NULL, 10));
> >         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 ca99b07..af97b7f 100644
> > --- a/smbinfo.rst
> > +++ b/smbinfo.rst
> > @@ -66,6 +66,11 @@ COMMAND
> >
> >  `getcompression`: Prints the compression setting for the file.
> >
> > +`setcompression <0|1|2>`: Sets the compression setting for the file.
> > +- 0 No compression
> > +- 1 Default compression
> > +- 2 LZNT1
>
> 0, 1 and 2 don't look obvious, how about "no", "default", "lznt1"?
> --
> Best regards,
> Pavel Shilovsky

I tried it and I think the syntax is strange:

smbinfo setcompression /mnt/test/file 1

How about this:

smbinfo setcompression [-c <0|1|2>] <filename> ?

-c would be 1 by default, so smbinfo setcompression <filename> will
set a default compression. Also as I mentioned before specifying "no",
"default" and "lznt1" looks better to me but I am ok with integers
too.

--
Best regards,
Pavel Shilovsky

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] smbinfo: add GETCOMPRESSION support
  2019-04-11  2:23 ` [PATCH 1/2] smbinfo: add GETCOMPRESSION support Ronnie Sahlberg
@ 2019-05-07 22:54   ` Pavel Shilovsky
  0 siblings, 0 replies; 6+ messages in thread
From: Pavel Shilovsky @ 2019-05-07 22:54 UTC (permalink / raw)
  To: Ronnie Sahlberg; +Cc: linux-cifs, Steve French, Pavel Shilovsky

ср, 10 апр. 2019 г. в 19:23, Ronnie Sahlberg <lsahlber@redhat.com>:
>
> 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 4bc503a..db569b2 100644
> --- a/smbinfo.c
> +++ b/smbinfo.c
> @@ -87,6 +87,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"
> @@ -243,6 +245,50 @@ fsctlgetobjid(int f)
>  }
>
>  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)
>  {
>         uint32_t access_flags;
> @@ -1118,6 +1164,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 0c96050..ca99b07 100644
> --- a/smbinfo.rst
> +++ b/smbinfo.rst
> @@ -64,6 +64,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.13.6
>

Merged into "next" branch. Thanks.

--
Best regards,
Pavel Shilovsky

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-05-07 22:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-11  2:23 [PATCH 0/2] Add get/set compression support to smbinfo Ronnie Sahlberg
2019-04-11  2:23 ` [PATCH 1/2] smbinfo: add GETCOMPRESSION support Ronnie Sahlberg
2019-05-07 22:54   ` Pavel Shilovsky
2019-04-11  2:23 ` [PATCH 2/2] smbinfo: Add SETCOMPRESSION support Ronnie Sahlberg
2019-04-17 21:47   ` Pavel Shilovsky
2019-05-07 22:45     ` Pavel Shilovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).