* [PATCH] fs: Don't ignore MS_RDONLY in bind and not remount case.
@ 2009-10-30 5:31 Kusanagi Kouichi
2009-10-30 5:53 ` Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: Kusanagi Kouichi @ 2009-10-30 5:31 UTC (permalink / raw)
To: linux-fsdevel; +Cc: linux-kernel
A readonly bind mount needed to be created in 2 steps
# mount --bind
# mount --bind -o remount,ro
instead of single
# mount --bind -o ro
because MS_RDONLY is ignored in bind and not remount case.
Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>
---
fs/namespace.c | 14 +++++++++-----
fs/pnode.h | 1 +
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/fs/namespace.c b/fs/namespace.c
index bdc3cb4..1d350e2 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -562,6 +562,8 @@ static struct vfsmount *clone_mnt(struct vfsmount *old, struct dentry *root,
}
mnt->mnt_flags = old->mnt_flags;
+ if (flag & CL_READONLY)
+ mnt->mnt_flags |= MNT_READONLY;
atomic_inc(&sb->s_active);
mnt->mnt_sb = sb;
mnt->mnt_root = dget(root);
@@ -1447,7 +1449,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)
+ int flags)
{
struct path old_path;
struct vfsmount *mnt = NULL;
@@ -1469,10 +1471,12 @@ static int do_loopback(struct path *path, char *old_name,
goto out;
err = -ENOMEM;
- if (recurse)
- mnt = copy_tree(old_path.mnt, old_path.dentry, 0);
+ if (flags & MS_REC)
+ mnt = copy_tree(old_path.mnt, old_path.dentry,
+ flags & MS_RDONLY ? CL_READONLY : 0);
else
- mnt = clone_mnt(old_path.mnt, old_path.dentry, 0);
+ mnt = clone_mnt(old_path.mnt, old_path.dentry,
+ flags & MS_RDONLY ? CL_READONLY : 0);
if (!mnt)
goto out;
@@ -1959,7 +1963,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)
diff --git a/fs/pnode.h b/fs/pnode.h
index 958665d..59769bb 100644
--- a/fs/pnode.h
+++ b/fs/pnode.h
@@ -23,6 +23,7 @@
#define CL_MAKE_SHARED 0x08
#define CL_PROPAGATION 0x10
#define CL_PRIVATE 0x20
+#define CL_READONLY 0x40
static inline void set_mnt_shared(struct vfsmount *mnt)
{
--
1.6.5
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fs: Don't ignore MS_RDONLY in bind and not remount case.
2009-10-30 5:31 [PATCH] fs: Don't ignore MS_RDONLY in bind and not remount case Kusanagi Kouichi
@ 2009-10-30 5:53 ` Christoph Hellwig
2009-10-30 8:56 ` Kusanagi Kouichi
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2009-10-30 5:53 UTC (permalink / raw)
To: Kusanagi Kouichi; +Cc: linux-fsdevel, linux-kernel
On Fri, Oct 30, 2009 at 02:31:46PM +0900, Kusanagi Kouichi wrote:
> A readonly bind mount needed to be created in 2 steps
>
> # mount --bind
> # mount --bind -o remount,ro
>
> instead of single
>
> # mount --bind -o ro
>
> because MS_RDONLY is ignored in bind and not remount case.
I'm pretty sure that was intentional, but I don't remember why anymore.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fs: Don't ignore MS_RDONLY in bind and not remount case.
2009-10-30 5:53 ` Christoph Hellwig
@ 2009-10-30 8:56 ` Kusanagi Kouichi
0 siblings, 0 replies; 3+ messages in thread
From: Kusanagi Kouichi @ 2009-10-30 8:56 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: linux-fsdevel, linux-kernel
On 2009-10-30 01:53:37 -0400, Christoph Hellwig wrote:
> On Fri, Oct 30, 2009 at 02:31:46PM +0900, Kusanagi Kouichi wrote:
> > A readonly bind mount needed to be created in 2 steps
> >
> > # mount --bind
> > # mount --bind -o remount,ro
> >
> > instead of single
> >
> > # mount --bind -o ro
> >
> > because MS_RDONLY is ignored in bind and not remount case.
>
> I'm pretty sure that was intentional, but I don't remember why anymore.
I could not find any reason to restrict this.
Could you tell me the reason of this restriction?
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-10-30 8:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-30 5:31 [PATCH] fs: Don't ignore MS_RDONLY in bind and not remount case Kusanagi Kouichi
2009-10-30 5:53 ` Christoph Hellwig
2009-10-30 8:56 ` Kusanagi Kouichi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®