[lxc-devel] [PATCH] Remounts bind mounts if read-only flag is provided
Oren Laadan
orenl at cellrox.com
Wed Nov 19 15:30:55 UTC 2014
the continuation of the thread.
On Wed, Nov 19, 2014 at 9:37 AM, Serge Hallyn <serge.hallyn at ubuntu.com>
wrote:
> Quoting Abin Shahab (ashahab at altiscale.com):
> > Yes. It's documented in the mount man page.
> > Thanks for looking at the patch.
> > On Nov 18, 2014 1:04 PM, "Serge Hallyn" <serge.hallyn at ubuntu.com> wrote:
> >
> > > Quoting Abin Shahab (ashahab at altiscale.com):
> > > > Bind mounts do not honor filesystem mount options. This change will
> > > remount filesystems that are bind mounted if there are changes to
> > > filesystem mount options, specifically if the mount is readonly.
> > >
> > > hi,
> > >
> > > Just to make sure I understand what you're saying,
> > >
> > > 'mount --bind -o ro /a /b' (when done through mount(2)) will not
> > > actually make /b readonly, so we need to do a remount in that case
> > > to get the -o ro to take effect at the vfsmount instead of the sb.
> > > Is that right?
> > >
> > > > Signed-off-by: Abin Shahab <ashahab at altiscale.com>
>
> Thanks, great catch.
>
> Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>
>
> Stéphane, this one is pretty important, please do get this into stable
> as well.
>
> > > > ---
> > > > src/lxc/conf.c | 8 +++++---
> > > > 1 file changed, 5 insertions(+), 3 deletions(-)
> > > >
> > > > diff --git a/src/lxc/conf.c b/src/lxc/conf.c
> > > > index 5938c3e..a3779de 100644
> > > > --- a/src/lxc/conf.c
> > > > +++ b/src/lxc/conf.c
> > > > @@ -1921,10 +1921,12 @@ static int mount_entry(const char *fsname,
> const
> > > char *target,
> > > > if ((mountflags & MS_REMOUNT) || (mountflags & MS_BIND)) {
> > > > DEBUG("remounting %s on %s to respect bind or remount
> > > options",
> > > > fsname ? fsname : "(none)", target ? target :
> > > "(none)");
> > > > -
> > > > + unsigned long rqd_flags = 0;
> > > > + if (mountflags & MS_RDONLY)
> > > > + rqd_flags |= MS_RDONLY;
> > > > #ifdef HAVE_STATVFS
> > > > if (statvfs(fsname, &sb) == 0) {
> > > > - unsigned long required_flags = 0;
> > > > + unsigned long required_flags = rqd_flags;
> > > > if (sb.f_flag & MS_NOSUID)
> > > > required_flags |= MS_NOSUID;
> > > > if (sb.f_flag & MS_NODEV)
> > > > @@ -1940,7 +1942,7 @@ static int mount_entry(const char *fsname,
> const
> > > char *target,
> > > > * mountflags, then skip the remount
> > > > */
> > > > if (!(mountflags & MS_REMOUNT)) {
> > > > - if (!(required_flags & ~mountflags)) {
> > > > + if (!(required_flags & ~mountflags) &&
> > > rqd_flags == 0) {
> > > > DEBUG("mountflags already was
> %lu,
> > > skipping remount",
> > > > mountflags);
> > > > goto skipremount;
> > > > --
> > > > 2.1.0
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20141119/a4c7219f/attachment.html>
More information about the lxc-devel
mailing list