Re: [PATCH] mount: enable use MS_RDONLY with MS_BIND

From: Gustavo Padovan
Date: Fri Dec 23 2011 - 12:17:55 EST


So I put Lennart's email wrong. Fixing it.

* Gustavo F. Padovan <padovan@xxxxxxxxxxxxxx> [2011-12-23 15:14:56 -0200]:

> From: "Gustavo F. Padovan" <padovan@xxxxxxxxxxxxxx>
>
> This allow creation of read-only bind mounts in a single mount() call,
> instead of two.
>
> Signed-off-by: Gustavo F. Padovan <padovan@xxxxxxxxxxxxxx>
> ---
> fs/namespace.c | 11 ++++++++---
> 1 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/fs/namespace.c b/fs/namespace.c
> index 5c07af8..c08c150 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -1743,7 +1743,7 @@ static int do_change_type(struct path *path, int flag)
> * do loopback mount.
> */
> static int do_loopback(struct path *path, char *old_name,
> - int recurse)
> + unsigned long flags)
> {
> LIST_HEAD(umount_list);
> struct path old_path;
> @@ -1769,7 +1769,7 @@ static int do_loopback(struct path *path, char *old_name,
> goto out2;
>
> err = -ENOMEM;
> - if (recurse)
> + if (flags & MS_REC)
> mnt = copy_tree(old_path.mnt, old_path.dentry, 0);
> else
> mnt = clone_mnt(old_path.mnt, old_path.dentry, 0);
> @@ -1782,7 +1782,12 @@ static int do_loopback(struct path *path, char *old_name,
> br_write_lock(&vfsmount_lock);
> umount_tree(mnt, 0, &umount_list);
> br_write_unlock(&vfsmount_lock);
> + goto out2;
> }
> +
> + if (flags & MS_RDONLY)
> + path->mnt->mnt_flags |= MNT_READONLY;
> +
> out2:
> unlock_mount(path);
> release_mounts(&umount_list);
> @@ -2338,7 +2343,7 @@ long do_mount(char *dev_name, char *dir_name, char *type_page,
> retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
> data_page);
> else if (flags & MS_BIND)
> - retval = do_loopback(&path, dev_name, flags & MS_REC);
> + retval = do_loopback(&path, dev_name, flags);
> else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
> retval = do_change_type(&path, flags);
> else if (flags & MS_MOVE)
> --
> 1.7.6.4
>

Gustavo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/