diff mbox

[5/6] findsuper: improve output if s_mkfs_time unset

Message ID 1457224716-72388-5-git-send-email-adilger@dilger.ca
State Accepted, archived
Headers show

Commit Message

Andreas Dilger March 6, 2016, 12:38 a.m. UTC
If s_mkfs_time is not set in the superblock, print the s_mtime field
instead to identify the different superblocks.  This can happen if the
superblock is corrupted, since s_mkfs_time is not reset by e2fsck.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
---
 misc/findsuper.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Theodore Ts'o March 6, 2016, 11:16 p.m. UTC | #1
On Sat, Mar 05, 2016 at 05:38:35PM -0700, Andreas Dilger wrote:
> If s_mkfs_time is not set in the superblock, print the s_mtime field
> instead to identify the different superblocks.  This can happen if the
> superblock is corrupted, since s_mkfs_time is not reset by e2fsck.
> 
> Signed-off-by: Andreas Dilger <adilger@dilger.ca>

Thanks, applied.

						- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/misc/findsuper.c b/misc/findsuper.c
index eb9130b..b3b76cd 100644
--- a/misc/findsuper.c
+++ b/misc/findsuper.c
@@ -187,7 +187,7 @@  int main(int argc, char *argv[])
 	if (print_jnl_copies)
 		printf(_("[*] probably superblock written in the ext3 "
 			 "journal superblock,\n\tso start/end/grp wrong\n"));
-	printf(_("byte_offset  byte_start     byte_end  fs_blocks blksz  grp  last_mount_time           sb_uuid label\n"));
+	printf(_("byte_offset  byte_start     byte_end  fs_blocks blksz  grp  mkfs/mount_time           sb_uuid label\n"));
 	for (; lseek64(fd, sk, SEEK_SET) != -1 &&
 	       read(fd, &ext2, 512) == 512; sk += skiprate) {
 		static unsigned char last_uuid[16] = "blah";
@@ -230,7 +230,10 @@  int main(int argc, char *argv[])
 			WHY("free_inodes_count > inodes_count (%u > %u)\n",
 			    ext2.s_free_inodes_count, ext2.s_inodes_count);
 
-		tm = ext2.s_mtime;
+		if (ext2.s_mkfs_time != 0)
+			tm = ext2.s_mkfs_time;
+		else
+			tm = ext2.s_mtime;
 		s = ctime(&tm);
 		s[24] = 0;
 		bsize = 1 << (ext2.s_log_block_size + 10);