Messages in this thread | | | Date | Thu, 19 Apr 2012 12:28:57 +0200 | From | Karel Zak <> | Subject | Re: [PATCH] fs: print warning when mount flags was ignored |
| |
On Thu, Apr 19, 2012 at 11:07:55AM +0200, Lukas Czerner wrote: > Some mount flags can conflict with each other so they can not be > handled together. Currently when conflicting flags are specified, > some of them are silently ignored putting user in believe that > they was handled correctly.
Unfortunately, it's not so simple ;-)
> - if (flags & MS_REMOUNT) > + if (flags & MS_REMOUNT) { > retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags, > data_page); > - else if (flags & MS_BIND) > + flags &= ~MS_REMOUNT;
This is incorrect, the flags may also include many others flags. For example MS_REMOUNT|MS_BIND|MS_RDONLY is valid (see do_remoun() code).
And it's normal that for "mount -o remount" the mount command reads flags from mtab/fstab so it includes for example MS_RELATIME, ...
> + } else if (flags & MS_BIND) { > retval = do_loopback(&path, dev_name, flags & MS_REC); > - else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE)) > + flags &= ~MS_BIND;
what about MS_REC ?
> + } else if (flags & (MS_SHARED | MS_PRIVATE | > + MS_SLAVE | MS_UNBINDABLE)) { > retval = do_change_type(&path, flags); > - else if (flags & MS_MOVE) > + flags &= ~(MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE);
what about MS_REC ?
Note that do_change_type() already checks for unexpected flags and returns -EINVAL if more flags are specified.
> + } else if (flags & MS_MOVE) { > retval = do_move_mount(&path, dev_name); > - else > + flags &= ~MS_MOVE; > + } else > retval = do_new_mount(&path, type_page, flags, mnt_flags, > dev_name, data_page); > + > + flags &= (MS_REMOUNT | MS_BIND | MS_SHARED | MS_PRIVATE | > + MS_SLAVE | MS_UNBINDABLE | MS_MOVE); > + > + if (!retval && flags) > + printk(KERN_WARNING "%s(%u): (%s -> %s) Conflicting mount flags" > + " specified. These flags has been " > + "ignored: %#.8lx\n", __func__, current->pid, > + dev_name, dir_name, flags);
Karel
-- Karel Zak <kzak@redhat.com> http://karelzak.blogspot.com
| |