From afccae852f231e8982276fa53614b3dc999b6bf8 Mon Sep 17 00:00:00 2001 From: Pavel Shilovsky Date: Wed, 3 Apr 2019 22:42:10 +0000 Subject: [PATCH 20/36] mount.cifs: detect GMT format of snapshot version In order to provide an easy way to access snapshots a GMT token string should be allowed as a "snapshot" mount option argument, not SMB 100-nanoseconds time only. Detect if the argument is in GMT format and convert it to SMB 100-nanoseconds time before passing to the kernel. Signed-off-by: Pavel Shilovsky Reviewed-by: Paulo Alcantara (cherry picked from commit c52be345de22669c53a6ec41c28914183bf65d09) Signed-off-by: Sachin Prabhu --- mount.cifs.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 47 insertions(+), 7 deletions(-) diff --git a/mount.cifs.c b/mount.cifs.c index c6a1bd6..b3235e4 100644 --- a/mount.cifs.c +++ b/mount.cifs.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #ifdef HAVE_SYS_FSUID_H @@ -161,10 +162,16 @@ #define OPT_BKUPUID 30 #define OPT_BKUPGID 31 #define OPT_NOFAIL 32 +#define OPT_SNAPSHOT 33 #define MNT_TMP_FILE "/.mtab.cifs.XXXXXX" -/* struct for holding parsed mount info for use by privleged process */ +#define GMT_NAME_LEN 24 /* length of a @GMT- name */ +#define GMT_FORMAT "@GMT-%Y.%m.%d-%H.%M.%S" + +#define NTFS_TIME_OFFSET ((unsigned long long)(369*365 + 89) * 24 * 3600 * 10000000) + +/* struct for holding parsed mount info for use by privileged process */ struct parsed_mount_info { unsigned long flags; char host[NI_MAXHOST + 1]; @@ -271,9 +278,9 @@ static int mount_usage(FILE * stream) fprintf(stream, "\n\tcache=,nounix,cifsacl,sec=,"); fprintf(stream, - "\n\tsign,seal,fsc,snapshot=