From 9d2aefb3bc0a48b1540d06e1983aa96c56d39e17 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 25 Oct 2002 17:29:55 -0400 Subject: [PATCH] Add a new superblock field, s_mkfs_time, which indicates when the filesystem was created. It is set via mke2fs, and printed via list_super2() (which is called by dumpe2fs). Also, list_super2() will now print "n/a" if the last mount time (s_mtime) is zero. --- lib/e2p/ChangeLog | 6 ++++++ lib/e2p/ls.c | 9 +++++++-- lib/ext2fs/ChangeLog | 8 ++++++++ lib/ext2fs/ext2_fs.h | 3 ++- lib/ext2fs/initialize.c | 2 +- 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/lib/e2p/ChangeLog b/lib/e2p/ChangeLog index 8c10fc1..252e40c 100644 --- a/lib/e2p/ChangeLog +++ b/lib/e2p/ChangeLog @@ -1,3 +1,9 @@ +2002-10-25 Theodore Ts'o + + * ls.c (list_super2): Print the s_mkfs_time field if it is + present. If the last mount time (s_mtime) is zero, print + "n/a". + 2002-10-20 Theodore Ts'o * e2p.h (e2p_string2mntopt), mntopts.c, ls.c (print_mntopts): diff --git a/lib/e2p/ls.c b/lib/e2p/ls.c index cc3e3ca..9e2b1b5 100644 --- a/lib/e2p/ls.c +++ b/lib/e2p/ls.c @@ -207,11 +207,16 @@ void list_super2(struct ext2_super_block * sb, FILE *f) fprintf(f, "Fragments per group: %u\n", sb->s_frags_per_group); fprintf(f, "Inodes per group: %u\n", sb->s_inodes_per_group); fprintf(f, "Inode blocks per group: %u\n", inode_blocks_per_group); - tm = sb->s_mtime; if (sb->s_first_meta_bg) fprintf(f, "First meta block group: %u\n", sb->s_first_meta_bg); - fprintf(f, "Last mount time: %s", ctime(&tm)); + if (sb->s_mkfs_time) { + tm = sb->s_mkfs_time; + fprintf(f, "Filesystem created: %s", ctime(&tm)); + } + tm = sb->s_mtime; + fprintf(f, "Last mount time: %s", + sb->s_mtime ? ctime(&tm) : "n/a\n"); tm = sb->s_wtime; fprintf(f, "Last write time: %s", ctime(&tm)); fprintf(f, "Mount count: %u\n", sb->s_mnt_count); diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index 5d0974f..079615c 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -1,3 +1,11 @@ +2002-10-25 Theodore Ts'o + + * ext2_fs.h: Add a new superblock field, s_mkfs_time, so that we + know when a filesystem was created. (Sometimes this can + be useful...) + + * initialize.c (ext2fs_initialize): Set the s_mkfs_time field. + 2002-10-20 Theodore Ts'o * ext2_fs.h (EXT3_DEFM_JMODE): Add new default mount options for diff --git a/lib/ext2fs/ext2_fs.h b/lib/ext2fs/ext2_fs.h index ca53902..7cd679d 100644 --- a/lib/ext2fs/ext2_fs.h +++ b/lib/ext2fs/ext2_fs.h @@ -440,7 +440,8 @@ struct ext2_super_block { __u16 s_reserved_word_pad; __u32 s_default_mount_opts; __u32 s_first_meta_bg; /* First metablock group */ - __u32 s_reserved[190]; /* Padding to the end of the block */ + __u32 s_mkfs_time; /* When the filesystem was created */ + __u32 s_reserved[189]; /* Padding to the end of the block */ }; /* diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c index d9be945..ecb27d7 100644 --- a/lib/ext2fs/initialize.c +++ b/lib/ext2fs/initialize.c @@ -127,7 +127,7 @@ errcode_t ext2fs_initialize(const char *name, int flags, } set_field(s_checkinterval, EXT2_DFL_CHECKINTERVAL); - super->s_lastcheck = time(NULL); + super->s_mkfs_time = super->s_lastcheck = time(NULL); super->s_creator_os = CREATOR_OS; -- 1.8.3.1