Whamcloud - gitweb
e2fsck, tune2fs: fix post-2038 support for s_lastcheck
[tools/e2fsprogs.git] / e2fsck / pass1.c
index 591acad..078bcb9 100644 (file)
@@ -331,7 +331,7 @@ static problem_t check_large_ea_inode(e2fsck_t ctx,
                                      blk64_t *quota_blocks)
 {
        struct ext2_inode inode;
-       __u32 hash;
+       __u32 hash, signed_hash;
        errcode_t retval;
 
        /* Check if inode is within valid range */
@@ -343,7 +343,8 @@ static problem_t check_large_ea_inode(e2fsck_t ctx,
 
        e2fsck_read_inode(ctx, entry->e_value_inum, &inode, "pass1");
 
-       retval = ext2fs_ext_attr_hash_entry2(ctx->fs, entry, NULL, &hash);
+       retval = ext2fs_ext_attr_hash_entry3(ctx->fs, entry, NULL, &hash,
+                                            &signed_hash);
        if (retval) {
                com_err("check_large_ea_inode", retval,
                        _("while hashing entry with e_value_inum = %u"),
@@ -351,7 +352,7 @@ static problem_t check_large_ea_inode(e2fsck_t ctx,
                fatal_error(ctx, 0);
        }
 
-       if (hash == entry->e_hash) {
+       if ((hash == entry->e_hash) || (signed_hash == entry->e_hash)) {
                *quota_blocks = size_to_quota_blocks(ctx->fs,
                                                     entry->e_value_size);
        } else {
@@ -495,7 +496,10 @@ static void check_ea_in_inode(e2fsck_t ctx, struct problem_context *pctx,
                        }
 
                        hash = ext2fs_ext_attr_hash_entry(entry,
-                                                         start + entry->e_value_offs);
+                                               start + entry->e_value_offs);
+                       if (entry->e_hash != 0 && entry->e_hash != hash)
+                               hash = ext2fs_ext_attr_hash_entry_signed(entry,
+                                               start + entry->e_value_offs);
 
                        /* e_hash may be 0 in older inode's ea */
                        if (entry->e_hash != 0 && entry->e_hash != hash) {
@@ -1177,6 +1181,7 @@ void e2fsck_pass1(e2fsck_t ctx)
        ext2_ino_t      ino_threshold = 0;
        dgrp_t          ra_group = 0;
        struct ea_quota ea_ibody_quota;
+       time_t          tm;
 
        init_resource_track(&rtrack, ctx->fs->io);
        clear_problem_context(&pctx);
@@ -1353,12 +1358,13 @@ void e2fsck_pass1(e2fsck_t ctx)
        if (ctx->progress && ((ctx->progress)(ctx, 1, 0,
                                              ctx->fs->group_desc_count)))
                goto endit;
-       if ((fs->super->s_wtime &&
-            fs->super->s_wtime < fs->super->s_inodes_count) ||
-           (fs->super->s_mtime &&
-            fs->super->s_mtime < fs->super->s_inodes_count) ||
-           (fs->super->s_mkfs_time &&
-            fs->super->s_mkfs_time < fs->super->s_inodes_count))
+
+       if (((tm = ext2fs_get_tstamp(fs->super, s_wtime)) &&
+            tm < fs->super->s_inodes_count) ||
+           ((tm = ext2fs_get_tstamp(fs->super, s_mtime)) &&
+            tm < fs->super->s_inodes_count) ||
+           ((tm = ext2fs_get_tstamp(fs->super, s_mkfs_time)) &&
+            tm < fs->super->s_inodes_count))
                low_dtime_check = 0;
 
        if (ext2fs_has_feature_mmp(fs->super) &&
@@ -2072,7 +2078,7 @@ void e2fsck_pass1(e2fsck_t ctx)
                if (!pctx.errcode) {
                        e2fsck_read_inode(ctx, EXT2_RESIZE_INO, inode,
                                          "recreate inode");
-                       inode->i_mtime = ctx->now;
+                       ext2fs_inode_xtime_set(inode, i_mtime, ctx->now);
                        e2fsck_write_inode(ctx, EXT2_RESIZE_INO, inode,
                                           "recreate inode");
                }
@@ -2602,6 +2608,9 @@ static int check_ext_attr(e2fsck_t ctx, struct problem_context *pctx,
 
                        hash = ext2fs_ext_attr_hash_entry(entry, block_buf +
                                                          entry->e_value_offs);
+                       if (entry->e_hash != hash)
+                               hash = ext2fs_ext_attr_hash_entry_signed(entry,
+                                       block_buf + entry->e_value_offs);
 
                        if (entry->e_hash != hash) {
                                pctx->num = entry->e_hash;