]> git.ipfire.org Git - thirdparty/e2fsprogs.git/blame - e2fsck/super.c
libext2fs: fix function declarations to match definition
[thirdparty/e2fsprogs.git] / e2fsck / super.c
CommitLineData
1b6bf175
TT
1/*
2 * e2fsck.c - superblock checks
efc6f628 3 *
1b6bf175
TT
4 * Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o.
5 *
6 * %Begin-Header%
7 * This file may be redistributed under the terms of the GNU Public
8 * License.
9 * %End-Header%
10 */
11
d1154eb4 12#include "config.h"
1b6bf175
TT
13#ifdef HAVE_ERRNO_H
14#include <errno.h>
15#endif
1b6bf175 16
54be2ccc 17#ifndef EXT2_SKIP_UUID
1b6bf175 18#include "uuid/uuid.h"
54be2ccc 19#endif
1b6bf175
TT
20#include "e2fsck.h"
21#include "problem.h"
1b6bf175
TT
22
23#define MIN_CHECK 1
24#define MAX_CHECK 2
25
26static void check_super_value(e2fsck_t ctx, const char *descr,
27 unsigned long value, int flags,
7f813ba3 28 unsigned long min_val, unsigned long max_val)
1b6bf175
TT
29{
30 struct problem_context pctx;
31
7f813ba3
TT
32 if (((flags & MIN_CHECK) && (value < min_val)) ||
33 ((flags & MAX_CHECK) && (value > max_val))) {
1b6bf175
TT
34 clear_problem_context(&pctx);
35 pctx.num = value;
36 pctx.str = descr;
37 fix_problem(ctx, PR_0_MISC_CORRUPT_SUPER, &pctx);
08b21301 38 ctx->flags |= E2F_FLAG_ABORT; /* never get here! */
1b6bf175
TT
39 }
40}
41
80bfaa3e
TT
42/*
43 * helper function to release an inode
44 */
45struct process_block_struct {
8394902e
TT
46 e2fsck_t ctx;
47 char *buf;
80bfaa3e 48 struct problem_context *pctx;
8394902e
TT
49 int truncating;
50 int truncate_offset;
54434927 51 e2_blkcnt_t truncate_block;
8394902e
TT
52 int truncated_blocks;
53 int abort;
54 errcode_t errcode;
80bfaa3e
TT
55};
56
57static int release_inode_block(ext2_filsys fs,
6dc64392 58 blk64_t *block_nr,
54434927 59 e2_blkcnt_t blockcnt,
6dc64392 60 blk64_t ref_blk EXT2FS_ATTR((unused)),
54434927 61 int ref_offset EXT2FS_ATTR((unused)),
80bfaa3e
TT
62 void *priv_data)
63{
64 struct process_block_struct *pb;
8394902e
TT
65 e2fsck_t ctx;
66 struct problem_context *pctx;
6dc64392 67 blk64_t blk = *block_nr;
8394902e 68 int retval = 0;
80bfaa3e
TT
69
70 pb = (struct process_block_struct *) priv_data;
71 ctx = pb->ctx;
72 pctx = pb->pctx;
73
74 pctx->blk = blk;
75 pctx->blkcount = blockcnt;
76
77 if (HOLE_BLKADDR(blk))
78 return 0;
79
80 if ((blk < fs->super->s_first_data_block) ||
4efbac6f 81 (blk >= ext2fs_blocks_count(fs->super))) {
80bfaa3e 82 fix_problem(ctx, PR_0_ORPHAN_ILLEGAL_BLOCK_NUM, pctx);
53ef44c4 83 return_abort:
80bfaa3e
TT
84 pb->abort = 1;
85 return BLOCK_ABORT;
86 }
87
c5d2f50d 88 if (!ext2fs_test_block_bitmap2(fs->block_map, blk)) {
80bfaa3e 89 fix_problem(ctx, PR_0_ORPHAN_ALREADY_CLEARED_BLOCK, pctx);
53ef44c4 90 goto return_abort;
8394902e
TT
91 }
92
93 /*
94 * If we are deleting an orphan, then we leave the fields alone.
95 * If we are truncating an orphan, then update the inode fields
96 * and clean up any partial block data.
97 */
98 if (pb->truncating) {
99 /*
100 * We only remove indirect blocks if they are
101 * completely empty.
102 */
103 if (blockcnt < 0) {
104 int i, limit;
53ef44c4 105 blk_t *bp;
efc6f628 106
24a117ab 107 pb->errcode = io_channel_read_blk64(fs->io, blk, 1,
8394902e
TT
108 pb->buf);
109 if (pb->errcode)
53ef44c4 110 goto return_abort;
8394902e
TT
111
112 limit = fs->blocksize >> 2;
53ef44c4
TT
113 for (i = 0, bp = (blk_t *) pb->buf;
114 i < limit; i++, bp++)
115 if (*bp)
8394902e
TT
116 return 0;
117 }
118 /*
119 * We don't remove direct blocks until we've reached
120 * the truncation block.
121 */
122 if (blockcnt >= 0 && blockcnt < pb->truncate_block)
123 return 0;
124 /*
125 * If part of the last block needs truncating, we do
126 * it here.
127 */
128 if ((blockcnt == pb->truncate_block) && pb->truncate_offset) {
24a117ab 129 pb->errcode = io_channel_read_blk64(fs->io, blk, 1,
8394902e
TT
130 pb->buf);
131 if (pb->errcode)
53ef44c4 132 goto return_abort;
8394902e
TT
133 memset(pb->buf + pb->truncate_offset, 0,
134 fs->blocksize - pb->truncate_offset);
24a117ab 135 pb->errcode = io_channel_write_blk64(fs->io, blk, 1,
8394902e
TT
136 pb->buf);
137 if (pb->errcode)
53ef44c4 138 goto return_abort;
8394902e
TT
139 }
140 pb->truncated_blocks++;
141 *block_nr = 0;
142 retval |= BLOCK_CHANGED;
80bfaa3e 143 }
efc6f628 144
48f23054 145 ext2fs_block_alloc_stats2(fs, blk, -1);
e9e96584 146 ctx->free_blocks++;
8394902e 147 return retval;
80bfaa3e 148}
efc6f628 149
80bfaa3e
TT
150/*
151 * This function releases an inode. Returns 1 if an inconsistency was
8394902e
TT
152 * found. If the inode has a link count, then it is being truncated and
153 * not deleted.
80bfaa3e 154 */
86c627ec 155static int release_inode_blocks(e2fsck_t ctx, ext2_ino_t ino,
721edd0e 156 struct ext2_inode *inode, char *block_buf,
80bfaa3e
TT
157 struct problem_context *pctx)
158{
0684a4f3 159 struct process_block_struct pb;
8394902e 160 ext2_filsys fs = ctx->fs;
80bfaa3e 161 errcode_t retval;
0684a4f3 162 __u32 count;
80bfaa3e 163
0c80c44b 164 if (!ext2fs_inode_has_valid_blocks2(fs, inode))
42475e28
TT
165 return 0;
166
8394902e 167 pb.buf = block_buf + 3 * ctx->fs->blocksize;
80bfaa3e
TT
168 pb.ctx = ctx;
169 pb.abort = 0;
8394902e 170 pb.errcode = 0;
80bfaa3e 171 pb.pctx = pctx;
8394902e
TT
172 if (inode->i_links_count) {
173 pb.truncating = 1;
54434927 174 pb.truncate_block = (e2_blkcnt_t)
0bd0e593 175 ((EXT2_I_SIZE(inode) + fs->blocksize - 1) /
8394902e
TT
176 fs->blocksize);
177 pb.truncate_offset = inode->i_size % fs->blocksize;
178 } else {
179 pb.truncating = 0;
180 pb.truncate_block = 0;
181 pb.truncate_offset = 0;
182 }
183 pb.truncated_blocks = 0;
6dc64392 184 retval = ext2fs_block_iterate3(fs, ino, BLOCK_FLAG_DEPTH_TRAVERSE,
8394902e 185 block_buf, release_inode_block, &pb);
80bfaa3e 186 if (retval) {
8394902e 187 com_err("release_inode_blocks", retval,
80bfaa3e
TT
188 _("while calling ext2fs_block_iterate for inode %d"),
189 ino);
190 return 1;
191 }
192 if (pb.abort)
193 return 1;
194
8394902e
TT
195 /* Refresh the inode since ext2fs_block_iterate may have changed it */
196 e2fsck_read_inode(ctx, ino, inode, "release_inode_blocks");
197
198 if (pb.truncated_blocks)
1ca1059f 199 ext2fs_iblk_sub_blocks(fs, inode, pb.truncated_blocks);
8394902e 200
0c80c44b
TT
201 if (ext2fs_file_acl_block(fs, inode)) {
202 retval = ext2fs_adjust_ea_refcount2(fs,
203 ext2fs_file_acl_block(fs, inode),
204 block_buf, -1, &count);
0684a4f3
TT
205 if (retval == EXT2_ET_BAD_EA_BLOCK_NUM) {
206 retval = 0;
207 count = 1;
208 }
209 if (retval) {
210 com_err("release_inode_blocks", retval,
6dc64392 211 _("while calling ext2fs_adjust_ea_refcount2 for inode %d"),
0684a4f3
TT
212 ino);
213 return 1;
214 }
e9e96584 215 if (count == 0) {
48f23054 216 ext2fs_block_alloc_stats2(fs,
0c80c44b 217 ext2fs_file_acl_block(fs, inode), -1);
e9e96584
TT
218 ctx->free_blocks++;
219 }
0c80c44b 220 ext2fs_file_acl_block_set(fs, inode, 0);
0684a4f3 221 }
80bfaa3e
TT
222 return 0;
223}
224
225/*
226 * This function releases all of the orphan inodes. It returns 1 if
227 * it hit some error, and 0 on success.
228 */
229static int release_orphan_inodes(e2fsck_t ctx)
230{
231 ext2_filsys fs = ctx->fs;
86c627ec 232 ext2_ino_t ino, next_ino;
80bfaa3e
TT
233 struct ext2_inode inode;
234 struct problem_context pctx;
235 char *block_buf;
236
237 if ((ino = fs->super->s_last_orphan) == 0)
238 return 0;
239
25c63ba0
TT
240 /*
241 * Win or lose, we won't be using the head of the orphan inode
242 * list again.
243 */
244 fs->super->s_last_orphan = 0;
245 ext2fs_mark_super_dirty(fs);
eb4ab510
TT
246
247 /*
248 * If the filesystem contains errors, don't run the orphan
249 * list, since the orphan list can't be trusted; and we're
250 * going to be running a full e2fsck run anyway...
251 */
252 if (fs->super->s_state & EXT2_ERROR_FS)
253 return 0;
efc6f628 254
80bfaa3e
TT
255 if ((ino < EXT2_FIRST_INODE(fs->super)) ||
256 (ino > fs->super->s_inodes_count)) {
257 clear_problem_context(&pctx);
53ef44c4 258 pctx.ino = ino;
80bfaa3e
TT
259 fix_problem(ctx, PR_0_ORPHAN_ILLEGAL_HEAD_INODE, &pctx);
260 return 1;
261 }
262
8394902e 263 block_buf = (char *) e2fsck_allocate_memory(ctx, fs->blocksize * 4,
9b565759 264 "block iterate buffer");
80bfaa3e 265 e2fsck_read_bitmaps(ctx);
efc6f628 266
80bfaa3e 267 while (ino) {
8394902e 268 e2fsck_read_inode(ctx, ino, &inode, "release_orphan_inodes");
80bfaa3e 269 clear_problem_context(&pctx);
ecf1b776 270 pctx.ino = ino;
80bfaa3e 271 pctx.inode = &inode;
f0b8c87d
TT
272 pctx.str = inode.i_links_count ? _("Truncating") :
273 _("Clearing");
80bfaa3e 274
8394902e 275 fix_problem(ctx, PR_0_ORPHAN_CLEAR_INODE, &pctx);
ecf1b776 276
80bfaa3e
TT
277 next_ino = inode.i_dtime;
278 if (next_ino &&
99a2cc96
TT
279 ((next_ino < EXT2_FIRST_INODE(fs->super)) ||
280 (next_ino > fs->super->s_inodes_count))) {
281 pctx.ino = next_ino;
80bfaa3e 282 fix_problem(ctx, PR_0_ORPHAN_ILLEGAL_INODE, &pctx);
53ef44c4 283 goto return_abort;
80bfaa3e
TT
284 }
285
8394902e 286 if (release_inode_blocks(ctx, ino, &inode, block_buf, &pctx))
53ef44c4 287 goto return_abort;
ecf1b776 288
8394902e 289 if (!inode.i_links_count) {
0684a4f3
TT
290 ext2fs_inode_alloc_stats2(fs, ino, -1,
291 LINUX_S_ISDIR(inode.i_mode));
e9e96584 292 ctx->free_inodes++;
1f3ad14a 293 inode.i_dtime = ctx->now;
eb16f861
ST
294 } else {
295 inode.i_dtime = 0;
8394902e
TT
296 }
297 e2fsck_write_inode(ctx, ino, &inode, "delete_file");
80bfaa3e
TT
298 ino = next_ino;
299 }
c4e3d3f3 300 ext2fs_free_mem(&block_buf);
80bfaa3e 301 return 0;
53ef44c4 302return_abort:
c4e3d3f3 303 ext2fs_free_mem(&block_buf);
80bfaa3e
TT
304 return 1;
305}
306
c3ffaf83
TT
307/*
308 * Check the resize inode to make sure it is sane. We check both for
309 * the case where on-line resizing is not enabled (in which case the
310 * resize inode should be cleared) as well as the case where on-line
311 * resizing is enabled.
312 */
69d0edfd 313void check_resize_inode(e2fsck_t ctx)
c3ffaf83
TT
314{
315 ext2_filsys fs = ctx->fs;
316 struct ext2_inode inode;
317 struct problem_context pctx;
642935c0
TT
318 int i, gdt_off, ind_off;
319 dgrp_t j;
b849f712 320 blk_t blk, pblk;
027b0577 321 blk_t expect; /* for resize inode, which is 32-bit only */
c3ffaf83
TT
322 __u32 *dind_buf = 0, *ind_buf;
323 errcode_t retval;
324
325 clear_problem_context(&pctx);
c3ffaf83 326
efc6f628
TT
327 /*
328 * If the resize inode feature isn't set, then
ea774315 329 * s_reserved_gdt_blocks must be zero.
c3ffaf83 330 */
efc6f628 331 if (!(fs->super->s_feature_compat &
c3ffaf83
TT
332 EXT2_FEATURE_COMPAT_RESIZE_INODE)) {
333 if (fs->super->s_reserved_gdt_blocks) {
334 pctx.num = fs->super->s_reserved_gdt_blocks;
335 if (fix_problem(ctx, PR_0_NONZERO_RESERVED_GDT_BLOCKS,
336 &pctx)) {
337 fs->super->s_reserved_gdt_blocks = 0;
338 ext2fs_mark_super_dirty(fs);
339 }
340 }
ea774315
TT
341 }
342
1f3ad14a 343 /* Read the resize inode */
ea774315
TT
344 pctx.ino = EXT2_RESIZE_INO;
345 retval = ext2fs_read_inode(fs, EXT2_RESIZE_INO, &inode);
346 if (retval) {
efc6f628 347 if (fs->super->s_feature_compat &
ea774315
TT
348 EXT2_FEATURE_COMPAT_RESIZE_INODE)
349 ctx->flags |= E2F_FLAG_RESIZE_INODE;
350 return;
351 }
352
efc6f628
TT
353 /*
354 * If the resize inode feature isn't set, check to make sure
ea774315
TT
355 * the resize inode is cleared; then we're done.
356 */
efc6f628 357 if (!(fs->super->s_feature_compat &
ea774315 358 EXT2_FEATURE_COMPAT_RESIZE_INODE)) {
c3ffaf83
TT
359 for (i=0; i < EXT2_N_BLOCKS; i++) {
360 if (inode.i_block[i])
361 break;
362 }
363 if ((i < EXT2_N_BLOCKS) &&
364 fix_problem(ctx, PR_0_CLEAR_RESIZE_INODE, &pctx)) {
365 memset(&inode, 0, sizeof(inode));
366 e2fsck_write_inode(ctx, EXT2_RESIZE_INO, &inode,
367 "clear_resize");
368 }
369 return;
370 }
ea774315 371
efc6f628 372 /*
c3ffaf83
TT
373 * The resize inode feature is enabled; check to make sure the
374 * only block in use is the double indirect block
375 */
376 blk = inode.i_block[EXT2_DIND_BLOCK];
377 for (i=0; i < EXT2_N_BLOCKS; i++) {
378 if (i != EXT2_DIND_BLOCK && inode.i_block[i])
379 break;
380 }
d4dc0a9e
TT
381 if ((i < EXT2_N_BLOCKS) || !blk || !inode.i_links_count ||
382 !(inode.i_mode & LINUX_S_IFREG) ||
c3ffaf83 383 (blk < fs->super->s_first_data_block ||
4efbac6f 384 blk >= ext2fs_blocks_count(fs->super))) {
c3ffaf83
TT
385 resize_inode_invalid:
386 if (fix_problem(ctx, PR_0_RESIZE_INODE_INVALID, &pctx)) {
387 memset(&inode, 0, sizeof(inode));
388 e2fsck_write_inode(ctx, EXT2_RESIZE_INO, &inode,
389 "clear_resize");
390 ctx->flags |= E2F_FLAG_RESIZE_INODE;
391 }
392 if (!(ctx->options & E2F_OPT_READONLY)) {
393 fs->super->s_state &= ~EXT2_VALID_FS;
394 ext2fs_mark_super_dirty(fs);
395 }
396 goto cleanup;
397 }
398 dind_buf = (__u32 *) e2fsck_allocate_memory(ctx, fs->blocksize * 2,
399 "resize dind buffer");
400 ind_buf = (__u32 *) ((char *) dind_buf + fs->blocksize);
401
dc8ce346 402 retval = ext2fs_read_ind_block(fs, blk, dind_buf);
c3ffaf83
TT
403 if (retval)
404 goto resize_inode_invalid;
405
406 gdt_off = fs->desc_blocks;
407 pblk = fs->super->s_first_data_block + 1 + fs->desc_blocks;
25567a7b
TT
408 if (fs->blocksize == 1024 && fs->super->s_first_data_block == 0)
409 pblk++; /* Deal with 1024 blocksize bigalloc fs */
efc6f628 410 for (i = 0; i < fs->super->s_reserved_gdt_blocks / 4;
c3ffaf83
TT
411 i++, gdt_off++, pblk++) {
412 gdt_off %= fs->blocksize/4;
413 if (dind_buf[gdt_off] != pblk)
414 goto resize_inode_invalid;
dc8ce346 415 retval = ext2fs_read_ind_block(fs, pblk, ind_buf);
efc6f628 416 if (retval)
c3ffaf83
TT
417 goto resize_inode_invalid;
418 ind_off = 0;
419 for (j = 1; j < fs->group_desc_count; j++) {
420 if (!ext2fs_bg_has_super(fs, j))
421 continue;
422 expect = pblk + (j * fs->super->s_blocks_per_group);
423 if (ind_buf[ind_off] != expect)
424 goto resize_inode_invalid;
425 ind_off++;
426 }
427 }
428
429cleanup:
430 if (dind_buf)
431 ext2fs_free_mem(&dind_buf);
432
433 }
80bfaa3e 434
f77704e4
TT
435/*
436 * This function checks the dirhash signed/unsigned hint if necessary.
437 */
642935c0 438static void e2fsck_fix_dirhash_hint(e2fsck_t ctx)
f77704e4
TT
439{
440 struct ext2_super_block *sb = ctx->fs->super;
441 struct problem_context pctx;
f77704e4
TT
442 char c;
443
444 if ((ctx->options & E2F_OPT_READONLY) ||
445 !(sb->s_feature_compat & EXT2_FEATURE_COMPAT_DIR_INDEX) ||
446 (sb->s_flags & (EXT2_FLAGS_SIGNED_HASH|EXT2_FLAGS_UNSIGNED_HASH)))
447 return;
448
449 c = (char) 255;
450
451 clear_problem_context(&pctx);
452 if (fix_problem(ctx, PR_0_DIRHASH_HINT, &pctx)) {
453 if (((int) c) == -1) {
454 sb->s_flags |= EXT2_FLAGS_SIGNED_HASH;
455 } else {
456 sb->s_flags |= EXT2_FLAGS_UNSIGNED_HASH;
457 }
458 ext2fs_mark_super_dirty(ctx->fs);
459 }
460}
461
462
1b6bf175
TT
463void check_super_block(e2fsck_t ctx)
464{
465 ext2_filsys fs = ctx->fs;
6dc64392 466 blk64_t first_block, last_block;
5dd8f963 467 struct ext2_super_block *sb = fs->super;
68477355 468 unsigned int ipg_max;
26ea4899 469 problem_t problem;
6dc64392 470 blk64_t blocks_per_group = fs->super->s_blocks_per_group;
44fe08f1 471 __u32 bpg_max, cpg_max;
78cf0547 472 int inodes_per_block;
89db86d3 473 int inode_size;
ba5131f6 474 int accept_time_fudge;
177839e2 475 int broken_system_clock;
7f813ba3 476 dgrp_t i;
6dc64392 477 blk64_t should_be;
1b6bf175 478 struct problem_context pctx;
6dc64392 479 blk64_t free_blocks = 0;
5d38ef1d 480 ino_t free_inodes = 0;
80875db5 481 int csum_flag, clear_test_fs_flag;
b21bf267
AD
482
483 inodes_per_block = EXT2_INODES_PER_BLOCK(fs->super);
484 ipg_max = inodes_per_block * (blocks_per_group - 4);
485 if (ipg_max > EXT2_MAX_INODES_PER_GROUP(sb))
486 ipg_max = EXT2_MAX_INODES_PER_GROUP(sb);
44fe08f1
TT
487 cpg_max = 8 * EXT2_BLOCK_SIZE(sb);
488 if (cpg_max > EXT2_MAX_CLUSTERS_PER_GROUP(sb))
489 cpg_max = EXT2_MAX_CLUSTERS_PER_GROUP(sb);
490 bpg_max = 8 * EXT2_BLOCK_SIZE(sb) * EXT2FS_CLUSTER_RATIO(fs);
b21bf267
AD
491 if (bpg_max > EXT2_MAX_BLOCKS_PER_GROUP(sb))
492 bpg_max = EXT2_MAX_BLOCKS_PER_GROUP(sb);
1b6bf175 493
54dc7ca2 494 ctx->invalid_inode_bitmap_flag = (int *) e2fsck_allocate_memory(ctx,
f8188fff 495 sizeof(int) * fs->group_desc_count, "invalid_inode_bitmap");
54dc7ca2 496 ctx->invalid_block_bitmap_flag = (int *) e2fsck_allocate_memory(ctx,
f8188fff 497 sizeof(int) * fs->group_desc_count, "invalid_block_bitmap");
54dc7ca2 498 ctx->invalid_inode_table_flag = (int *) e2fsck_allocate_memory(ctx,
f8188fff 499 sizeof(int) * fs->group_desc_count, "invalid_inode_table");
b21bf267 500
1b6bf175
TT
501 clear_problem_context(&pctx);
502
503 /*
504 * Verify the super block constants...
505 */
5dd8f963 506 check_super_value(ctx, "inodes_count", sb->s_inodes_count,
1b6bf175 507 MIN_CHECK, 1, 0);
4efbac6f 508 check_super_value(ctx, "blocks_count", ext2fs_blocks_count(sb),
1b6bf175 509 MIN_CHECK, 1, 0);
5dd8f963 510 check_super_value(ctx, "first_data_block", sb->s_first_data_block,
4efbac6f 511 MAX_CHECK, 0, ext2fs_blocks_count(sb));
5dd8f963 512 check_super_value(ctx, "log_block_size", sb->s_log_block_size,
31e29a12
TT
513 MIN_CHECK | MAX_CHECK, 0,
514 EXT2_MAX_BLOCK_LOG_SIZE - EXT2_MIN_BLOCK_LOG_SIZE);
412376ef
TT
515 check_super_value(ctx, "log_cluster_size",
516 sb->s_log_cluster_size,
517 MIN_CHECK | MAX_CHECK, sb->s_log_block_size,
518 (EXT2_MAX_CLUSTER_LOG_SIZE -
519 EXT2_MIN_CLUSTER_LOG_SIZE));
520 check_super_value(ctx, "clusters_per_group", sb->s_clusters_per_group,
44fe08f1 521 MIN_CHECK | MAX_CHECK, 8, cpg_max);
5dd8f963 522 check_super_value(ctx, "blocks_per_group", sb->s_blocks_per_group,
b21bf267 523 MIN_CHECK | MAX_CHECK, 8, bpg_max);
5dd8f963 524 check_super_value(ctx, "inodes_per_group", sb->s_inodes_per_group,
b21bf267 525 MIN_CHECK | MAX_CHECK, inodes_per_block, ipg_max);
4efbac6f
VAH
526 check_super_value(ctx, "r_blocks_count", ext2fs_r_blocks_count(sb),
527 MAX_CHECK, 0, ext2fs_blocks_count(sb) / 2);
efc6f628 528 check_super_value(ctx, "reserved_gdt_blocks",
c3ffaf83
TT
529 sb->s_reserved_gdt_blocks, MAX_CHECK, 0,
530 fs->blocksize/4);
1f790a7c
TT
531 if (sb->s_rev_level > EXT2_GOOD_OLD_REV)
532 check_super_value(ctx, "first_ino", sb->s_first_ino,
533 MIN_CHECK | MAX_CHECK,
534 EXT2_GOOD_OLD_FIRST_INO, sb->s_inodes_count);
89db86d3
TT
535 inode_size = EXT2_INODE_SIZE(sb);
536 check_super_value(ctx, "inode_size",
537 inode_size, MIN_CHECK | MAX_CHECK,
538 EXT2_GOOD_OLD_INODE_SIZE, fs->blocksize);
44fe08f1
TT
539 if (sb->s_blocks_per_group != (sb->s_clusters_per_group *
540 EXT2FS_CLUSTER_RATIO(fs))) {
541 pctx.num = sb->s_clusters_per_group * EXT2FS_CLUSTER_RATIO(fs);
542 pctx.str = "block_size";
543 fix_problem(ctx, PR_0_MISC_CORRUPT_SUPER, &pctx);
544 ctx->flags |= E2F_FLAG_ABORT; /* never get here! */
545 return;
546 }
89db86d3
TT
547 if (inode_size & (inode_size - 1)) {
548 pctx.num = inode_size;
549 pctx.str = "inode_size";
550 fix_problem(ctx, PR_0_MISC_CORRUPT_SUPER, &pctx);
551 ctx->flags |= E2F_FLAG_ABORT; /* never get here! */
552 return;
553 }
efc6f628 554
d2af1bdd 555 if ((ctx->flags & E2F_FLAG_GOT_DEVSIZE) &&
4efbac6f
VAH
556 (ctx->num_blocks < ext2fs_blocks_count(sb))) {
557 pctx.blk = ext2fs_blocks_count(sb);
d2af1bdd
TT
558 pctx.blk2 = ctx->num_blocks;
559 if (fix_problem(ctx, PR_0_FS_SIZE_WRONG, &pctx)) {
08b21301
TT
560 ctx->flags |= E2F_FLAG_ABORT;
561 return;
562 }
1b6bf175
TT
563 }
564
25567a7b
TT
565 should_be = (sb->s_log_block_size == 0 &&
566 EXT2FS_CLUSTER_RATIO(fs) == 1) ? 1 : 0;
5dd8f963
TT
567 if (sb->s_first_data_block != should_be) {
568 pctx.blk = sb->s_first_data_block;
1b6bf175
TT
569 pctx.blk2 = should_be;
570 fix_problem(ctx, PR_0_FIRST_DATA_BLOCK, &pctx);
08b21301
TT
571 ctx->flags |= E2F_FLAG_ABORT;
572 return;
1b6bf175
TT
573 }
574
5dd8f963
TT
575 should_be = sb->s_inodes_per_group * fs->group_desc_count;
576 if (sb->s_inodes_count != should_be) {
577 pctx.ino = sb->s_inodes_count;
d4b0ce03
TT
578 pctx.ino2 = should_be;
579 if (fix_problem(ctx, PR_0_INODE_COUNT_WRONG, &pctx)) {
5dd8f963 580 sb->s_inodes_count = should_be;
d4b0ce03
TT
581 ext2fs_mark_super_dirty(fs);
582 }
583 }
584
27b2297d
DW
585 /* Is 64bit set and extents unset? */
586 if (EXT2_HAS_INCOMPAT_FEATURE(fs->super,
587 EXT4_FEATURE_INCOMPAT_64BIT) &&
588 !EXT2_HAS_INCOMPAT_FEATURE(fs->super,
589 EXT3_FEATURE_INCOMPAT_EXTENTS) &&
590 fix_problem(ctx, PR_0_64BIT_WITHOUT_EXTENTS, &pctx)) {
591 fs->super->s_feature_incompat |=
592 EXT3_FEATURE_INCOMPAT_EXTENTS;
593 ext2fs_mark_super_dirty(fs);
594 }
595
1b6bf175
TT
596 /*
597 * Verify the group descriptors....
598 */
88b34b1f 599 first_block = sb->s_first_data_block;
4efbac6f 600 last_block = ext2fs_blocks_count(sb)-1;
1b6bf175 601
49a7360b
JS
602 csum_flag = EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
603 EXT4_FEATURE_RO_COMPAT_GDT_CSUM);
d7cca6b0 604 for (i = 0; i < fs->group_desc_count; i++) {
1b6bf175 605 pctx.group = i;
abf23439 606
88b34b1f
JS
607 if (!EXT2_HAS_INCOMPAT_FEATURE(fs->super,
608 EXT4_FEATURE_INCOMPAT_FLEX_BG)) {
b49f78fe
TT
609 first_block = ext2fs_group_first_block2(fs, i);
610 last_block = ext2fs_group_last_block2(fs, i);
88b34b1f 611 }
bb1a46a4 612
d7cca6b0
VAH
613 if ((ext2fs_block_bitmap_loc(fs, i) < first_block) ||
614 (ext2fs_block_bitmap_loc(fs, i) > last_block)) {
615 pctx.blk = ext2fs_block_bitmap_loc(fs, i);
24bfb443 616 if (fix_problem(ctx, PR_0_BB_NOT_GROUP, &pctx))
d7cca6b0 617 ext2fs_block_bitmap_loc_set(fs, i, 0);
24bfb443 618 }
d7cca6b0 619 if (ext2fs_block_bitmap_loc(fs, i) == 0) {
24bfb443
TT
620 ctx->invalid_block_bitmap_flag[i]++;
621 ctx->invalid_bitmaps++;
1b6bf175 622 }
d7cca6b0
VAH
623 if ((ext2fs_inode_bitmap_loc(fs, i) < first_block) ||
624 (ext2fs_inode_bitmap_loc(fs, i) > last_block)) {
625 pctx.blk = ext2fs_inode_bitmap_loc(fs, i);
24bfb443 626 if (fix_problem(ctx, PR_0_IB_NOT_GROUP, &pctx))
d7cca6b0 627 ext2fs_inode_bitmap_loc_set(fs, i, 0);
24bfb443 628 }
d7cca6b0 629 if (ext2fs_inode_bitmap_loc(fs, i) == 0) {
24bfb443
TT
630 ctx->invalid_inode_bitmap_flag[i]++;
631 ctx->invalid_bitmaps++;
1b6bf175 632 }
d7cca6b0
VAH
633 if ((ext2fs_inode_table_loc(fs, i) < first_block) ||
634 ((ext2fs_inode_table_loc(fs, i) +
bb1a46a4 635 fs->inode_blocks_per_group - 1) > last_block)) {
d7cca6b0 636 pctx.blk = ext2fs_inode_table_loc(fs, i);
24bfb443 637 if (fix_problem(ctx, PR_0_ITABLE_NOT_GROUP, &pctx))
d7cca6b0 638 ext2fs_inode_table_loc_set(fs, i, 0);
24bfb443 639 }
d7cca6b0 640 if (ext2fs_inode_table_loc(fs, i) == 0) {
24bfb443
TT
641 ctx->invalid_inode_table_flag[i]++;
642 ctx->invalid_bitmaps++;
1b6bf175 643 }
d7cca6b0
VAH
644 free_blocks += ext2fs_bg_free_blocks_count(fs, i);
645 free_inodes += ext2fs_bg_free_inodes_count(fs, i);
550a4afa 646
d7cca6b0
VAH
647 if ((ext2fs_bg_free_blocks_count(fs, i) > sb->s_blocks_per_group) ||
648 (ext2fs_bg_free_inodes_count(fs, i) > sb->s_inodes_per_group) ||
649 (ext2fs_bg_used_dirs_count(fs, i) > sb->s_inodes_per_group))
550a4afa
TT
650 ext2fs_unmark_valid(fs);
651
0d5439c8 652 should_be = 0;
49a7360b 653 if (!ext2fs_group_desc_csum_verify(fs, i)) {
b9a64a51
TT
654 pctx.csum1 = ext2fs_bg_checksum(fs, i);
655 pctx.csum2 = ext2fs_group_desc_csum(fs, i);
49a7360b 656 if (fix_problem(ctx, PR_0_GDT_CSUM, &pctx)) {
e633b58a
ES
657 ext2fs_bg_flags_clear(fs, i, EXT2_BG_BLOCK_UNINIT);
658 ext2fs_bg_flags_clear(fs, i, EXT2_BG_INODE_UNINIT);
d7cca6b0 659 ext2fs_bg_itable_unused_set(fs, i, 0);
0d5439c8 660 should_be = 1;
49a7360b
JS
661 }
662 ext2fs_unmark_valid(fs);
663 }
664
16b851cd 665 if (!csum_flag &&
cd65a24e
TT
666 (ext2fs_bg_flags_test(fs, i, EXT2_BG_BLOCK_UNINIT) ||
667 ext2fs_bg_flags_test(fs, i, EXT2_BG_INODE_UNINIT) ||
d7cca6b0 668 ext2fs_bg_itable_unused(fs, i) != 0)) {
49a7360b 669 if (fix_problem(ctx, PR_0_GDT_UNINIT, &pctx)) {
e633b58a
ES
670 ext2fs_bg_flags_clear(fs, i, EXT2_BG_BLOCK_UNINIT);
671 ext2fs_bg_flags_clear(fs, i, EXT2_BG_INODE_UNINIT);
d7cca6b0 672 ext2fs_bg_itable_unused_set(fs, i, 0);
0d5439c8 673 should_be = 1;
49a7360b
JS
674 }
675 ext2fs_unmark_valid(fs);
676 }
0d5439c8
AD
677
678 if (i == fs->group_desc_count - 1 &&
cd65a24e 679 ext2fs_bg_flags_test(fs, i, EXT2_BG_BLOCK_UNINIT)) {
0d5439c8 680 if (fix_problem(ctx, PR_0_BB_UNINIT_LAST, &pctx)) {
e633b58a 681 ext2fs_bg_flags_clear(fs, i, EXT2_BG_BLOCK_UNINIT);
0d5439c8
AD
682 should_be = 1;
683 }
684 ext2fs_unmark_valid(fs);
685 }
686
49a7360b 687 if (csum_flag &&
d7cca6b0
VAH
688 (ext2fs_bg_itable_unused(fs, i) > ext2fs_bg_free_inodes_count(fs, i) ||
689 ext2fs_bg_itable_unused(fs, i) > sb->s_inodes_per_group)) {
690 pctx.blk = ext2fs_bg_itable_unused(fs, i);
0d5439c8 691 if (fix_problem(ctx, PR_0_GDT_ITABLE_UNUSED, &pctx)) {
d7cca6b0 692 ext2fs_bg_itable_unused_set(fs, i, 0);
0d5439c8
AD
693 should_be = 1;
694 }
49a7360b
JS
695 ext2fs_unmark_valid(fs);
696 }
0d5439c8
AD
697
698 if (should_be)
699 ext2fs_group_desc_csum_set(fs, i);
bee24f36
VAH
700 /* If the user aborts e2fsck by typing ^C, stop right away */
701 if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
702 return;
1b6bf175 703 }
550a4afa 704
fe75afbf 705 ctx->free_blocks = EXT2FS_C2B(fs, free_blocks);
a3efe484 706 ctx->free_inodes = free_inodes;
efc6f628 707
4efbac6f 708 if ((ext2fs_free_blocks_count(sb) > ext2fs_blocks_count(sb)) ||
550a4afa
TT
709 (sb->s_free_inodes_count > sb->s_inodes_count))
710 ext2fs_unmark_valid(fs);
711
712
1b6bf175
TT
713 /*
714 * If we have invalid bitmaps, set the error state of the
715 * filesystem.
716 */
717 if (ctx->invalid_bitmaps && !(ctx->options & E2F_OPT_READONLY)) {
550a4afa 718 sb->s_state &= ~EXT2_VALID_FS;
1b6bf175
TT
719 ext2fs_mark_super_dirty(fs);
720 }
721
4ea0a110 722 clear_problem_context(&pctx);
efc6f628 723
54be2ccc 724#ifndef EXT2_SKIP_UUID
1b6bf175
TT
725 /*
726 * If the UUID field isn't assigned, assign it.
727 */
5dd8f963 728 if (!(ctx->options & E2F_OPT_READONLY) && uuid_is_null(sb->s_uuid)) {
1b6bf175 729 if (fix_problem(ctx, PR_0_ADD_UUID, &pctx)) {
5dd8f963 730 uuid_generate(sb->s_uuid);
86db36ab 731 fs->flags |= EXT2_FLAG_DIRTY;
299d7424 732 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
1b6bf175
TT
733 }
734 }
54be2ccc 735#endif
2a77a784 736
80875db5
TT
737 /*
738 * Check to see if we should disable the test_fs flag
739 */
740 profile_get_boolean(ctx->profile, "options",
741 "clear_test_fs_flag", 0, 1,
742 &clear_test_fs_flag);
743 if (!(ctx->options & E2F_OPT_READONLY) &&
744 clear_test_fs_flag &&
745 (fs->super->s_flags & EXT2_FLAGS_TEST_FILESYS) &&
746 (fs_proc_check("ext4") || check_for_modules("ext4"))) {
747 if (fix_problem(ctx, PR_0_CLEAR_TESTFS_FLAG, &pctx)) {
748 fs->super->s_flags &= ~EXT2_FLAGS_TEST_FILESYS;
86db36ab 749 fs->flags |= EXT2_FLAG_DIRTY;
80875db5
TT
750 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
751 }
752 }
753
4ea0a110
TT
754 /*
755 * For the Hurd, check to see if the filetype option is set,
756 * since it doesn't support it.
757 */
80bfaa3e
TT
758 if (!(ctx->options & E2F_OPT_READONLY) &&
759 fs->super->s_creator_os == EXT2_OS_HURD &&
4ea0a110
TT
760 (fs->super->s_feature_incompat &
761 EXT2_FEATURE_INCOMPAT_FILETYPE)) {
762 if (fix_problem(ctx, PR_0_HURD_CLEAR_FILETYPE, &pctx)) {
763 fs->super->s_feature_incompat &=
764 ~EXT2_FEATURE_INCOMPAT_FILETYPE;
765 ext2fs_mark_super_dirty(fs);
0cfce7f7 766 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
4ea0a110
TT
767 }
768 }
80bfaa3e 769
7b59f1ef
TT
770 /*
771 * If we have any of the compatibility flags set, we need to have a
772 * revision 1 filesystem. Most kernels will not check the flags on
773 * a rev 0 filesystem and we may have corruption issues because of
774 * the incompatible changes to the filesystem.
775 */
776 if (!(ctx->options & E2F_OPT_READONLY) &&
777 fs->super->s_rev_level == EXT2_GOOD_OLD_REV &&
778 (fs->super->s_feature_compat ||
779 fs->super->s_feature_ro_compat ||
780 fs->super->s_feature_incompat) &&
781 fix_problem(ctx, PR_0_FS_REV_LEVEL, &pctx)) {
a917d1cc 782 ext2fs_update_dynamic_rev(fs);
7b59f1ef 783 ext2fs_mark_super_dirty(fs);
0cfce7f7 784 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
7b59f1ef
TT
785 }
786
80bfaa3e
TT
787 /*
788 * Clean up any orphan inodes, if present.
789 */
790 if (!(ctx->options & E2F_OPT_READONLY) && release_orphan_inodes(ctx)) {
791 fs->super->s_state &= ~EXT2_VALID_FS;
7b59f1ef 792 ext2fs_mark_super_dirty(fs);
80bfaa3e
TT
793 }
794
60702c26 795 /*
ba5131f6
TT
796 * Unfortunately, due to Windows' unfortunate design decision
797 * to configure the hardware clock to tick localtime, instead
798 * of the more proper and less error-prone UTC time, many
799 * users end up in the situation where the system clock is
800 * incorrectly set at the time when e2fsck is run.
801 *
802 * Historically this was usually due to some distributions
803 * having buggy init scripts and/or installers that didn't
804 * correctly detect this case and take appropriate
805 * countermeasures. However, it's still possible, despite the
806 * best efforts of init script and installer authors to not be
807 * able to detect this misconfiguration, usually due to a
808 * buggy or misconfigured virtualization manager or the
809 * installer not having access to a network time server during
810 * the installation process. So by default, we allow the
811 * superblock times to be fudged by up to 24 hours. This can
812 * be disabled by setting options.accept_time_fudge to the
813 * boolean value of false in e2fsck.conf. We also support
814 * options.buggy_init_scripts for backwards compatibility.
60702c26 815 */
ba5131f6
TT
816 profile_get_boolean(ctx->profile, "options", "accept_time_fudge",
817 0, 1, &accept_time_fudge);
60702c26 818 profile_get_boolean(ctx->profile, "options", "buggy_init_scripts",
ba5131f6
TT
819 0, accept_time_fudge, &accept_time_fudge);
820 ctx->time_fudge = accept_time_fudge ? 86400 : 0;
60702c26 821
177839e2
TT
822 profile_get_boolean(ctx->profile, "options", "broken_system_clock",
823 0, 0, &broken_system_clock);
824
efc6f628 825 /*
8dceb924
TT
826 * Check to see if the superblock last mount time or last
827 * write time is in the future.
828 */
177839e2
TT
829 if (!broken_system_clock &&
830 !(ctx->flags & E2F_FLAG_TIME_INSANE) &&
831 fs->super->s_mtime > (__u32) ctx->now) {
8dceb924 832 pctx.num = fs->super->s_mtime;
26ea4899
TT
833 problem = PR_0_FUTURE_SB_LAST_MOUNT;
834 if (fs->super->s_mtime <= (__u32) ctx->now + ctx->time_fudge)
835 problem = PR_0_FUTURE_SB_LAST_MOUNT_FUDGED;
836 if (fix_problem(ctx, problem, &pctx)) {
8dceb924 837 fs->super->s_mtime = ctx->now;
86db36ab 838 fs->flags |= EXT2_FLAG_DIRTY;
8dceb924
TT
839 }
840 }
177839e2
TT
841 if (!broken_system_clock &&
842 !(ctx->flags & E2F_FLAG_TIME_INSANE) &&
843 fs->super->s_wtime > (__u32) ctx->now) {
8dceb924 844 pctx.num = fs->super->s_wtime;
fe26a55a 845 problem = PR_0_FUTURE_SB_LAST_WRITE;
26ea4899 846 if (fs->super->s_wtime <= (__u32) ctx->now + ctx->time_fudge)
61a9d2b3 847 problem = PR_0_FUTURE_SB_LAST_WRITE_FUDGED;
26ea4899 848 if (fix_problem(ctx, problem, &pctx)) {
8dceb924 849 fs->super->s_wtime = ctx->now;
86db36ab 850 fs->flags |= EXT2_FLAG_DIRTY;
8dceb924
TT
851 }
852 }
853
773fd8a1
TT
854 /*
855 * Move the ext3 journal file, if necessary.
856 */
857 e2fsck_move_ext3_journal(ctx);
b1c52b26
TT
858
859 /*
860 * Fix journal hint, if necessary
861 */
862 e2fsck_fix_ext3_journal_hint(ctx);
863
f77704e4
TT
864 /*
865 * Add dirhash hint if necessary
866 */
867 e2fsck_fix_dirhash_hint(ctx);
868
624e4a64
AK
869 /*
870 * Hide quota inodes if necessary.
871 */
872 e2fsck_hide_quota(ctx);
873
1b6bf175
TT
874 return;
875}
0c37f456
TT
876
877/*
878 * Check to see if we should backup the master sb to the backup super
a8cde73a 879 * blocks. Returns non-zero if the sb should be backed up.
0c37f456 880 */
a8cde73a
TT
881
882/*
883 * A few flags are set on the fly by the kernel, but only in the
884 * primary superblock. This is actually a bad thing, and we should
885 * try to discourage it in the future. In particular, for the newer
886 * ext4 files, especially EXT4_FEATURE_RO_COMPAT_DIR_NLINK and
887 * EXT3_FEATURE_INCOMPAT_EXTENTS. So some of these may go away in the
d9ff474b
ES
888 * future. EXT3_FEATURE_INCOMPAT_RECOVER may also get set when
889 * copying the primary superblock during online resize.
a8cde73a
TT
890 *
891 * The kernel will set EXT2_FEATURE_COMPAT_EXT_ATTR, but
892 * unfortunately, we shouldn't ignore it since if it's not set in the
893 * backup, the extended attributes in the filesystem will be stripped
894 * away.
895 */
896#define FEATURE_RO_COMPAT_IGNORE (EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
897 EXT4_FEATURE_RO_COMPAT_DIR_NLINK)
d9ff474b
ES
898#define FEATURE_INCOMPAT_IGNORE (EXT3_FEATURE_INCOMPAT_EXTENTS| \
899 EXT3_FEATURE_INCOMPAT_RECOVER)
a8cde73a 900
0c37f456
TT
901int check_backup_super_block(e2fsck_t ctx)
902{
903 ext2_filsys fs = ctx->fs;
0c37f456
TT
904 errcode_t retval;
905 dgrp_t g;
6dc64392 906 blk64_t sb;
0c37f456 907 int ret = 0;
982dd30c
TT
908 char buf[SUPERBLOCK_SIZE];
909 struct ext2_super_block *backup_sb;
0c37f456
TT
910
911 /*
912 * If we are already writing out the backup blocks, then we
913 * don't need to test. Also, if the filesystem is invalid, or
914 * the check was aborted or cancelled, we also don't want to
915 * do the backup. If the filesystem was opened read-only then
916 * we can't do the backup.
917 */
918 if (((fs->flags & EXT2_FLAG_MASTER_SB_ONLY) == 0) ||
919 !ext2fs_test_valid(fs) ||
920 (fs->super->s_state & EXT2_ERROR_FS) ||
921 (ctx->flags & (E2F_FLAG_ABORT | E2F_FLAG_CANCEL)) ||
922 (ctx->options & E2F_OPT_READONLY))
923 return 0;
924
925 for (g = 1; g < fs->group_desc_count; g++) {
926 if (!ext2fs_bg_has_super(fs, g))
927 continue;
928
027b0577 929 sb = ext2fs_group_first_block2(fs, g);
0c37f456 930
982dd30c
TT
931 retval = io_channel_read_blk(fs->io, sb, -SUPERBLOCK_SIZE,
932 buf);
933 if (retval)
934 continue;
935 backup_sb = (struct ext2_super_block *) buf;
936#ifdef WORDS_BIGENDIAN
937 ext2fs_swap_super(backup_sb);
938#endif
939 if ((backup_sb->s_magic != EXT2_SUPER_MAGIC) ||
940 (backup_sb->s_rev_level > EXT2_LIB_CURRENT_REV) ||
941 ((backup_sb->s_log_block_size + EXT2_MIN_BLOCK_LOG_SIZE) >
942 EXT2_MAX_BLOCK_LOG_SIZE) ||
943 (EXT2_INODE_SIZE(backup_sb) < EXT2_GOOD_OLD_INODE_SIZE))
0c37f456 944 continue;
0c37f456 945
a8cde73a 946#define SUPER_INCOMPAT_DIFFERENT(x) \
982dd30c
TT
947 ((fs->super->x & ~FEATURE_INCOMPAT_IGNORE) != \
948 (backup_sb->x & ~FEATURE_INCOMPAT_IGNORE))
a8cde73a 949#define SUPER_RO_COMPAT_DIFFERENT(x) \
982dd30c
TT
950 ((fs->super->x & ~FEATURE_RO_COMPAT_IGNORE) != \
951 (backup_sb->x & ~FEATURE_RO_COMPAT_IGNORE))
a8cde73a 952#define SUPER_DIFFERENT(x) \
982dd30c 953 (fs->super->x != backup_sb->x)
a8cde73a 954
0c37f456 955 if (SUPER_DIFFERENT(s_feature_compat) ||
a8cde73a
TT
956 SUPER_INCOMPAT_DIFFERENT(s_feature_incompat) ||
957 SUPER_RO_COMPAT_DIFFERENT(s_feature_ro_compat) ||
0c37f456
TT
958 SUPER_DIFFERENT(s_blocks_count) ||
959 SUPER_DIFFERENT(s_inodes_count) ||
982dd30c 960 memcmp(fs->super->s_uuid, backup_sb->s_uuid,
0c37f456
TT
961 sizeof(fs->super->s_uuid)))
962 ret = 1;
0c37f456
TT
963 break;
964 }
965 return ret;
966}