public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Karel Zak <kzak@redhat.com>
To: Lukas Czerner <lczerner@redhat.com>
Cc: linux-kernel@vger.kernel.org, mbroz@redhat.com,
	linux-fsdevel@vger.kernel.org, Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH] fs: print warning when mount flags was ignored
Date: Thu, 19 Apr 2012 12:28:57 +0200	[thread overview]
Message-ID: <20120419102857.GA13436@x2.net.home> (raw)
In-Reply-To: <1334826475-11606-1-git-send-email-lczerner@redhat.com>

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

  reply	other threads:[~2012-04-19 10:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-19  9:07 [PATCH] fs: print warning when mount flags was ignored Lukas Czerner
2012-04-19 10:28 ` Karel Zak [this message]
2012-04-19 11:49   ` Lukas Czerner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120419102857.GA13436@x2.net.home \
    --to=kzak@redhat.com \
    --cc=lczerner@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mbroz@redhat.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox