diff options
Diffstat (limited to 'fs/ubifs/scan.c')
-rw-r--r-- | fs/ubifs/scan.c | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/fs/ubifs/scan.c b/fs/ubifs/scan.c index 892ebfee4fe5..96c525384191 100644 --- a/fs/ubifs/scan.c +++ b/fs/ubifs/scan.c | |||
@@ -108,10 +108,9 @@ int ubifs_scan_a_node(const struct ubifs_info *c, void *buf, int len, int lnum, | |||
108 | 108 | ||
109 | /* Make the node pads to 8-byte boundary */ | 109 | /* Make the node pads to 8-byte boundary */ |
110 | if ((node_len + pad_len) & 7) { | 110 | if ((node_len + pad_len) & 7) { |
111 | if (!quiet) { | 111 | if (!quiet) |
112 | dbg_err("bad padding length %d - %d", | 112 | dbg_err("bad padding length %d - %d", |
113 | offs, offs + node_len + pad_len); | 113 | offs, offs + node_len + pad_len); |
114 | } | ||
115 | return SCANNED_A_BAD_PAD_NODE; | 114 | return SCANNED_A_BAD_PAD_NODE; |
116 | } | 115 | } |
117 | 116 | ||
@@ -253,15 +252,19 @@ void ubifs_scanned_corruption(const struct ubifs_info *c, int lnum, int offs, | |||
253 | * @c: UBIFS file-system description object | 252 | * @c: UBIFS file-system description object |
254 | * @lnum: logical eraseblock number | 253 | * @lnum: logical eraseblock number |
255 | * @offs: offset to start at (usually zero) | 254 | * @offs: offset to start at (usually zero) |
256 | * @sbuf: scan buffer (must be c->leb_size) | 255 | * @sbuf: scan buffer (must be of @c->leb_size bytes in size) |
256 | * @quiet: print no messages | ||
257 | * | 257 | * |
258 | * This function scans LEB number @lnum and returns complete information about | 258 | * This function scans LEB number @lnum and returns complete information about |
259 | * its contents. Returns the scaned information in case of success and, | 259 | * its contents. Returns the scaned information in case of success and, |
260 | * %-EUCLEAN if the LEB neads recovery, and other negative error codes in case | 260 | * %-EUCLEAN if the LEB neads recovery, and other negative error codes in case |
261 | * of failure. | 261 | * of failure. |
262 | * | ||
263 | * If @quiet is non-zero, this function does not print large and scary | ||
264 | * error messages and flash dumps in case of errors. | ||
262 | */ | 265 | */ |
263 | struct ubifs_scan_leb *ubifs_scan(const struct ubifs_info *c, int lnum, | 266 | struct ubifs_scan_leb *ubifs_scan(const struct ubifs_info *c, int lnum, |
264 | int offs, void *sbuf) | 267 | int offs, void *sbuf, int quiet) |
265 | { | 268 | { |
266 | void *buf = sbuf + offs; | 269 | void *buf = sbuf + offs; |
267 | int err, len = c->leb_size - offs; | 270 | int err, len = c->leb_size - offs; |
@@ -280,7 +283,7 @@ struct ubifs_scan_leb *ubifs_scan(const struct ubifs_info *c, int lnum, | |||
280 | 283 | ||
281 | cond_resched(); | 284 | cond_resched(); |
282 | 285 | ||
283 | ret = ubifs_scan_a_node(c, buf, len, lnum, offs, 0); | 286 | ret = ubifs_scan_a_node(c, buf, len, lnum, offs, quiet); |
284 | if (ret > 0) { | 287 | if (ret > 0) { |
285 | /* Padding bytes or a valid padding node */ | 288 | /* Padding bytes or a valid padding node */ |
286 | offs += ret; | 289 | offs += ret; |
@@ -320,7 +323,9 @@ struct ubifs_scan_leb *ubifs_scan(const struct ubifs_info *c, int lnum, | |||
320 | } | 323 | } |
321 | 324 | ||
322 | if (offs % c->min_io_size) { | 325 | if (offs % c->min_io_size) { |
323 | ubifs_err("empty space starts at non-aligned offset %d", offs); | 326 | if (!quiet) |
327 | ubifs_err("empty space starts at non-aligned offset %d", | ||
328 | offs); | ||
324 | goto corrupted;; | 329 | goto corrupted;; |
325 | } | 330 | } |
326 | 331 | ||
@@ -331,18 +336,25 @@ struct ubifs_scan_leb *ubifs_scan(const struct ubifs_info *c, int lnum, | |||
331 | break; | 336 | break; |
332 | for (; len; offs++, buf++, len--) | 337 | for (; len; offs++, buf++, len--) |
333 | if (*(uint8_t *)buf != 0xff) { | 338 | if (*(uint8_t *)buf != 0xff) { |
334 | ubifs_err("corrupt empty space at LEB %d:%d", | 339 | if (!quiet) |
335 | lnum, offs); | 340 | ubifs_err("corrupt empty space at LEB %d:%d", |
341 | lnum, offs); | ||
336 | goto corrupted; | 342 | goto corrupted; |
337 | } | 343 | } |
338 | 344 | ||
339 | return sleb; | 345 | return sleb; |
340 | 346 | ||
341 | corrupted: | 347 | corrupted: |
342 | ubifs_scanned_corruption(c, lnum, offs, buf); | 348 | if (!quiet) { |
349 | ubifs_scanned_corruption(c, lnum, offs, buf); | ||
350 | ubifs_err("LEB %d scanning failed", lnum); | ||
351 | } | ||
343 | err = -EUCLEAN; | 352 | err = -EUCLEAN; |
353 | ubifs_scan_destroy(sleb); | ||
354 | return ERR_PTR(err); | ||
355 | |||
344 | error: | 356 | error: |
345 | ubifs_err("LEB %d scanning failed", lnum); | 357 | ubifs_err("LEB %d scanning failed, error %d", lnum, err); |
346 | ubifs_scan_destroy(sleb); | 358 | ubifs_scan_destroy(sleb); |
347 | return ERR_PTR(err); | 359 | return ERR_PTR(err); |
348 | } | 360 | } |