Commit 53a08cb9 authored by Miklos Szeredi's avatar Miklos Szeredi

ovl: make upperdir optional

Make "upperdir=" mount option optional.  If "upperdir=" is not given, then
the "workdir=" option is also optional (and ignored if given).
Signed-off-by: default avatarMiklos Szeredi <mszeredi@suse.cz>
parent ab508822
...@@ -516,8 +516,10 @@ static int ovl_show_options(struct seq_file *m, struct dentry *dentry) ...@@ -516,8 +516,10 @@ static int ovl_show_options(struct seq_file *m, struct dentry *dentry)
struct ovl_fs *ufs = sb->s_fs_info; struct ovl_fs *ufs = sb->s_fs_info;
seq_printf(m, ",lowerdir=%s", ufs->config.lowerdir); seq_printf(m, ",lowerdir=%s", ufs->config.lowerdir);
if (ufs->config.upperdir) {
seq_printf(m, ",upperdir=%s", ufs->config.upperdir); seq_printf(m, ",upperdir=%s", ufs->config.upperdir);
seq_printf(m, ",workdir=%s", ufs->config.workdir); seq_printf(m, ",workdir=%s", ufs->config.workdir);
}
return 0; return 0;
} }
...@@ -768,8 +770,8 @@ static bool ovl_workdir_ok(struct dentry *workdir, struct dentry *upperdir) ...@@ -768,8 +770,8 @@ static bool ovl_workdir_ok(struct dentry *workdir, struct dentry *upperdir)
static int ovl_fill_super(struct super_block *sb, void *data, int silent) static int ovl_fill_super(struct super_block *sb, void *data, int silent)
{ {
struct path lowerpath; struct path lowerpath;
struct path upperpath; struct path upperpath = { NULL, NULL };
struct path workpath; struct path workpath = { NULL, NULL };
struct dentry *root_dentry; struct dentry *root_dentry;
struct ovl_entry *oe; struct ovl_entry *oe;
struct ovl_fs *ufs; struct ovl_fs *ufs;
...@@ -786,11 +788,17 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) ...@@ -786,11 +788,17 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
if (err) if (err)
goto out_free_config; goto out_free_config;
/* FIXME: workdir is not needed for a R/O mount */
err = -EINVAL; err = -EINVAL;
if (!ufs->config.upperdir || !ufs->config.lowerdir || if (!ufs->config.lowerdir) {
!ufs->config.workdir) { pr_err("overlayfs: missing 'lowerdir'\n");
pr_err("overlayfs: missing upperdir or lowerdir or workdir\n"); goto out_free_config;
}
sb->s_stack_depth = 0;
if (ufs->config.upperdir) {
/* FIXME: workdir is not needed for a R/O mount */
if (!ufs->config.workdir) {
pr_err("overlayfs: missing 'workdir'\n");
goto out_free_config; goto out_free_config;
} }
...@@ -811,6 +819,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) ...@@ -811,6 +819,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
goto out_put_workpath; goto out_put_workpath;
} }
sb->s_stack_depth = upperpath.mnt->mnt_sb->s_stack_depth; sb->s_stack_depth = upperpath.mnt->mnt_sb->s_stack_depth;
}
err = ovl_lower_dir(ufs->config.lowerdir, &lowerpath, err = ovl_lower_dir(ufs->config.lowerdir, &lowerpath,
&ufs->lower_namelen, &sb->s_stack_depth); &ufs->lower_namelen, &sb->s_stack_depth);
...@@ -824,6 +833,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) ...@@ -824,6 +833,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
goto out_put_lowerpath; goto out_put_lowerpath;
} }
if (ufs->config.upperdir) {
ufs->upper_mnt = clone_private_mount(&upperpath); ufs->upper_mnt = clone_private_mount(&upperpath);
err = PTR_ERR(ufs->upper_mnt); err = PTR_ERR(ufs->upper_mnt);
if (IS_ERR(ufs->upper_mnt)) { if (IS_ERR(ufs->upper_mnt)) {
...@@ -838,6 +848,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) ...@@ -838,6 +848,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
ufs->config.workdir, OVL_WORKDIR_NAME); ufs->config.workdir, OVL_WORKDIR_NAME);
goto out_put_upper_mnt; goto out_put_upper_mnt;
} }
}
ufs->lower_mnt = kcalloc(1, sizeof(struct vfsmount *), GFP_KERNEL); ufs->lower_mnt = kcalloc(1, sizeof(struct vfsmount *), GFP_KERNEL);
if (ufs->lower_mnt == NULL) if (ufs->lower_mnt == NULL)
...@@ -858,8 +869,8 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) ...@@ -858,8 +869,8 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent)
ufs->lower_mnt[0] = mnt; ufs->lower_mnt[0] = mnt;
ufs->numlower = 1; ufs->numlower = 1;
/* If the upper fs is r/o, we mark overlayfs r/o too */ /* If the upper fs is r/o or nonexistent, we mark overlayfs r/o too */
if (ufs->upper_mnt->mnt_sb->s_flags & MS_RDONLY) if (!ufs->upper_mnt || (ufs->upper_mnt->mnt_sb->s_flags & MS_RDONLY))
sb->s_flags |= MS_RDONLY; sb->s_flags |= MS_RDONLY;
sb->s_d_op = &ovl_dentry_operations; sb->s_d_op = &ovl_dentry_operations;
......
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