Skip to content

Commit af1a3d2

Browse files
Ronnie Sahlbergsmfrench
authored andcommitted
cifs: In the new mount api we get the full devname as source=
so we no longer need to handle or parse the UNC= and prefixpath= options that mount.cifs are generating. This also fixes a bug in the mount command option where the devname would be truncated into just //server/share because we were looking at the truncated UNC value and not the full path. I.e. in the mount command output the devive //server/share/path would show up as just //server/share Signed-off-by: Ronnie Sahlberg <[email protected]> Reviewed-by: Shyam Prasad N <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent a0f85e3 commit af1a3d2

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

fs/cifs/cifsfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ cifs_show_cache_flavor(struct seq_file *s, struct cifs_sb_info *cifs_sb)
469469
static int cifs_show_devname(struct seq_file *m, struct dentry *root)
470470
{
471471
struct cifs_sb_info *cifs_sb = CIFS_SB(root->d_sb);
472-
char *devname = kstrdup(cifs_sb->ctx->UNC, GFP_KERNEL);
472+
char *devname = kstrdup(cifs_sb->ctx->source, GFP_KERNEL);
473473

474474
if (devname == NULL)
475475
seq_puts(m, "none");

fs/cifs/fs_context.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ const struct fs_parameter_spec smb3_fs_parameters[] = {
148148

149149
/* Mount options which take string value */
150150
fsparam_string("source", Opt_source),
151-
fsparam_string("unc", Opt_source),
152151
fsparam_string("user", Opt_user),
153152
fsparam_string("username", Opt_user),
154153
fsparam_string("pass", Opt_pass),
@@ -178,6 +177,11 @@ const struct fs_parameter_spec smb3_fs_parameters[] = {
178177
fsparam_flag_no("auto", Opt_ignore),
179178
fsparam_string("cred", Opt_ignore),
180179
fsparam_string("credentials", Opt_ignore),
180+
/*
181+
* UNC and prefixpath is now extracted from Opt_source
182+
* in the new mount API so we can just ignore them going forward.
183+
*/
184+
fsparam_string("unc", Opt_ignore),
181185
fsparam_string("prefixpath", Opt_ignore),
182186
{}
183187
};
@@ -313,6 +317,7 @@ smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx
313317
new_ctx->password = NULL;
314318
new_ctx->domainname = NULL;
315319
new_ctx->UNC = NULL;
320+
new_ctx->source = NULL;
316321
new_ctx->iocharset = NULL;
317322

318323
/*
@@ -323,6 +328,7 @@ smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx
323328
DUP_CTX_STR(username);
324329
DUP_CTX_STR(password);
325330
DUP_CTX_STR(UNC);
331+
DUP_CTX_STR(source);
326332
DUP_CTX_STR(domainname);
327333
DUP_CTX_STR(nodename);
328334
DUP_CTX_STR(iocharset);
@@ -732,6 +738,7 @@ static int smb3_reconfigure(struct fs_context *fc)
732738
* just use what we already have in cifs_sb->ctx.
733739
*/
734740
STEAL_STRING(cifs_sb, ctx, UNC);
741+
STEAL_STRING(cifs_sb, ctx, source);
735742
STEAL_STRING(cifs_sb, ctx, username);
736743
STEAL_STRING(cifs_sb, ctx, password);
737744
STEAL_STRING(cifs_sb, ctx, domainname);
@@ -974,6 +981,11 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
974981
cifs_dbg(VFS, "Unknown error parsing devname\n");
975982
goto cifs_parse_mount_err;
976983
}
984+
ctx->source = kstrdup(param->string, GFP_KERNEL);
985+
if (ctx->source == NULL) {
986+
cifs_dbg(VFS, "OOM when copying UNC string\n");
987+
goto cifs_parse_mount_err;
988+
}
977989
fc->source = kstrdup(param->string, GFP_KERNEL);
978990
if (fc->source == NULL) {
979991
cifs_dbg(VFS, "OOM when copying UNC string\n");
@@ -1396,6 +1408,8 @@ smb3_cleanup_fs_context_contents(struct smb3_fs_context *ctx)
13961408
ctx->password = NULL;
13971409
kfree(ctx->UNC);
13981410
ctx->UNC = NULL;
1411+
kfree(ctx->source);
1412+
ctx->source = NULL;
13991413
kfree(ctx->domainname);
14001414
ctx->domainname = NULL;
14011415
kfree(ctx->nodename);

fs/cifs/fs_context.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ struct smb3_fs_context {
159159
char *username;
160160
char *password;
161161
char *domainname;
162+
char *source;
162163
char *UNC;
163164
char *nodename;
164165
char *iocharset; /* local code page for mapping to and from Unicode */

0 commit comments

Comments
 (0)