Skip to content

Commit c1468c7

Browse files
Paulo Alcantaragregkh
authored andcommitted
smb: client: introduce reparse mount option
[ Upstream commit eb90e8e ] Allow the user to create special files and symlinks by choosing between WSL and NFS reparse points via 'reparse={nfs,wsl}' mount options. If unset or 'reparse=default', the client will default to creating them via NFS reparse points. Creating WSL reparse points isn't supported yet, so simply return error when attempting to mount with 'reparse=wsl' for now. Signed-off-by: Paulo Alcantara <[email protected]> Signed-off-by: Steve French <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 1e60bc0 commit c1468c7

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

fs/smb/client/cifsglob.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ enum securityEnum {
153153
Kerberos, /* Kerberos via SPNEGO */
154154
};
155155

156+
enum cifs_reparse_type {
157+
CIFS_REPARSE_TYPE_NFS,
158+
CIFS_REPARSE_TYPE_WSL,
159+
CIFS_REPARSE_TYPE_DEFAULT = CIFS_REPARSE_TYPE_NFS,
160+
};
161+
156162
struct session_key {
157163
unsigned int len;
158164
char *response;

fs/smb/client/connect.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2805,6 +2805,8 @@ compare_mount_options(struct super_block *sb, struct cifs_mnt_data *mnt_data)
28052805
return 0;
28062806
if (old->ctx->closetimeo != new->ctx->closetimeo)
28072807
return 0;
2808+
if (old->ctx->reparse_type != new->ctx->reparse_type)
2809+
return 0;
28082810

28092811
return 1;
28102812
}

fs/smb/client/fs_context.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ const struct fs_parameter_spec smb3_fs_parameters[] = {
175175
fsparam_string("vers", Opt_vers),
176176
fsparam_string("sec", Opt_sec),
177177
fsparam_string("cache", Opt_cache),
178+
fsparam_string("reparse", Opt_reparse),
178179

179180
/* Arguments that should be ignored */
180181
fsparam_flag("guest", Opt_ignore),
@@ -297,6 +298,35 @@ cifs_parse_cache_flavor(struct fs_context *fc, char *value, struct smb3_fs_conte
297298
return 0;
298299
}
299300

301+
static const match_table_t reparse_flavor_tokens = {
302+
{ Opt_reparse_default, "default" },
303+
{ Opt_reparse_nfs, "nfs" },
304+
{ Opt_reparse_wsl, "wsl" },
305+
{ Opt_reparse_err, NULL },
306+
};
307+
308+
static int parse_reparse_flavor(struct fs_context *fc, char *value,
309+
struct smb3_fs_context *ctx)
310+
{
311+
substring_t args[MAX_OPT_ARGS];
312+
313+
switch (match_token(value, reparse_flavor_tokens, args)) {
314+
case Opt_reparse_default:
315+
ctx->reparse_type = CIFS_REPARSE_TYPE_DEFAULT;
316+
break;
317+
case Opt_reparse_nfs:
318+
ctx->reparse_type = CIFS_REPARSE_TYPE_NFS;
319+
break;
320+
case Opt_reparse_wsl:
321+
cifs_errorf(fc, "unsupported reparse= option: %s\n", value);
322+
return 1;
323+
default:
324+
cifs_errorf(fc, "bad reparse= option: %s\n", value);
325+
return 1;
326+
}
327+
return 0;
328+
}
329+
300330
#define DUP_CTX_STR(field) \
301331
do { \
302332
if (ctx->field) { \
@@ -1595,6 +1625,10 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
15951625
case Opt_rdma:
15961626
ctx->rdma = true;
15971627
break;
1628+
case Opt_reparse:
1629+
if (parse_reparse_flavor(fc, param->string, ctx))
1630+
goto cifs_parse_mount_err;
1631+
break;
15981632
}
15991633
/* case Opt_ignore: - is ignored as expected ... */
16001634

@@ -1683,6 +1717,7 @@ int smb3_init_fs_context(struct fs_context *fc)
16831717
ctx->backupgid_specified = false; /* no backup intent for a group */
16841718

16851719
ctx->retrans = 1;
1720+
ctx->reparse_type = CIFS_REPARSE_TYPE_DEFAULT;
16861721

16871722
/*
16881723
* short int override_uid = -1;

fs/smb/client/fs_context.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ enum {
4141
Opt_cache_err
4242
};
4343

44+
enum cifs_reparse_parm {
45+
Opt_reparse_default,
46+
Opt_reparse_nfs,
47+
Opt_reparse_wsl,
48+
Opt_reparse_err
49+
};
50+
4451
enum cifs_sec_param {
4552
Opt_sec_krb5,
4653
Opt_sec_krb5i,
@@ -149,6 +156,7 @@ enum cifs_param {
149156
Opt_vers,
150157
Opt_sec,
151158
Opt_cache,
159+
Opt_reparse,
152160

153161
/* Mount options to be ignored */
154162
Opt_ignore,
@@ -275,6 +283,7 @@ struct smb3_fs_context {
275283
char *leaf_fullpath;
276284
struct cifs_ses *dfs_root_ses;
277285
bool dfs_automount:1; /* set for dfs automount only */
286+
enum cifs_reparse_type reparse_type;
278287
};
279288

280289
extern const struct fs_parameter_spec smb3_fs_parameters[];

0 commit comments

Comments
 (0)