diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2009-06-29 10:59:23 -0400 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2009-07-09 02:19:38 -0400 |
commit | ed43f2f06cc1cec7ec2dc235c908530bc8c796eb (patch) | |
tree | 7d178c64dc5a758487cc0fca834c4ab42e62febc /fs/ubifs/scan.c | |
parent | 086b3640c10ab448a6993c4bae1508f496f530c4 (diff) |
UBIFS: small amendments in the LEB scanning code
This patch fixes few minor things I've spotted while going through
code:
1. Better document return codes
2. If 'ubifs_scan_a_node()' returns some thing we do not expect,
treat this as an error.
3. Try to do recovery only when 'ubifs_scan()' returns %-EUCLEAN,
not on any error.
4. If empty space starts at a non-aligned address, print a message.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Reviewed-by: Adrian Hunter <Adrian.Hunter@nokia.com>
Diffstat (limited to 'fs/ubifs/scan.c')
-rw-r--r-- | fs/ubifs/scan.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/fs/ubifs/scan.c b/fs/ubifs/scan.c index 165c14ba1a46..892ebfee4fe5 100644 --- a/fs/ubifs/scan.c +++ b/fs/ubifs/scan.c | |||
@@ -256,7 +256,9 @@ void ubifs_scanned_corruption(const struct ubifs_info *c, int lnum, int offs, | |||
256 | * @sbuf: scan buffer (must be c->leb_size) | 256 | * @sbuf: scan buffer (must be c->leb_size) |
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 an error code in case of failure. | 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 | ||
261 | * of failure. | ||
260 | */ | 262 | */ |
261 | struct ubifs_scan_leb *ubifs_scan(const struct ubifs_info *c, int lnum, | 263 | struct ubifs_scan_leb *ubifs_scan(const struct ubifs_info *c, int lnum, |
262 | int offs, void *sbuf) | 264 | int offs, void *sbuf) |
@@ -279,7 +281,6 @@ struct ubifs_scan_leb *ubifs_scan(const struct ubifs_info *c, int lnum, | |||
279 | cond_resched(); | 281 | cond_resched(); |
280 | 282 | ||
281 | ret = ubifs_scan_a_node(c, buf, len, lnum, offs, 0); | 283 | ret = ubifs_scan_a_node(c, buf, len, lnum, offs, 0); |
282 | |||
283 | if (ret > 0) { | 284 | if (ret > 0) { |
284 | /* Padding bytes or a valid padding node */ | 285 | /* Padding bytes or a valid padding node */ |
285 | offs += ret; | 286 | offs += ret; |
@@ -304,7 +305,8 @@ struct ubifs_scan_leb *ubifs_scan(const struct ubifs_info *c, int lnum, | |||
304 | goto corrupted; | 305 | goto corrupted; |
305 | default: | 306 | default: |
306 | dbg_err("unknown"); | 307 | dbg_err("unknown"); |
307 | goto corrupted; | 308 | err = -EINVAL; |
309 | goto error; | ||
308 | } | 310 | } |
309 | 311 | ||
310 | err = ubifs_add_snod(c, sleb, buf, offs); | 312 | err = ubifs_add_snod(c, sleb, buf, offs); |
@@ -317,8 +319,10 @@ struct ubifs_scan_leb *ubifs_scan(const struct ubifs_info *c, int lnum, | |||
317 | len -= node_len; | 319 | len -= node_len; |
318 | } | 320 | } |
319 | 321 | ||
320 | if (offs % c->min_io_size) | 322 | if (offs % c->min_io_size) { |
321 | goto corrupted; | 323 | ubifs_err("empty space starts at non-aligned offset %d", offs); |
324 | goto corrupted;; | ||
325 | } | ||
322 | 326 | ||
323 | ubifs_end_scan(c, sleb, lnum, offs); | 327 | ubifs_end_scan(c, sleb, lnum, offs); |
324 | 328 | ||