2019-05-30 01:57:50 +02:00
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2008-07-14 18:08:37 +02:00
|
|
|
|
/*
|
|
|
|
|
* This file is part of UBIFS.
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2006-2008 Nokia Corporation
|
|
|
|
|
*
|
|
|
|
|
* Authors: Adrian Hunter
|
|
|
|
|
* Artem Bityutskiy (Битюцкий Артём)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This file implements the scan which is a general-purpose function for
|
|
|
|
|
* determining what nodes are in an eraseblock. The scan is used to replay the
|
|
|
|
|
* journal, to do garbage collection. for the TNC in-the-gaps method, and by
|
|
|
|
|
* debugging functions.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "ubifs.h"
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* scan_padding_bytes - scan for padding bytes.
|
|
|
|
|
* @buf: buffer to scan
|
|
|
|
|
* @len: length of buffer
|
|
|
|
|
*
|
|
|
|
|
* This function returns the number of padding bytes on success and
|
|
|
|
|
* %SCANNED_GARBAGE on failure.
|
|
|
|
|
*/
|
|
|
|
|
static int scan_padding_bytes(void *buf, int len)
|
|
|
|
|
{
|
|
|
|
|
int pad_len = 0, max_pad_len = min_t(int, UBIFS_PAD_NODE_SZ, len);
|
|
|
|
|
uint8_t *p = buf;
|
|
|
|
|
|
|
|
|
|
dbg_scan("not a node");
|
|
|
|
|
|
|
|
|
|
while (pad_len < max_pad_len && *p++ == UBIFS_PADDING_BYTE)
|
|
|
|
|
pad_len += 1;
|
|
|
|
|
|
|
|
|
|
if (!pad_len || (pad_len & 7))
|
|
|
|
|
return SCANNED_GARBAGE;
|
|
|
|
|
|
|
|
|
|
dbg_scan("%d padding bytes", pad_len);
|
|
|
|
|
|
|
|
|
|
return pad_len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ubifs_scan_a_node - scan for a node or padding.
|
|
|
|
|
* @c: UBIFS file-system description object
|
|
|
|
|
* @buf: buffer to scan
|
|
|
|
|
* @len: length of buffer
|
|
|
|
|
* @lnum: logical eraseblock number
|
|
|
|
|
* @offs: offset within the logical eraseblock
|
|
|
|
|
* @quiet: print no messages
|
|
|
|
|
*
|
|
|
|
|
* This function returns a scanning code to indicate what was scanned.
|
|
|
|
|
*/
|
|
|
|
|
int ubifs_scan_a_node(const struct ubifs_info *c, void *buf, int len, int lnum,
|
|
|
|
|
int offs, int quiet)
|
|
|
|
|
{
|
|
|
|
|
struct ubifs_ch *ch = buf;
|
|
|
|
|
uint32_t magic;
|
|
|
|
|
|
|
|
|
|
magic = le32_to_cpu(ch->magic);
|
|
|
|
|
|
|
|
|
|
if (magic == 0xFFFFFFFF) {
|
2012-08-23 16:28:58 +02:00
|
|
|
|
dbg_scan("hit empty space at LEB %d:%d", lnum, offs);
|
2008-07-14 18:08:37 +02:00
|
|
|
|
return SCANNED_EMPTY_SPACE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (magic != UBIFS_NODE_MAGIC)
|
|
|
|
|
return scan_padding_bytes(buf, len);
|
|
|
|
|
|
|
|
|
|
if (len < UBIFS_CH_SZ)
|
|
|
|
|
return SCANNED_GARBAGE;
|
|
|
|
|
|
2012-08-27 12:34:09 +02:00
|
|
|
|
dbg_scan("scanning %s at LEB %d:%d",
|
|
|
|
|
dbg_ntype(ch->node_type), lnum, offs);
|
2008-07-14 18:08:37 +02:00
|
|
|
|
|
2008-09-04 15:26:00 +02:00
|
|
|
|
if (ubifs_check_node(c, buf, lnum, offs, quiet, 1))
|
2008-07-14 18:08:37 +02:00
|
|
|
|
return SCANNED_A_CORRUPT_NODE;
|
|
|
|
|
|
|
|
|
|
if (ch->node_type == UBIFS_PAD_NODE) {
|
|
|
|
|
struct ubifs_pad_node *pad = buf;
|
|
|
|
|
int pad_len = le32_to_cpu(pad->pad_len);
|
|
|
|
|
int node_len = le32_to_cpu(ch->len);
|
|
|
|
|
|
|
|
|
|
/* Validate the padding node */
|
|
|
|
|
if (pad_len < 0 ||
|
|
|
|
|
offs + node_len + pad_len > c->leb_size) {
|
|
|
|
|
if (!quiet) {
|
UBIFS: extend debug/message capabilities
In the case where we have more than one volumes on different UBI
devices, it may be not that easy to tell which volume prints the
messages. Add ubi number and volume id in ubifs_msg/warn/error
to help debug. These two values are passed by struct ubifs_info.
For those where ubifs_info is not initialized yet, ubifs_* is
replaced by pr_*. For those where ubifs_info is not avaliable,
ubifs_info is passed to the calling function as a const parameter.
The output looks like,
[ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696
[ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1"
[ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs)
[ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB)
[ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model
[ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699
[ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2"
[ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs)
[ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB)
[ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model
[ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6)
[ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-03-20 11:39:42 +01:00
|
|
|
|
ubifs_err(c, "bad pad node at LEB %d:%d",
|
2008-07-14 18:08:37 +02:00
|
|
|
|
lnum, offs);
|
2012-05-16 18:15:56 +02:00
|
|
|
|
ubifs_dump_node(c, pad);
|
2008-07-14 18:08:37 +02:00
|
|
|
|
}
|
|
|
|
|
return SCANNED_A_BAD_PAD_NODE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Make the node pads to 8-byte boundary */
|
|
|
|
|
if ((node_len + pad_len) & 7) {
|
2009-08-25 14:00:55 +02:00
|
|
|
|
if (!quiet)
|
UBIFS: extend debug/message capabilities
In the case where we have more than one volumes on different UBI
devices, it may be not that easy to tell which volume prints the
messages. Add ubi number and volume id in ubifs_msg/warn/error
to help debug. These two values are passed by struct ubifs_info.
For those where ubifs_info is not initialized yet, ubifs_* is
replaced by pr_*. For those where ubifs_info is not avaliable,
ubifs_info is passed to the calling function as a const parameter.
The output looks like,
[ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696
[ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1"
[ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs)
[ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB)
[ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model
[ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699
[ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2"
[ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs)
[ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB)
[ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model
[ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6)
[ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-03-20 11:39:42 +01:00
|
|
|
|
ubifs_err(c, "bad padding length %d - %d",
|
2012-05-16 19:11:23 +02:00
|
|
|
|
offs, offs + node_len + pad_len);
|
2008-07-14 18:08:37 +02:00
|
|
|
|
return SCANNED_A_BAD_PAD_NODE;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-23 16:28:58 +02:00
|
|
|
|
dbg_scan("%d bytes padded at LEB %d:%d, offset now %d", pad_len,
|
|
|
|
|
lnum, offs, ALIGN(offs + node_len + pad_len, 8));
|
2008-07-14 18:08:37 +02:00
|
|
|
|
|
|
|
|
|
return node_len + pad_len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return SCANNED_A_NODE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ubifs_start_scan - create LEB scanning information at start of scan.
|
|
|
|
|
* @c: UBIFS file-system description object
|
|
|
|
|
* @lnum: logical eraseblock number
|
|
|
|
|
* @offs: offset to start at (usually zero)
|
|
|
|
|
* @sbuf: scan buffer (must be c->leb_size)
|
|
|
|
|
*
|
2014-07-01 17:32:15 +02:00
|
|
|
|
* This function returns the scanned information on success and a negative error
|
2014-07-01 16:45:25 +02:00
|
|
|
|
* code on failure.
|
2008-07-14 18:08:37 +02:00
|
|
|
|
*/
|
|
|
|
|
struct ubifs_scan_leb *ubifs_start_scan(const struct ubifs_info *c, int lnum,
|
|
|
|
|
int offs, void *sbuf)
|
|
|
|
|
{
|
|
|
|
|
struct ubifs_scan_leb *sleb;
|
|
|
|
|
int err;
|
|
|
|
|
|
|
|
|
|
dbg_scan("scan LEB %d:%d", lnum, offs);
|
|
|
|
|
|
|
|
|
|
sleb = kzalloc(sizeof(struct ubifs_scan_leb), GFP_NOFS);
|
|
|
|
|
if (!sleb)
|
|
|
|
|
return ERR_PTR(-ENOMEM);
|
|
|
|
|
|
|
|
|
|
sleb->lnum = lnum;
|
|
|
|
|
INIT_LIST_HEAD(&sleb->nodes);
|
|
|
|
|
sleb->buf = sbuf;
|
|
|
|
|
|
2011-06-03 13:03:25 +02:00
|
|
|
|
err = ubifs_leb_read(c, lnum, sbuf + offs, offs, c->leb_size - offs, 0);
|
2008-07-14 18:08:37 +02:00
|
|
|
|
if (err && err != -EBADMSG) {
|
UBIFS: extend debug/message capabilities
In the case where we have more than one volumes on different UBI
devices, it may be not that easy to tell which volume prints the
messages. Add ubi number and volume id in ubifs_msg/warn/error
to help debug. These two values are passed by struct ubifs_info.
For those where ubifs_info is not initialized yet, ubifs_* is
replaced by pr_*. For those where ubifs_info is not avaliable,
ubifs_info is passed to the calling function as a const parameter.
The output looks like,
[ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696
[ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1"
[ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs)
[ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB)
[ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model
[ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699
[ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2"
[ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs)
[ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB)
[ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model
[ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6)
[ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-03-20 11:39:42 +01:00
|
|
|
|
ubifs_err(c, "cannot read %d bytes from LEB %d:%d, error %d",
|
2012-08-27 12:34:09 +02:00
|
|
|
|
c->leb_size - offs, lnum, offs, err);
|
2008-07-14 18:08:37 +02:00
|
|
|
|
kfree(sleb);
|
|
|
|
|
return ERR_PTR(err);
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-24 05:46:36 +02:00
|
|
|
|
/*
|
|
|
|
|
* Note, we ignore integrity errors (EBASMSG) because all the nodes are
|
|
|
|
|
* protected by CRC checksums.
|
|
|
|
|
*/
|
2008-07-14 18:08:37 +02:00
|
|
|
|
return sleb;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ubifs_end_scan - update LEB scanning information at end of scan.
|
|
|
|
|
* @c: UBIFS file-system description object
|
|
|
|
|
* @sleb: scanning information
|
|
|
|
|
* @lnum: logical eraseblock number
|
|
|
|
|
* @offs: offset to start at (usually zero)
|
|
|
|
|
*/
|
|
|
|
|
void ubifs_end_scan(const struct ubifs_info *c, struct ubifs_scan_leb *sleb,
|
|
|
|
|
int lnum, int offs)
|
|
|
|
|
{
|
|
|
|
|
dbg_scan("stop scanning LEB %d at offset %d", lnum, offs);
|
2018-07-12 13:01:57 +02:00
|
|
|
|
ubifs_assert(c, offs % c->min_io_size == 0);
|
2008-07-14 18:08:37 +02:00
|
|
|
|
|
|
|
|
|
sleb->endpt = ALIGN(offs, c->min_io_size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ubifs_add_snod - add a scanned node to LEB scanning information.
|
|
|
|
|
* @c: UBIFS file-system description object
|
|
|
|
|
* @sleb: scanning information
|
|
|
|
|
* @buf: buffer containing node
|
|
|
|
|
* @offs: offset of node on flash
|
|
|
|
|
*
|
|
|
|
|
* This function returns %0 on success and a negative error code on failure.
|
|
|
|
|
*/
|
|
|
|
|
int ubifs_add_snod(const struct ubifs_info *c, struct ubifs_scan_leb *sleb,
|
|
|
|
|
void *buf, int offs)
|
|
|
|
|
{
|
|
|
|
|
struct ubifs_ch *ch = buf;
|
|
|
|
|
struct ubifs_ino_node *ino = buf;
|
|
|
|
|
struct ubifs_scan_node *snod;
|
|
|
|
|
|
2010-08-22 06:10:12 +02:00
|
|
|
|
snod = kmalloc(sizeof(struct ubifs_scan_node), GFP_NOFS);
|
2008-07-14 18:08:37 +02:00
|
|
|
|
if (!snod)
|
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
|
|
snod->sqnum = le64_to_cpu(ch->sqnum);
|
|
|
|
|
snod->type = ch->node_type;
|
|
|
|
|
snod->offs = offs;
|
|
|
|
|
snod->len = le32_to_cpu(ch->len);
|
|
|
|
|
snod->node = buf;
|
|
|
|
|
|
|
|
|
|
switch (ch->node_type) {
|
|
|
|
|
case UBIFS_INO_NODE:
|
|
|
|
|
case UBIFS_DENT_NODE:
|
|
|
|
|
case UBIFS_XENT_NODE:
|
|
|
|
|
case UBIFS_DATA_NODE:
|
|
|
|
|
/*
|
|
|
|
|
* The key is in the same place in all keyed
|
|
|
|
|
* nodes.
|
|
|
|
|
*/
|
|
|
|
|
key_read(c, &ino->key, &snod->key);
|
|
|
|
|
break;
|
2010-08-22 06:10:12 +02:00
|
|
|
|
default:
|
|
|
|
|
invalid_key_init(c, &snod->key);
|
|
|
|
|
break;
|
2008-07-14 18:08:37 +02:00
|
|
|
|
}
|
|
|
|
|
list_add_tail(&snod->list, &sleb->nodes);
|
|
|
|
|
sleb->nodes_cnt += 1;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ubifs_scanned_corruption - print information after UBIFS scanned corruption.
|
|
|
|
|
* @c: UBIFS file-system description object
|
|
|
|
|
* @lnum: LEB number of corruption
|
|
|
|
|
* @offs: offset of corruption
|
|
|
|
|
* @buf: buffer containing corruption
|
|
|
|
|
*/
|
|
|
|
|
void ubifs_scanned_corruption(const struct ubifs_info *c, int lnum, int offs,
|
|
|
|
|
void *buf)
|
|
|
|
|
{
|
|
|
|
|
int len;
|
|
|
|
|
|
UBIFS: extend debug/message capabilities
In the case where we have more than one volumes on different UBI
devices, it may be not that easy to tell which volume prints the
messages. Add ubi number and volume id in ubifs_msg/warn/error
to help debug. These two values are passed by struct ubifs_info.
For those where ubifs_info is not initialized yet, ubifs_* is
replaced by pr_*. For those where ubifs_info is not avaliable,
ubifs_info is passed to the calling function as a const parameter.
The output looks like,
[ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696
[ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1"
[ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs)
[ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB)
[ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model
[ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699
[ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2"
[ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs)
[ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB)
[ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model
[ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6)
[ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-03-20 11:39:42 +01:00
|
|
|
|
ubifs_err(c, "corruption at LEB %d:%d", lnum, offs);
|
2008-07-14 18:08:37 +02:00
|
|
|
|
len = c->leb_size - offs;
|
2009-06-29 15:25:33 +02:00
|
|
|
|
if (len > 8192)
|
|
|
|
|
len = 8192;
|
UBIFS: extend debug/message capabilities
In the case where we have more than one volumes on different UBI
devices, it may be not that easy to tell which volume prints the
messages. Add ubi number and volume id in ubifs_msg/warn/error
to help debug. These two values are passed by struct ubifs_info.
For those where ubifs_info is not initialized yet, ubifs_* is
replaced by pr_*. For those where ubifs_info is not avaliable,
ubifs_info is passed to the calling function as a const parameter.
The output looks like,
[ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696
[ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1"
[ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs)
[ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB)
[ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model
[ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699
[ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2"
[ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs)
[ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB)
[ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model
[ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6)
[ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-03-20 11:39:42 +01:00
|
|
|
|
ubifs_err(c, "first %d bytes from LEB %d:%d", len, lnum, offs);
|
2008-07-14 18:08:37 +02:00
|
|
|
|
print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 4, buf, len, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ubifs_scan - scan a logical eraseblock.
|
|
|
|
|
* @c: UBIFS file-system description object
|
|
|
|
|
* @lnum: logical eraseblock number
|
|
|
|
|
* @offs: offset to start at (usually zero)
|
2009-08-25 14:00:55 +02:00
|
|
|
|
* @sbuf: scan buffer (must be of @c->leb_size bytes in size)
|
|
|
|
|
* @quiet: print no messages
|
2008-07-14 18:08:37 +02:00
|
|
|
|
*
|
|
|
|
|
* This function scans LEB number @lnum and returns complete information about
|
2014-07-01 17:32:15 +02:00
|
|
|
|
* its contents. Returns the scanned information in case of success and,
|
2009-06-29 16:59:23 +02:00
|
|
|
|
* %-EUCLEAN if the LEB neads recovery, and other negative error codes in case
|
|
|
|
|
* of failure.
|
2009-08-25 14:00:55 +02:00
|
|
|
|
*
|
|
|
|
|
* If @quiet is non-zero, this function does not print large and scary
|
|
|
|
|
* error messages and flash dumps in case of errors.
|
2008-07-14 18:08:37 +02:00
|
|
|
|
*/
|
|
|
|
|
struct ubifs_scan_leb *ubifs_scan(const struct ubifs_info *c, int lnum,
|
2009-08-25 14:00:55 +02:00
|
|
|
|
int offs, void *sbuf, int quiet)
|
2008-07-14 18:08:37 +02:00
|
|
|
|
{
|
|
|
|
|
void *buf = sbuf + offs;
|
|
|
|
|
int err, len = c->leb_size - offs;
|
|
|
|
|
struct ubifs_scan_leb *sleb;
|
|
|
|
|
|
|
|
|
|
sleb = ubifs_start_scan(c, lnum, offs, sbuf);
|
|
|
|
|
if (IS_ERR(sleb))
|
|
|
|
|
return sleb;
|
|
|
|
|
|
|
|
|
|
while (len >= 8) {
|
|
|
|
|
struct ubifs_ch *ch = buf;
|
|
|
|
|
int node_len, ret;
|
|
|
|
|
|
|
|
|
|
dbg_scan("look at LEB %d:%d (%d bytes left)",
|
|
|
|
|
lnum, offs, len);
|
|
|
|
|
|
|
|
|
|
cond_resched();
|
|
|
|
|
|
2009-08-25 14:00:55 +02:00
|
|
|
|
ret = ubifs_scan_a_node(c, buf, len, lnum, offs, quiet);
|
2008-07-14 18:08:37 +02:00
|
|
|
|
if (ret > 0) {
|
|
|
|
|
/* Padding bytes or a valid padding node */
|
|
|
|
|
offs += ret;
|
|
|
|
|
buf += ret;
|
|
|
|
|
len -= ret;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ret == SCANNED_EMPTY_SPACE)
|
|
|
|
|
/* Empty space is checked later */
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
switch (ret) {
|
|
|
|
|
case SCANNED_GARBAGE:
|
UBIFS: extend debug/message capabilities
In the case where we have more than one volumes on different UBI
devices, it may be not that easy to tell which volume prints the
messages. Add ubi number and volume id in ubifs_msg/warn/error
to help debug. These two values are passed by struct ubifs_info.
For those where ubifs_info is not initialized yet, ubifs_* is
replaced by pr_*. For those where ubifs_info is not avaliable,
ubifs_info is passed to the calling function as a const parameter.
The output looks like,
[ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696
[ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1"
[ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs)
[ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB)
[ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model
[ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699
[ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2"
[ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs)
[ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB)
[ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model
[ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6)
[ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-03-20 11:39:42 +01:00
|
|
|
|
ubifs_err(c, "garbage");
|
2008-07-14 18:08:37 +02:00
|
|
|
|
goto corrupted;
|
|
|
|
|
case SCANNED_A_NODE:
|
|
|
|
|
break;
|
|
|
|
|
case SCANNED_A_CORRUPT_NODE:
|
|
|
|
|
case SCANNED_A_BAD_PAD_NODE:
|
UBIFS: extend debug/message capabilities
In the case where we have more than one volumes on different UBI
devices, it may be not that easy to tell which volume prints the
messages. Add ubi number and volume id in ubifs_msg/warn/error
to help debug. These two values are passed by struct ubifs_info.
For those where ubifs_info is not initialized yet, ubifs_* is
replaced by pr_*. For those where ubifs_info is not avaliable,
ubifs_info is passed to the calling function as a const parameter.
The output looks like,
[ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696
[ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1"
[ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs)
[ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB)
[ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model
[ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699
[ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2"
[ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs)
[ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB)
[ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model
[ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6)
[ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-03-20 11:39:42 +01:00
|
|
|
|
ubifs_err(c, "bad node");
|
2008-07-14 18:08:37 +02:00
|
|
|
|
goto corrupted;
|
|
|
|
|
default:
|
UBIFS: extend debug/message capabilities
In the case where we have more than one volumes on different UBI
devices, it may be not that easy to tell which volume prints the
messages. Add ubi number and volume id in ubifs_msg/warn/error
to help debug. These two values are passed by struct ubifs_info.
For those where ubifs_info is not initialized yet, ubifs_* is
replaced by pr_*. For those where ubifs_info is not avaliable,
ubifs_info is passed to the calling function as a const parameter.
The output looks like,
[ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696
[ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1"
[ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs)
[ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB)
[ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model
[ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699
[ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2"
[ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs)
[ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB)
[ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model
[ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6)
[ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-03-20 11:39:42 +01:00
|
|
|
|
ubifs_err(c, "unknown");
|
2009-06-29 16:59:23 +02:00
|
|
|
|
err = -EINVAL;
|
|
|
|
|
goto error;
|
2008-07-14 18:08:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err = ubifs_add_snod(c, sleb, buf, offs);
|
|
|
|
|
if (err)
|
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
|
|
node_len = ALIGN(le32_to_cpu(ch->len), 8);
|
|
|
|
|
offs += node_len;
|
|
|
|
|
buf += node_len;
|
|
|
|
|
len -= node_len;
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-29 16:59:23 +02:00
|
|
|
|
if (offs % c->min_io_size) {
|
2009-08-25 14:00:55 +02:00
|
|
|
|
if (!quiet)
|
UBIFS: extend debug/message capabilities
In the case where we have more than one volumes on different UBI
devices, it may be not that easy to tell which volume prints the
messages. Add ubi number and volume id in ubifs_msg/warn/error
to help debug. These two values are passed by struct ubifs_info.
For those where ubifs_info is not initialized yet, ubifs_* is
replaced by pr_*. For those where ubifs_info is not avaliable,
ubifs_info is passed to the calling function as a const parameter.
The output looks like,
[ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696
[ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1"
[ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs)
[ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB)
[ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model
[ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699
[ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2"
[ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs)
[ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB)
[ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model
[ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6)
[ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-03-20 11:39:42 +01:00
|
|
|
|
ubifs_err(c, "empty space starts at non-aligned offset %d",
|
2009-08-25 14:00:55 +02:00
|
|
|
|
offs);
|
2011-02-06 13:49:26 +01:00
|
|
|
|
goto corrupted;
|
2009-06-29 16:59:23 +02:00
|
|
|
|
}
|
2008-07-14 18:08:37 +02:00
|
|
|
|
|
|
|
|
|
ubifs_end_scan(c, sleb, lnum, offs);
|
|
|
|
|
|
|
|
|
|
for (; len > 4; offs += 4, buf = buf + 4, len -= 4)
|
|
|
|
|
if (*(uint32_t *)buf != 0xffffffff)
|
|
|
|
|
break;
|
|
|
|
|
for (; len; offs++, buf++, len--)
|
|
|
|
|
if (*(uint8_t *)buf != 0xff) {
|
2009-08-25 14:00:55 +02:00
|
|
|
|
if (!quiet)
|
UBIFS: extend debug/message capabilities
In the case where we have more than one volumes on different UBI
devices, it may be not that easy to tell which volume prints the
messages. Add ubi number and volume id in ubifs_msg/warn/error
to help debug. These two values are passed by struct ubifs_info.
For those where ubifs_info is not initialized yet, ubifs_* is
replaced by pr_*. For those where ubifs_info is not avaliable,
ubifs_info is passed to the calling function as a const parameter.
The output looks like,
[ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696
[ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1"
[ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs)
[ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB)
[ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model
[ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699
[ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2"
[ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs)
[ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB)
[ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model
[ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6)
[ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-03-20 11:39:42 +01:00
|
|
|
|
ubifs_err(c, "corrupt empty space at LEB %d:%d",
|
2009-08-25 14:00:55 +02:00
|
|
|
|
lnum, offs);
|
2008-07-14 18:08:37 +02:00
|
|
|
|
goto corrupted;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return sleb;
|
|
|
|
|
|
|
|
|
|
corrupted:
|
2009-08-25 14:00:55 +02:00
|
|
|
|
if (!quiet) {
|
|
|
|
|
ubifs_scanned_corruption(c, lnum, offs, buf);
|
UBIFS: extend debug/message capabilities
In the case where we have more than one volumes on different UBI
devices, it may be not that easy to tell which volume prints the
messages. Add ubi number and volume id in ubifs_msg/warn/error
to help debug. These two values are passed by struct ubifs_info.
For those where ubifs_info is not initialized yet, ubifs_* is
replaced by pr_*. For those where ubifs_info is not avaliable,
ubifs_info is passed to the calling function as a const parameter.
The output looks like,
[ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696
[ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1"
[ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs)
[ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB)
[ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model
[ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699
[ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2"
[ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs)
[ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB)
[ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model
[ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6)
[ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-03-20 11:39:42 +01:00
|
|
|
|
ubifs_err(c, "LEB %d scanning failed", lnum);
|
2009-08-25 14:00:55 +02:00
|
|
|
|
}
|
2008-07-14 18:08:37 +02:00
|
|
|
|
err = -EUCLEAN;
|
2009-08-25 14:00:55 +02:00
|
|
|
|
ubifs_scan_destroy(sleb);
|
|
|
|
|
return ERR_PTR(err);
|
|
|
|
|
|
2008-07-14 18:08:37 +02:00
|
|
|
|
error:
|
UBIFS: extend debug/message capabilities
In the case where we have more than one volumes on different UBI
devices, it may be not that easy to tell which volume prints the
messages. Add ubi number and volume id in ubifs_msg/warn/error
to help debug. These two values are passed by struct ubifs_info.
For those where ubifs_info is not initialized yet, ubifs_* is
replaced by pr_*. For those where ubifs_info is not avaliable,
ubifs_info is passed to the calling function as a const parameter.
The output looks like,
[ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696
[ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1"
[ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs)
[ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB)
[ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model
[ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699
[ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2"
[ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs)
[ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB)
[ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model
[ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6)
[ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2015-03-20 11:39:42 +01:00
|
|
|
|
ubifs_err(c, "LEB %d scanning failed, error %d", lnum, err);
|
2008-07-14 18:08:37 +02:00
|
|
|
|
ubifs_scan_destroy(sleb);
|
|
|
|
|
return ERR_PTR(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ubifs_scan_destroy - destroy LEB scanning information.
|
|
|
|
|
* @sleb: scanning information to free
|
|
|
|
|
*/
|
|
|
|
|
void ubifs_scan_destroy(struct ubifs_scan_leb *sleb)
|
|
|
|
|
{
|
|
|
|
|
struct ubifs_scan_node *node;
|
|
|
|
|
struct list_head *head;
|
|
|
|
|
|
|
|
|
|
head = &sleb->nodes;
|
|
|
|
|
while (!list_empty(head)) {
|
|
|
|
|
node = list_entry(head->next, struct ubifs_scan_node, list);
|
|
|
|
|
list_del(&node->list);
|
|
|
|
|
kfree(node);
|
|
|
|
|
}
|
|
|
|
|
kfree(sleb);
|
|
|
|
|
}
|