Commit 4e4ca161 by Serge Hallyn Committed by Stéphane Graber

drop create= from mount options (v2)

Otherwise mount may return -EINVAL if in-kernel super-block parser objects (as is the case with ext4). Changelog v2: also drop 'optional' specifically drop create=dir, not create=* fix order of arguments for memmove Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com> Acked-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
parent b36db61d
...@@ -1881,7 +1881,32 @@ static int mount_entry(const char *fsname, const char *target, ...@@ -1881,7 +1881,32 @@ static int mount_entry(const char *fsname, const char *target,
return 0; return 0;
} }
static inline int mount_entry_on_systemfs(const struct mntent *mntent) /*
* Remove 'optional', 'create=dir', and 'create=file' from mntopt
*/
static void cull_mntent_opt(struct mntent *mntent)
{
int i;
char *p, *p2;
char *list[] = {"create=dir",
"create=file",
"optional",
NULL };
for (i=0; list[i]; i++) {
if (!(p = strstr(mntent->mnt_opts, list[i])))
continue;
p2 = strchr(p, ',');
if (!p2) {
/* no more mntopts, so just chop it here */
*p = '\0';
continue;
}
memmove(p, p2+1, strlen(p2+1)+1);
}
}
static inline int mount_entry_on_systemfs(struct mntent *mntent)
{ {
unsigned long mntflags; unsigned long mntflags;
char *mntdata; char *mntdata;
...@@ -1911,6 +1936,8 @@ static inline int mount_entry_on_systemfs(const struct mntent *mntent) ...@@ -1911,6 +1936,8 @@ static inline int mount_entry_on_systemfs(const struct mntent *mntent)
fclose(pathfile); fclose(pathfile);
} }
cull_mntent_opt(mntent);
if (parse_mntopts(mntent->mnt_opts, &mntflags, &mntdata) < 0) { if (parse_mntopts(mntent->mnt_opts, &mntflags, &mntdata) < 0) {
free(mntdata); free(mntdata);
return -1; return -1;
...@@ -1928,7 +1955,7 @@ static inline int mount_entry_on_systemfs(const struct mntent *mntent) ...@@ -1928,7 +1955,7 @@ static inline int mount_entry_on_systemfs(const struct mntent *mntent)
return ret; return ret;
} }
static int mount_entry_on_absolute_rootfs(const struct mntent *mntent, static int mount_entry_on_absolute_rootfs(struct mntent *mntent,
const struct lxc_rootfs *rootfs, const struct lxc_rootfs *rootfs,
const char *lxc_name) const char *lxc_name)
{ {
...@@ -1998,6 +2025,7 @@ skipabs: ...@@ -1998,6 +2025,7 @@ skipabs:
else else
fclose(pathfile); fclose(pathfile);
} }
cull_mntent_opt(mntent);
if (parse_mntopts(mntent->mnt_opts, &mntflags, &mntdata) < 0) { if (parse_mntopts(mntent->mnt_opts, &mntflags, &mntdata) < 0) {
free(mntdata); free(mntdata);
...@@ -2017,7 +2045,7 @@ out: ...@@ -2017,7 +2045,7 @@ out:
return ret; return ret;
} }
static int mount_entry_on_relative_rootfs(const struct mntent *mntent, static int mount_entry_on_relative_rootfs(struct mntent *mntent,
const char *rootfs) const char *rootfs)
{ {
char path[MAXPATHLEN]; char path[MAXPATHLEN];
...@@ -2055,6 +2083,7 @@ static int mount_entry_on_relative_rootfs(const struct mntent *mntent, ...@@ -2055,6 +2083,7 @@ static int mount_entry_on_relative_rootfs(const struct mntent *mntent,
else else
fclose(pathfile); fclose(pathfile);
} }
cull_mntent_opt(mntent);
if (parse_mntopts(mntent->mnt_opts, &mntflags, &mntdata) < 0) { if (parse_mntopts(mntent->mnt_opts, &mntflags, &mntdata) < 0) {
free(mntdata); free(mntdata);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment