]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
e2image: add support for post-2038 dates in the e2image header
authorTheodore Ts'o <tytso@mit.edu>
Wed, 1 May 2024 20:54:26 +0000 (16:54 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 1 May 2024 20:54:26 +0000 (16:54 -0400)
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ext2fs/e2image.h
misc/e2image.c

index 53b20cc73994342e48f9badc229234bd99c1173c..143e0dc6cc5d949528b38c20c045f3fc92e38e9d 100644 (file)
@@ -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  */
index 1ae03001fe9f9a976c3ec5591dee0324ff733c28..2c46d3ff87d86b766c094341bcf708bfdaa09b40 100644 (file)
@@ -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);
 }