kernel: rootfs auto-mount on ubi
[openwrt/openwrt.git] / target / linux / generic / patches-3.14 / 552-ubifs-respect-silent-mount-flag.patch
1 From 248b89b95d27659c5360ef5b68cca21d096ee909 Mon Sep 17 00:00:00 2001
2 From: Daniel Golle <daniel@makrotopia.org>
3 Date: Sat, 17 May 2014 03:16:54 +0200
4 Subject: [PATCH 3/5] ubifs: respect MS_SILENT mount flag
5 To: dedekind1@gmail.com,
6 linux-mtd@lists.infradead.org
7
8 When attempting to mount a non-ubifs formatted volume, lots of error
9 messages (including a stack dump) are thrown to the kernel log even if
10 the MS_SILENT mount flag is set.
11 Fix this by checking the MS_SILENT flag in ubifs_read_sb_node and
12 passing it down to ubifs_read_node, which now got an additional
13 parameter for that purpose.
14
15 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
16 ---
17 fs/ubifs/commit.c | 4 ++--
18 fs/ubifs/io.c | 23 ++++++++++++++---------
19 fs/ubifs/sb.c | 5 +++--
20 fs/ubifs/tnc_misc.c | 4 ++--
21 fs/ubifs/ubifs.h | 2 +-
22 5 files changed, 22 insertions(+), 16 deletions(-)
23
24 diff --git a/fs/ubifs/commit.c b/fs/ubifs/commit.c
25 index ff82293..865d13f 100644
26 --- a/fs/ubifs/commit.c
27 +++ b/fs/ubifs/commit.c
28 @@ -542,7 +542,7 @@ int dbg_old_index_check_init(struct ubifs_info *c, struct ubifs_zbranch *zroot)
29 if (!idx)
30 return -ENOMEM;
31
32 - err = ubifs_read_node(c, idx, UBIFS_IDX_NODE, len, lnum, offs);
33 + err = ubifs_read_node(c, idx, UBIFS_IDX_NODE, len, lnum, offs, 0);
34 if (err)
35 goto out;
36
37 @@ -610,7 +610,7 @@ int dbg_check_old_index(struct ubifs_info *c, struct ubifs_zbranch *zroot)
38 list_add_tail(&i->list, &list);
39 /* Read the index node */
40 idx = &i->idx;
41 - err = ubifs_read_node(c, idx, UBIFS_IDX_NODE, len, lnum, offs);
42 + err = ubifs_read_node(c, idx, UBIFS_IDX_NODE, len, lnum, offs, 0);
43 if (err)
44 goto out_free;
45 /* Validate index node */
46 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
47 index e18b988..51c4072 100644
48 --- a/fs/ubifs/io.c
49 +++ b/fs/ubifs/io.c
50 @@ -912,7 +912,7 @@ int ubifs_read_node_wbuf(struct ubifs_wbuf *wbuf, void *buf, int type, int len,
51 if (!overlap) {
52 /* We may safely unlock the write-buffer and read the data */
53 spin_unlock(&wbuf->lock);
54 - return ubifs_read_node(c, buf, type, len, lnum, offs);
55 + return ubifs_read_node(c, buf, type, len, lnum, offs, 0);
56 }
57
58 /* Don't read under wbuf */
59 @@ -966,13 +966,14 @@ out:
60 * @len: node length (not aligned)
61 * @lnum: logical eraseblock number
62 * @offs: offset within the logical eraseblock
63 + * @silent: suppress error messages
64 *
65 * This function reads a node of known type and and length, checks it and
66 * stores in @buf. Returns zero in case of success, %-EUCLEAN if CRC mismatched
67 * and a negative error code in case of failure.
68 */
69 int ubifs_read_node(const struct ubifs_info *c, void *buf, int type, int len,
70 - int lnum, int offs)
71 + int lnum, int offs, int silent)
72 {
73 int err, l;
74 struct ubifs_ch *ch = buf;
75 @@ -988,30 +989,34 @@ int ubifs_read_node(const struct ubifs_info *c, void *buf, int type, int len,
76 return err;
77
78 if (type != ch->node_type) {
79 - ubifs_err("bad node type (%d but expected %d)",
80 + if (!silent) ubifs_err("bad node type (%d but expected %d)",
81 ch->node_type, type);
82 goto out;
83 }
84
85 err = ubifs_check_node(c, buf, lnum, offs, 0, 0);
86 if (err) {
87 - ubifs_err("expected node type %d", type);
88 + if (!silent)
89 + ubifs_err("expected node type %d", type);
90 return err;
91 }
92
93 l = le32_to_cpu(ch->len);
94 if (l != len) {
95 - ubifs_err("bad node length %d, expected %d", l, len);
96 + if (!silent)
97 + ubifs_err("bad node length %d, expected %d", l, len);
98 goto out;
99 }
100
101 return 0;
102
103 out:
104 - ubifs_err("bad node at LEB %d:%d, LEB mapping status %d", lnum, offs,
105 - ubi_is_mapped(c->ubi, lnum));
106 - ubifs_dump_node(c, buf);
107 - dump_stack();
108 + if (!silent) {
109 + ubifs_err("bad node at LEB %d:%d, LEB mapping status %d", lnum,
110 + offs, ubi_is_mapped(c->ubi, lnum));
111 + ubifs_dump_node(c, buf);
112 + dump_stack();
113 + }
114 return -EINVAL;
115 }
116
117 diff --git a/fs/ubifs/sb.c b/fs/ubifs/sb.c
118 index 4c37607..b46847d 100644
119 --- a/fs/ubifs/sb.c
120 +++ b/fs/ubifs/sb.c
121 @@ -482,14 +482,15 @@ failed:
122 struct ubifs_sb_node *ubifs_read_sb_node(struct ubifs_info *c)
123 {
124 struct ubifs_sb_node *sup;
125 - int err;
126 + int silent, err;
127
128 sup = kmalloc(ALIGN(UBIFS_SB_NODE_SZ, c->min_io_size), GFP_NOFS);
129 if (!sup)
130 return ERR_PTR(-ENOMEM);
131
132 + silent = !!(c->vfs_sb->s_flags & MS_SILENT);
133 err = ubifs_read_node(c, sup, UBIFS_SB_NODE, UBIFS_SB_NODE_SZ,
134 - UBIFS_SB_LNUM, 0);
135 + UBIFS_SB_LNUM, 0, silent);
136 if (err) {
137 kfree(sup);
138 return ERR_PTR(err);
139 diff --git a/fs/ubifs/tnc_misc.c b/fs/ubifs/tnc_misc.c
140 index f6bf899..e128689 100644
141 --- a/fs/ubifs/tnc_misc.c
142 +++ b/fs/ubifs/tnc_misc.c
143 @@ -280,7 +280,7 @@ static int read_znode(struct ubifs_info *c, int lnum, int offs, int len,
144 if (!idx)
145 return -ENOMEM;
146
147 - err = ubifs_read_node(c, idx, UBIFS_IDX_NODE, len, lnum, offs);
148 + err = ubifs_read_node(c, idx, UBIFS_IDX_NODE, len, lnum, offs, 0);
149 if (err < 0) {
150 kfree(idx);
151 return err;
152 @@ -472,7 +472,7 @@ int ubifs_tnc_read_node(struct ubifs_info *c, struct ubifs_zbranch *zbr,
153 zbr->lnum, zbr->offs);
154 else
155 err = ubifs_read_node(c, node, type, zbr->len, zbr->lnum,
156 - zbr->offs);
157 + zbr->offs, 0);
158
159 if (err) {
160 dbg_tnck(key, "key ");
161 diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
162 index e8c8cfe..85fdd11 100644
163 --- a/fs/ubifs/ubifs.h
164 +++ b/fs/ubifs/ubifs.h
165 @@ -1481,7 +1481,7 @@ int ubifs_wbuf_write_nolock(struct ubifs_wbuf *wbuf, void *buf, int len);
166 int ubifs_wbuf_seek_nolock(struct ubifs_wbuf *wbuf, int lnum, int offs);
167 int ubifs_wbuf_init(struct ubifs_info *c, struct ubifs_wbuf *wbuf);
168 int ubifs_read_node(const struct ubifs_info *c, void *buf, int type, int len,
169 - int lnum, int offs);
170 + int lnum, int offs, int silent);
171 int ubifs_read_node_wbuf(struct ubifs_wbuf *wbuf, void *buf, int type, int len,
172 int lnum, int offs);
173 int ubifs_write_node(struct ubifs_info *c, void *node, int len, int lnum,
174 --
175 1.9.2
176