aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2024-05-01 16:54:26 -0400
committerTheodore Ts'o <tytso@mit.edu>2024-05-01 16:54:26 -0400
commit80abfebc673bb2a1496dec88f7f0601e7325d3c2 (patch)
treee78c40188f2c8e4c4b7e9b67100697cffcc99b51
parent2e66d0ecfe97b699678dc059ba16ceff05b527cf (diff)
downloade2fsprogs-80abfebc673bb2a1496dec88f7f0601e7325d3c2.tar.gz
e2image: add support for post-2038 dates in the e2image header
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r--lib/ext2fs/e2image.h5
-rw-r--r--misc/e2image.c8
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/ext2fs/e2image.h b/lib/ext2fs/e2image.h
index 53b20cc73..143e0dc6c 100644
--- a/lib/ext2fs/e2image.h
+++ b/lib/ext2fs/e2image.h
@@ -26,8 +26,9 @@ struct ext2_image_hdr {
__u32 image_device; /* Device number of image file */
__u32 image_inode; /* Inode number of image file */
- __u32 image_time; /* Time of image creation */
- __u32 image_reserved[8];
+ __u32 image_time_lo; /* Time of image creation */
+ __u32 image_time_hi; /* High bits of image test creation */
+ __u32 image_reserved[7];
__u32 offset_super; /* Byte offset of the sb and descriptors */
__u32 offset_inode; /* Byte offset of the inode table */
diff --git a/misc/e2image.c b/misc/e2image.c
index 1ae03001f..2c46d3ff8 100644
--- a/misc/e2image.c
+++ b/misc/e2image.c
@@ -239,6 +239,7 @@ static void write_image_file(ext2_filsys fs, int fd)
struct ext2_image_hdr hdr;
struct stat st;
errcode_t retval;
+ time_t now = time(0);
write_header(fd, NULL, sizeof(struct ext2_image_hdr), fs->blocksize);
memset(&hdr, 0, sizeof(struct ext2_image_hdr));
@@ -292,7 +293,12 @@ static void write_image_file(ext2_filsys fs, int fd)
}
memcpy(hdr.fs_uuid, fs->super->s_uuid, sizeof(hdr.fs_uuid));
- hdr.image_time = ext2fs_cpu_to_le32(time(0));
+ hdr.image_time_lo = ext2fs_cpu_to_le32(now & 0xFFFFFFFF);
+#if (SIZEOF_TIME_T > 4)
+ hdr.image_time_hi = ext2fs_cpu_to_le32(now >> 32);
+#else
+ hdr_image_time_hi = 0;
+#endif
write_header(fd, &hdr, sizeof(struct ext2_image_hdr), fs->blocksize);
}