io.c (cdd38c5f1ce4398ec58fec95904b75824daab7b5) | io.c (2e3cbf425804fb44a005e252f88f93dff108c911) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * This file is part of UBIFS. 4 * 5 * Copyright (C) 2006-2008 Nokia Corporation. 6 * Copyright (C) 2006, 2007 University of Szeged, Hungary 7 * 8 * Authors: Artem Bityutskiy (Битюцкий Артём) --- 180 unchanged lines hidden (view full) --- 189 if (err < 0) { 190 ubifs_err(c, "ubi_is_mapped failed for LEB %d, error %d", 191 lnum, err); 192 dump_stack(); 193 } 194 return err; 195} 196 | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * This file is part of UBIFS. 4 * 5 * Copyright (C) 2006-2008 Nokia Corporation. 6 * Copyright (C) 2006, 2007 University of Szeged, Hungary 7 * 8 * Authors: Artem Bityutskiy (Битюцкий Артём) --- 180 unchanged lines hidden (view full) --- 189 if (err < 0) { 190 ubifs_err(c, "ubi_is_mapped failed for LEB %d, error %d", 191 lnum, err); 192 dump_stack(); 193 } 194 return err; 195} 196 |
197static void record_magic_error(struct ubifs_stats_info *stats) 198{ 199 if (stats) 200 stats->magic_errors++; 201} 202 203static void record_node_error(struct ubifs_stats_info *stats) 204{ 205 if (stats) 206 stats->node_errors++; 207} 208 209static void record_crc_error(struct ubifs_stats_info *stats) 210{ 211 if (stats) 212 stats->crc_errors++; 213} 214 |
|
197/** 198 * ubifs_check_node - check node. 199 * @c: UBIFS file-system description object 200 * @buf: node to check 201 * @len: node length 202 * @lnum: logical eraseblock number 203 * @offs: offset within the logical eraseblock 204 * @quiet: print no messages --- 28 unchanged lines hidden (view full) --- 233 ubifs_assert(c, lnum >= 0 && lnum < c->leb_cnt && offs >= 0); 234 ubifs_assert(c, !(offs & 7) && offs < c->leb_size); 235 236 magic = le32_to_cpu(ch->magic); 237 if (magic != UBIFS_NODE_MAGIC) { 238 if (!quiet) 239 ubifs_err(c, "bad magic %#08x, expected %#08x", 240 magic, UBIFS_NODE_MAGIC); | 215/** 216 * ubifs_check_node - check node. 217 * @c: UBIFS file-system description object 218 * @buf: node to check 219 * @len: node length 220 * @lnum: logical eraseblock number 221 * @offs: offset within the logical eraseblock 222 * @quiet: print no messages --- 28 unchanged lines hidden (view full) --- 251 ubifs_assert(c, lnum >= 0 && lnum < c->leb_cnt && offs >= 0); 252 ubifs_assert(c, !(offs & 7) && offs < c->leb_size); 253 254 magic = le32_to_cpu(ch->magic); 255 if (magic != UBIFS_NODE_MAGIC) { 256 if (!quiet) 257 ubifs_err(c, "bad magic %#08x, expected %#08x", 258 magic, UBIFS_NODE_MAGIC); |
259 record_magic_error(c->stats); |
|
241 err = -EUCLEAN; 242 goto out; 243 } 244 245 type = ch->node_type; 246 if (type < 0 || type >= UBIFS_NODE_TYPES_CNT) { 247 if (!quiet) 248 ubifs_err(c, "bad node type %d", type); | 260 err = -EUCLEAN; 261 goto out; 262 } 263 264 type = ch->node_type; 265 if (type < 0 || type >= UBIFS_NODE_TYPES_CNT) { 266 if (!quiet) 267 ubifs_err(c, "bad node type %d", type); |
268 record_node_error(c->stats); |
|
249 goto out; 250 } 251 252 node_len = le32_to_cpu(ch->len); 253 if (node_len + offs > c->leb_size) 254 goto out_len; 255 256 if (c->ranges[type].max_len == 0) { --- 8 unchanged lines hidden (view full) --- 265 return 0; 266 267 crc = crc32(UBIFS_CRC32_INIT, buf + 8, node_len - 8); 268 node_crc = le32_to_cpu(ch->crc); 269 if (crc != node_crc) { 270 if (!quiet) 271 ubifs_err(c, "bad CRC: calculated %#08x, read %#08x", 272 crc, node_crc); | 269 goto out; 270 } 271 272 node_len = le32_to_cpu(ch->len); 273 if (node_len + offs > c->leb_size) 274 goto out_len; 275 276 if (c->ranges[type].max_len == 0) { --- 8 unchanged lines hidden (view full) --- 285 return 0; 286 287 crc = crc32(UBIFS_CRC32_INIT, buf + 8, node_len - 8); 288 node_crc = le32_to_cpu(ch->crc); 289 if (crc != node_crc) { 290 if (!quiet) 291 ubifs_err(c, "bad CRC: calculated %#08x, read %#08x", 292 crc, node_crc); |
293 record_crc_error(c->stats); |
|
273 err = -EUCLEAN; 274 goto out; 275 } 276 277 return 0; 278 279out_len: 280 if (!quiet) --- 941 unchanged lines hidden --- | 294 err = -EUCLEAN; 295 goto out; 296 } 297 298 return 0; 299 300out_len: 301 if (!quiet) --- 941 unchanged lines hidden --- |