Re: Remount root RO after the root dentry drops from the namespace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 18 Nov 2009, Daniel Drake wrote:
> On Wed, 2009-11-18 at 12:50 +0100, Miklos Szeredi wrote:
> > You can easily make a directory a root of a mount with
> > 
> >  mount --bind $DIR $DIR
> > 
> > In your example, add this before 5.
> 
> Thanks for the suggestion! And following on from that, we would do
> "mount -o remount,ro /path/to/realroot" during shutdown
> where /path/to/realroot is the bind mount that we created based on your
> advice?

I see some confusion here, there's no "path/to/realroot", the bind
mount didn't actually do anything to the namespace, it just made
"/versions/run/1" (which will later become "/") a mountpoint.

At shutdown there's nothing special to do, other than 
"mount -o remount,ro /"

> 
> Unfortunately, that approach doesn't solve the problem. If you remount a
> bind-mount as read only then the "real" underlying mount is unaffected.
> See the code flow in do_remount() :
> 
> 	if (flags & MS_BIND)
> 		err = change_mount_flags(path->mnt, flags);
> 	else
> 		err = do_remount_sb(sb, flags, data, 0);
> 

Note: the "flags" tested here are supplied from the argument of
mount(2), and are not flags stored in the mount.  And btw, MS_BIND is
not stored in the mount at all, there's absolutely no difference
between a mount created with "--bind" and one without.

So my suggestion should work fine.

Thanks,
Miklos
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux