Commit 90bea5a3 authored by Daniel Golle's avatar Daniel Golle Committed by Artem Bityutskiy

UBIFS: respect MS_SILENT mount flag

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: default avatarDaniel Golle <daniel@makrotopia.org>
Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
parent 72abc8f4
...@@ -988,30 +988,32 @@ int ubifs_read_node(const struct ubifs_info *c, void *buf, int type, int len, ...@@ -988,30 +988,32 @@ int ubifs_read_node(const struct ubifs_info *c, void *buf, int type, int len,
return err; return err;
if (type != ch->node_type) { 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); ch->node_type, type);
goto out; goto out;
} }
err = ubifs_check_node(c, buf, lnum, offs, 0, 0); err = ubifs_check_node(c, buf, lnum, offs, 0, 0);
if (err) { if (err) {
ubifs_err("expected node type %d", type); ubifs_errc(c, "expected node type %d", type);
return err; return err;
} }
l = le32_to_cpu(ch->len); l = le32_to_cpu(ch->len);
if (l != 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; goto out;
} }
return 0; return 0;
out: 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,
ubi_is_mapped(c->ubi, lnum)); offs, ubi_is_mapped(c->ubi, lnum));
if (!c->probing) {
ubifs_dump_node(c, buf); ubifs_dump_node(c, buf);
dump_stack(); dump_stack();
}
return -EINVAL; return -EINVAL;
} }
......
...@@ -1149,6 +1149,9 @@ static int mount_ubifs(struct ubifs_info *c) ...@@ -1149,6 +1149,9 @@ static int mount_ubifs(struct ubifs_info *c)
size_t sz; size_t sz;
c->ro_mount = !!(c->vfs_sb->s_flags & MS_RDONLY); c->ro_mount = !!(c->vfs_sb->s_flags & MS_RDONLY);
/* Suppress error messages while probing if MS_SILENT is set */
c->probing = !!(c->vfs_sb->s_flags & MS_SILENT);
err = init_constants_early(c); err = init_constants_early(c);
if (err) if (err)
return err; return err;
...@@ -1214,6 +1217,8 @@ static int mount_ubifs(struct ubifs_info *c) ...@@ -1214,6 +1217,8 @@ static int mount_ubifs(struct ubifs_info *c)
if (err) if (err)
goto out_free; goto out_free;
c->probing = 0;
/* /*
* Make sure the compressor which is set as default in the superblock * Make sure the compressor which is set as default in the superblock
* or overridden by mount options is actually compiled in. * or overridden by mount options is actually compiled in.
......
...@@ -51,6 +51,15 @@ ...@@ -51,6 +51,15 @@
#define ubifs_warn(fmt, ...) \ #define ubifs_warn(fmt, ...) \
pr_warn("UBIFS warning (pid %d): %s: " fmt "\n", \ pr_warn("UBIFS warning (pid %d): %s: " fmt "\n", \
current->pid, __func__, ##__VA_ARGS__) 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, ...) \
do { \
if (!(c)->probing) \
ubifs_err(fmt, ##__VA_ARGS__); \
} while (0)
/* UBIFS file system VFS magic number */ /* UBIFS file system VFS magic number */
#define UBIFS_SUPER_MAGIC 0x24051905 #define UBIFS_SUPER_MAGIC 0x24051905
...@@ -1209,6 +1218,7 @@ struct ubifs_debug_info; ...@@ -1209,6 +1218,7 @@ struct ubifs_debug_info;
* @need_recovery: %1 if the file-system needs recovery * @need_recovery: %1 if the file-system needs recovery
* @replaying: %1 during journal replay * @replaying: %1 during journal replay
* @mounting: %1 while mounting * @mounting: %1 while mounting
* @probing: %1 while attempting to mount if MS_SILENT mount flag is set
* @remounting_rw: %1 while re-mounting from R/O mode to R/W mode * @remounting_rw: %1 while re-mounting from R/O mode to R/W mode
* @replay_list: temporary list used during journal replay * @replay_list: temporary list used during journal replay
* @replay_buds: list of buds to replay * @replay_buds: list of buds to replay
...@@ -1441,6 +1451,7 @@ struct ubifs_info { ...@@ -1441,6 +1451,7 @@ struct ubifs_info {
unsigned int replaying:1; unsigned int replaying:1;
unsigned int mounting:1; unsigned int mounting:1;
unsigned int remounting_rw:1; unsigned int remounting_rw:1;
unsigned int probing:1;
struct list_head replay_list; struct list_head replay_list;
struct list_head replay_buds; struct list_head replay_buds;
unsigned long long cs_sqnum; unsigned long long cs_sqnum;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment