All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Golle <daniel@makrotopia.org>
To: dedekind1@gmail.com, hujianyang@huawei.com,
	linux-mtd@lists.infradead.org
Subject: [PATCH v3] ubifs: respect MS_SILENT mount flag
Date: Sat, 31 May 2014 00:01:56 +0200	[thread overview]
Message-ID: <20140530220149.GA30631@earthship.lan> (raw)
In-Reply-To: <1401265736.2118.2.camel@sauron.fi.intel.com>

[-- Attachment #1: Type: text/plain, Size: 3308 bytes --]

When attempting to mount a non-ubifs formatted volume, lots of error
messages (including a stack dump) are thrown to the kernel log even if
the MS_SILENT mount flag is set.
Fix this by introducing adding an additional state-variable in
struct ubifs_info and suppress error messages in ubifs_read_node if
MS_SILENT is set.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
v3: use state variable in ubifs_info instead of 
 fs/ubifs/io.c    | 14 ++++++++------
 fs/ubifs/super.c |  4 ++++
 fs/ubifs/ubifs.h |  9 +++++++++
 3 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
index e18b988..e6a31faa 100644
--- a/fs/ubifs/io.c
+++ b/fs/ubifs/io.c
@@ -988,30 +988,32 @@ int ubifs_read_node(const struct ubifs_info *c, void *buf, int type, int len,
 		return err;
 
 	if (type != ch->node_type) {
-		ubifs_err("bad node type (%d but expected %d)",
+		ubifs_errc(c, "bad node type (%d but expected %d)",
 			  ch->node_type, type);
 		goto out;
 	}
 
 	err = ubifs_check_node(c, buf, lnum, offs, 0, 0);
 	if (err) {
-		ubifs_err("expected node type %d", type);
+		ubifs_errc(c, "expected node type %d", type);
 		return err;
 	}
 
 	l = le32_to_cpu(ch->len);
 	if (l != len) {
-		ubifs_err("bad node length %d, expected %d", l, len);
+		ubifs_errc(c, "bad node length %d, expected %d", l, len);
 		goto out;
 	}
 
 	return 0;
 
 out:
-	ubifs_err("bad node at LEB %d:%d, LEB mapping status %d", lnum, offs,
+	ubifs_errc(c, "bad node at LEB %d:%d, LEB mapping status %d", lnum, offs,
 		  ubi_is_mapped(c->ubi, lnum));
-	ubifs_dump_node(c, buf);
-	dump_stack();
+	if (!c->probing) {
+		ubifs_dump_node(c, buf);
+		dump_stack();
+	}
 	return -EINVAL;
 }
 
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index a81c7b5..e88bbb6 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -1149,6 +1149,8 @@ static int mount_ubifs(struct ubifs_info *c)
 	size_t sz;
 
 	c->ro_mount = !!(c->vfs_sb->s_flags & MS_RDONLY);
+	c->probing = !!(c->vfs_sb->s_flags & MS_SILENT);
+
 	err = init_constants_early(c);
 	if (err)
 		return err;
@@ -1214,6 +1216,8 @@ static int mount_ubifs(struct ubifs_info *c)
 	if (err)
 		goto out_free;
 
+	c->probing = 0;
+
 	/*
 	 * Make sure the compressor which is set as default in the superblock
 	 * or overridden by mount options is actually compiled in.
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index e8c8cfe..6aa1550 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -52,6 +52,14 @@
 	pr_warn("UBIFS warning (pid %d): %s: " fmt "\n",            \
 		current->pid, __func__, ##__VA_ARGS__)
 
+/*
+ * A variant of 'ubifs_err()' which takes the UBIFS file-sytem description
+ * object as an argument.
+ */
+#define ubifs_errc(c, fmt, ...)                                    \
+	if (!(c)->probing)                                         \
+		ubifs_err(fmt, ##__VA_ARGS__)
+
 /* UBIFS file system VFS magic number */
 #define UBIFS_SUPER_MAGIC 0x24051905
 
@@ -1441,6 +1449,7 @@ struct ubifs_info {
 	unsigned int replaying:1;
 	unsigned int mounting:1;
 	unsigned int remounting_rw:1;
+	unsigned int probing:1;
 	struct list_head replay_list;
 	struct list_head replay_buds;
 	unsigned long long cs_sqnum;
-- 
1.9.3


[-- Attachment #2: Type: application/pgp-signature, Size: 490 bytes --]

  parent reply	other threads:[~2014-05-30 22:02 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-17  1:55 [PATCH] ubifs: respect MS_SILENT mount flag Daniel Golle
2014-05-27 12:18 ` Artem Bityutskiy
2014-05-27 14:11   ` [PATCH v2] " Daniel Golle
2014-05-27 14:56     ` Artem Bityutskiy
2014-05-27 16:04       ` Daniel
2014-05-28  2:11         ` hujianyang
2014-05-28  8:01           ` Artem Bityutskiy
2014-05-28  8:07             ` Bityutskiy, Artem
2014-05-28  8:14               ` Artem Bityutskiy
2014-05-28  8:28                 ` Artem Bityutskiy
2014-05-28  8:42                   ` hujianyang
2014-05-28  9:29                     ` Artem Bityutskiy
2014-05-30 22:01                   ` Daniel Golle [this message]
2014-05-30 23:20                     ` [PATCH v3] " Brian Norris
2014-05-30 23:32                       ` [PATCH v4] " Daniel Golle
2014-05-31  0:01                       ` [PATCH v5] " Daniel Golle
2014-06-02  7:59                         ` Artem Bityutskiy
2014-06-02 13:51                           ` [PATCH v6] " Daniel Golle
2014-06-02 15:01                             ` Artem Bityutskiy

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=20140530220149.GA30631@earthship.lan \
    --to=daniel@makrotopia.org \
    --cc=dedekind1@gmail.com \
    --cc=hujianyang@huawei.com \
    --cc=linux-mtd@lists.infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.