From: Lukas Czerner <lczerner@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: mbroz@redhat.com, linux-fsdevel@vger.kernel.org,
Lukas Czerner <lczerner@redhat.com>,
Al Viro <viro@zeniv.linux.org.uk>
Subject: [PATCH] fs: print warning when mount flags was ignored
Date: Thu, 19 Apr 2012 11:07:55 +0200 [thread overview]
Message-ID: <1334826475-11606-1-git-send-email-lczerner@redhat.com> (raw)
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.
Fix this by checking for unhandled flags and print warning when
flags was ignored. I am not sure if it's worth translating the flags
into the name, so it just prints the flag as a hexadecimal number.
Obviously we can not fail when conflicting flags are specified,
because it may break buggy application, but it can change in the
future.
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reported-by: Milan Broz <mbroz@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
---
fs/namespace.c | 24 +++++++++++++++++++-----
1 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/fs/namespace.c b/fs/namespace.c
index e608199..8736a48 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2175,18 +2175,32 @@ long do_mount(char *dev_name, char *dir_name, char *type_page,
MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
MS_STRICTATIME);
- 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;
+ } 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;
+ } 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);
+ } 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);
dput_out:
path_put(&path);
return retval;
--
1.7.4.4
next reply other threads:[~2012-04-19 9:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-19 9:07 Lukas Czerner [this message]
2012-04-19 10:28 ` [PATCH] fs: print warning when mount flags was ignored Karel Zak
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=1334826475-11606-1-git-send-email-lczerner@redhat.com \
--to=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