[PATCH 2/7] cifs: Add mount option -o reparse=none

Pali Rohár posted 7 patches 1 month, 3 weeks ago
[PATCH 2/7] cifs: Add mount option -o reparse=none
Posted by Pali Rohár 1 month, 3 weeks ago
This new mount option allows to completely disable creating new reparse
points. When -o sfu or -o mfsymlinks is not specified then creating any
special file (fifo, socket, symlink, block and char) will fail with
-EOPNOTSUPP error.

Signed-off-by: Pali Rohár <pali@kernel.org>
---
 fs/smb/client/cifsglob.h   | 3 +++
 fs/smb/client/fs_context.c | 4 ++++
 fs/smb/client/fs_context.h | 1 +
 3 files changed, 8 insertions(+)

diff --git a/fs/smb/client/cifsglob.h b/fs/smb/client/cifsglob.h
index 367f0ac6400d..7632d2ba5390 100644
--- a/fs/smb/client/cifsglob.h
+++ b/fs/smb/client/cifsglob.h
@@ -154,6 +154,7 @@ enum securityEnum {
 };
 
 enum cifs_reparse_type {
+	CIFS_REPARSE_TYPE_NONE, /* disable creating new reparse points */
 	CIFS_REPARSE_TYPE_NATIVE, /* native symlinks only */
 	CIFS_REPARSE_TYPE_NATIVE_NFS, /* native for symlinks, nfs for others */
 	CIFS_REPARSE_TYPE_NATIVE_WSL, /* native for symlinks, wsl for others */
@@ -165,6 +166,8 @@ enum cifs_reparse_type {
 static inline const char *cifs_reparse_type_str(enum cifs_reparse_type type)
 {
 	switch (type) {
+	case CIFS_REPARSE_TYPE_NONE:
+		return "none";
 	case CIFS_REPARSE_TYPE_NATIVE:
 		return "native";
 	case CIFS_REPARSE_TYPE_NATIVE_NFS:
diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
index e5de84912e3d..3e402961cc95 100644
--- a/fs/smb/client/fs_context.c
+++ b/fs/smb/client/fs_context.c
@@ -303,6 +303,7 @@ cifs_parse_cache_flavor(struct fs_context *fc, char *value, struct smb3_fs_conte
 
 static const match_table_t reparse_flavor_tokens = {
 	{ Opt_reparse_default,	"default" },
+	{ Opt_reparse_none,	"none" },
 	{ Opt_reparse_native,	"native" },
 	{ Opt_reparse_native_nfs, "native+nfs" },
 	{ Opt_reparse_native_wsl, "native+wsl" },
@@ -320,6 +321,9 @@ static int parse_reparse_flavor(struct fs_context *fc, char *value,
 	case Opt_reparse_default:
 		ctx->reparse_type = CIFS_REPARSE_TYPE_DEFAULT;
 		break;
+	case Opt_reparse_none:
+		ctx->reparse_type = CIFS_REPARSE_TYPE_NONE;
+		break;
 	case Opt_reparse_native:
 		ctx->reparse_type = CIFS_REPARSE_TYPE_NATIVE;
 		break;
diff --git a/fs/smb/client/fs_context.h b/fs/smb/client/fs_context.h
index 1011176ba3b7..5db06de2ed35 100644
--- a/fs/smb/client/fs_context.h
+++ b/fs/smb/client/fs_context.h
@@ -43,6 +43,7 @@ enum {
 
 enum cifs_reparse_parm {
 	Opt_reparse_default,
+	Opt_reparse_none,
 	Opt_reparse_native,
 	Opt_reparse_native_nfs,
 	Opt_reparse_native_wsl,
-- 
2.20.1