diff mbox series

Add support for smb3 alias/fstype in mount.cifs.c

Message ID 20191113170126.23372-1-kdsouza@redhat.com
State New
Headers show
Series Add support for smb3 alias/fstype in mount.cifs.c | expand

Commit Message

Kenneth Dsouza Nov. 13, 2019, 5:01 p.m. UTC
As we will slowly move towards smb3 filesystem,
supporting through "mount -t smb3" is important.

Signed-off-by: Kenneth D'souza <kdsouza@redhat.com>
---
 Makefile.am    |  4 ++++
 mount.cifs.c   |  8 +++++++-
 mount.cifs.rst | 12 +++++++++---
 3 files changed, 20 insertions(+), 4 deletions(-)

Comments

Pavel Shilovsky Dec. 13, 2019, 12:25 a.m. UTC | #1
ср, 13 нояб. 2019 г. в 09:01, Kenneth D'souza <kdsouza@redhat.com>:
>
> As we will slowly move towards smb3 filesystem,
> supporting through "mount -t smb3" is important.
>
> Signed-off-by: Kenneth D'souza <kdsouza@redhat.com>
> ---
>  Makefile.am    |  4 ++++
>  mount.cifs.c   |  8 +++++++-
>  mount.cifs.rst | 12 +++++++++---
>  3 files changed, 20 insertions(+), 4 deletions(-)
>
> diff --git a/Makefile.am b/Makefile.am
> index 8291b99..1af2573 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -111,3 +111,7 @@ CLEANFILES += $(rst_man_pages)
>  endif
>
>  SUBDIRS = contrib
> +
> +install-exec-hook:
> +       (cd $(ROOTSBINDIR) && ln -sf mount.cifs mount.smb3)
> +       (cd $(man8dir) && ln -sf mount.cifs.8 mount.smb3.8)
> diff --git a/mount.cifs.c b/mount.cifs.c
> index 6935fe1..0ed9d0a 100644
> --- a/mount.cifs.c
> +++ b/mount.cifs.c
> @@ -192,7 +192,7 @@ struct parsed_mount_info {
>  };
>
>  static const char *thisprogram;
> -static const char *cifs_fstype = "cifs";
> +static const char *cifs_fstype;
>
>  static int parse_unc(const char *unc_name, struct parsed_mount_info *parsed_info);
>
> @@ -1986,6 +1986,12 @@ int main(int argc, char **argv)
>         if (thisprogram == NULL)
>                 thisprogram = "mount.cifs";
>
> +       if(strcmp(thisprogram, "mount.cifs") == 0)
> +               cifs_fstype = "cifs";
> +
> +        if(strcmp(thisprogram, "mount.smb3") == 0)
> +              cifs_fstype = "smb3";
> +
>         /* allocate parsed_info as shared anonymous memory range */
>         parsed_info = mmap((void *)0, sizeof(*parsed_info), PROT_READ | PROT_WRITE,
>                            MAP_ANONYMOUS | MAP_SHARED, -1, 0);
> diff --git a/mount.cifs.rst b/mount.cifs.rst
> index ee5086c..67ec629 100644
> --- a/mount.cifs.rst
> +++ b/mount.cifs.rst
> @@ -1,6 +1,6 @@
> -==========
> -mount.cifs
> -==========
> +=====================
> +mount.cifs mount.smb3
> +=====================
>
>  --------------------------------------------------
>  mount using the Common Internet File System (CIFS)
> @@ -23,6 +23,12 @@ protocol and is supported by most Windows servers, Azure (cloud storage),
>  Macs and many other commercial servers and Network Attached Storage
>  appliances as well as by the popular Open Source server Samba.
>
> +``mount.smb3`` mounts only SMB3 filesystem. It is usually invoked
> +indirectly by the mount(8) command when using the "-t smb3" option.
> +The ``smb3`` filesystem type was added in kernel-4.18 and above.
> +It works in a similar fashion as mount.cifs except it passes filesystem
> +type as smb3.
> +
>  The mount.cifs utility attaches the UNC name (exported network
>  resource) specified as service (using ``//server/share`` syntax, where
>  "server" is the server name or IP address and "share" is the name of
> --
> 2.21.0
>

Merged, thanks.
--
Best regards,
Pavel Shilovsky
diff mbox series

Patch

diff --git a/Makefile.am b/Makefile.am
index 8291b99..1af2573 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -111,3 +111,7 @@  CLEANFILES += $(rst_man_pages)
 endif
 
 SUBDIRS = contrib
+
+install-exec-hook:
+	(cd $(ROOTSBINDIR) && ln -sf mount.cifs mount.smb3)
+	(cd $(man8dir) && ln -sf mount.cifs.8 mount.smb3.8)
diff --git a/mount.cifs.c b/mount.cifs.c
index 6935fe1..0ed9d0a 100644
--- a/mount.cifs.c
+++ b/mount.cifs.c
@@ -192,7 +192,7 @@  struct parsed_mount_info {
 };
 
 static const char *thisprogram;
-static const char *cifs_fstype = "cifs";
+static const char *cifs_fstype;
 
 static int parse_unc(const char *unc_name, struct parsed_mount_info *parsed_info);
 
@@ -1986,6 +1986,12 @@  int main(int argc, char **argv)
 	if (thisprogram == NULL)
 		thisprogram = "mount.cifs";
 
+	if(strcmp(thisprogram, "mount.cifs") == 0)
+               cifs_fstype = "cifs";
+
+        if(strcmp(thisprogram, "mount.smb3") == 0)
+              cifs_fstype = "smb3";
+
 	/* allocate parsed_info as shared anonymous memory range */
 	parsed_info = mmap((void *)0, sizeof(*parsed_info), PROT_READ | PROT_WRITE,
 			   MAP_ANONYMOUS | MAP_SHARED, -1, 0);
diff --git a/mount.cifs.rst b/mount.cifs.rst
index ee5086c..67ec629 100644
--- a/mount.cifs.rst
+++ b/mount.cifs.rst
@@ -1,6 +1,6 @@ 
-==========
-mount.cifs
-==========
+=====================
+mount.cifs mount.smb3
+=====================
 
 --------------------------------------------------
 mount using the Common Internet File System (CIFS)
@@ -23,6 +23,12 @@  protocol and is supported by most Windows servers, Azure (cloud storage),
 Macs and many other commercial servers and Network Attached Storage
 appliances as well as by the popular Open Source server Samba.
 
+``mount.smb3`` mounts only SMB3 filesystem. It is usually invoked
+indirectly by the mount(8) command when using the "-t smb3" option.
+The ``smb3`` filesystem type was added in kernel-4.18 and above.
+It works in a similar fashion as mount.cifs except it passes filesystem
+type as smb3.
+
 The mount.cifs utility attaches the UNC name (exported network
 resource) specified as service (using ``//server/share`` syntax, where
 "server" is the server name or IP address and "share" is the name of