Skip to content

Commit

Permalink
ovl: allow filenames with comma
Browse files Browse the repository at this point in the history
Allow option separator (comma) to be escaped with backslash.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
  • Loading branch information
Miklos Szeredi committed Nov 20, 2014
1 parent 5214846 commit 91c7794
Showing 1 changed file with 45 additions and 3 deletions.
48 changes: 45 additions & 3 deletions fs/overlayfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,11 +462,34 @@ static const match_table_t ovl_tokens = {
{OPT_ERR, NULL}
};

static char *ovl_next_opt(char **s)
{
char *sbegin = *s;
char *p;

if (sbegin == NULL)
return NULL;

for (p = sbegin; *p; p++) {
if (*p == '\\') {
p++;
if (!*p)
break;
} else if (*p == ',') {
*p = '\0';
*s = p + 1;
return sbegin;
}
}
*s = NULL;
return sbegin;
}

static int ovl_parse_opt(char *opt, struct ovl_config *config)
{
char *p;

while ((p = strsep(&opt, ",")) != NULL) {
while ((p = ovl_next_opt(&opt)) != NULL) {
int token;
substring_t args[MAX_OPT_ARGS];

Expand Down Expand Up @@ -554,15 +577,34 @@ static struct dentry *ovl_workdir_create(struct vfsmount *mnt,
goto out_unlock;
}

static void ovl_unescape(char *s)
{
char *d = s;

for (;; s++, d++) {
if (*s == '\\')
s++;
*d = *s;
if (!*s)
break;
}
}

static int ovl_mount_dir(const char *name, struct path *path)
{
int err;
char *tmp = kstrdup(name, GFP_KERNEL);

if (!tmp)
return -ENOMEM;

err = kern_path(name, LOOKUP_FOLLOW, path);
ovl_unescape(tmp);
err = kern_path(tmp, LOOKUP_FOLLOW, path);
if (err) {
pr_err("overlayfs: failed to resolve '%s': %i\n", name, err);
pr_err("overlayfs: failed to resolve '%s': %i\n", tmp, err);
err = -EINVAL;
}
kfree(tmp);
return err;
}

Expand Down

0 comments on commit 91c7794

Please sign in to comment.