Re: [lxc-devel] Fixed (hacked) LXC to apply mount options for bind mounts
On 03/08/2010 10:35 PM, Ciprian Dorin, Craciun wrote: Hello all! This bug stalked me for a while, but only now it bit me quite badly... (Lost about an hour of work...) So the culprit: inside the fstab file for the `lxc.mount` option I can use options like `ro` together with `bind`. Unfortunately the kernel just laughs in my face and ignores any options I've put in there... :) But not any more: I've updated `./src/lxc/conf.c` (`mount_file_entries` function) so that when it encounters a `bind` option it executes it twice (one without any extra options, and a second time with the remount flag set.) I've marginally (as in my particular case) tested it and it works. Any other ideas on how to solve this? Any comments? Ciprian. Sorry for the delay. Hopefully, John remind me to take this patch. I found this paragraph in the mount man page: [ ... ] Note that the filesystem mount options will remain the same as those on the original mount point, and cannot be changed by passing the -o option along with --bind/--rbind. The mount options can be changed by a separate remount command, for example: mount --bind olddir newdir mount -o remount,ro newdir So I think your patch is correct :) Thanks Ciprian. -- Daniel -- ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo ___ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel
Re: [lxc-devel] Fixed (hacked) LXC to apply mount options for bind mounts
Ciprian Dorin, Craciun wrote: On Mon, Mar 8, 2010 at 11:35 PM, Ciprian Dorin, Craciun ciprian.crac...@gmail.com wrote: Hello all! This bug stalked me for a while, but only now it bit me quite badly... (Lost about an hour of work...) So the culprit: inside the fstab file for the `lxc.mount` option I can use options like `ro` together with `bind`. Unfortunately the kernel just laughs in my face and ignores any options I've put in there... :) But not any more: I've updated `./src/lxc/conf.c` (`mount_file_entries` function) so that when it encounters a `bind` option it executes it twice (one without any extra options, and a second time with the remount flag set.) I've marginally (as in my particular case) tested it and it works. Any other ideas on how to solve this? Any comments? Ciprian. P.S.: One question though (both in the patched and unpatched versions): it seems that if I put two lines inside the fstab, once with only `bind` options, and a second one with `remount,ro` option it doesn't work and I receive the error `No such device - failed to mount`. But this is equivalent with what my patched version is doing (which works)... Strange... diff --git a/src/lxc/conf.c b/src/lxc/conf.c index 26ddd03..f7c5816 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -801,11 +801,20 @@ static int mount_file_entries(FILE *file) } if (mount(mntent-mnt_fsname, mntent-mnt_dir, - mntent-mnt_type, mntflags, mntdata)) { + mntent-mnt_type, mntflags ~MS_REMOUNT, mntdata)) { SYSERROR(failed to mount '%s' on '%s', mntent-mnt_fsname, mntent-mnt_dir); goto out; } + if ((mntflags MS_REMOUNT == MS_REMOUNT) || (mntflags MS_BIND == MS_BIND)) { + DEBUG (remounting %s on %s to respect bind or remount options, mntent-mnt_fsname, mntent-mnt_dir); + if (mount(mntent-mnt_fsname, mntent-mnt_dir, + mntent-mnt_type, mntflags | MS_REMOUNT, mntdata)) { + SYSERROR(failed to mount '%s' on '%s', +mntent-mnt_fsname, mntent-mnt_dir); + goto out; + } + } DEBUG(mounted %s on %s, type %s, mntent-mnt_fsname, mntent-mnt_dir, mntent-mnt_type); Forgot to montion that my changeset is also available on Gitorious: clone-URL git://gitorious.org/~ciprian.craciun/lxc/ciprian-craciun-patches.git branch: patches/bind-remount Or view on-line: http://gitorious.org/~ciprian.craciun/lxc/ciprian-craciun-patches/commits/patches/bind-remount Thanks Ciprian for the report. -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel
Re: [lxc-devel] Fixed (hacked) LXC to apply mount options for bind mounts
On Mon, Mar 8, 2010 at 11:35 PM, Ciprian Dorin, Craciun ciprian.crac...@gmail.com wrote: Hello all! This bug stalked me for a while, but only now it bit me quite badly... (Lost about an hour of work...) So the culprit: inside the fstab file for the `lxc.mount` option I can use options like `ro` together with `bind`. Unfortunately the kernel just laughs in my face and ignores any options I've put in there... :) But not any more: I've updated `./src/lxc/conf.c` (`mount_file_entries` function) so that when it encounters a `bind` option it executes it twice (one without any extra options, and a second time with the remount flag set.) I've marginally (as in my particular case) tested it and it works. Any other ideas on how to solve this? Any comments? Ciprian. P.S.: One question though (both in the patched and unpatched versions): it seems that if I put two lines inside the fstab, once with only `bind` options, and a second one with `remount,ro` option it doesn't work and I receive the error `No such device - failed to mount`. But this is equivalent with what my patched version is doing (which works)... Strange... diff --git a/src/lxc/conf.c b/src/lxc/conf.c index 26ddd03..f7c5816 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -801,11 +801,20 @@ static int mount_file_entries(FILE *file) } if (mount(mntent-mnt_fsname, mntent-mnt_dir, - mntent-mnt_type, mntflags, mntdata)) { + mntent-mnt_type, mntflags ~MS_REMOUNT, mntdata)) { SYSERROR(failed to mount '%s' on '%s', mntent-mnt_fsname, mntent-mnt_dir); goto out; } + if ((mntflags MS_REMOUNT == MS_REMOUNT) || (mntflags MS_BIND == MS_BIND)) { + DEBUG (remounting %s on %s to respect bind or remount options, mntent-mnt_fsname, mntent-mnt_dir); + if (mount(mntent-mnt_fsname, mntent-mnt_dir, + mntent-mnt_type, mntflags | MS_REMOUNT, mntdata)) { + SYSERROR(failed to mount '%s' on '%s', + mntent-mnt_fsname, mntent-mnt_dir); + goto out; + } + } DEBUG(mounted %s on %s, type %s, mntent-mnt_fsname, mntent-mnt_dir, mntent-mnt_type); Forgot to montion that my changeset is also available on Gitorious: clone-URL git://gitorious.org/~ciprian.craciun/lxc/ciprian-craciun-patches.git branch: patches/bind-remount Or view on-line: http://gitorious.org/~ciprian.craciun/lxc/ciprian-craciun-patches/commits/patches/bind-remount Ciprian. -- Download Intel#174; Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel