aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2005-09-24 20:14:51 -0400
committerTheodore Ts'o <tytso@mit.edu>2005-09-24 20:14:51 -0400
commit32138187f08d1f1dc03feb269f987982db76f3db (patch)
tree311bb28e00cf06424f2983464400661c920dd466
parent6a7075df301f36587fd99d900d1799710e82262f (diff)
downloade2fsprogs-32138187f08d1f1dc03feb269f987982db76f3db.tar.gz
e2fsprogs-32138187f08d1f1dc03feb269f987982db76f3db.tar.xz
e2fsprogs-32138187f08d1f1dc03feb269f987982db76f3db.zip
Add fs->now to override time(0) in libext2fs
If fs->now is non-zero, use that as the time instead of the system time when setting various filesystem fields (last modified time, last write time, etc.) Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r--lib/ext2fs/ChangeLog8
-rw-r--r--lib/ext2fs/bb_inode.c4
-rw-r--r--lib/ext2fs/closefs.c2
-rw-r--r--lib/ext2fs/ext2fs.h3
-rw-r--r--lib/ext2fs/initialize.c2
-rw-r--r--lib/ext2fs/mkdir.c2
-rw-r--r--lib/ext2fs/mkjournal.c2
-rw-r--r--lib/ext2fs/res_gdt.c4
8 files changed, 18 insertions, 9 deletions
diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog
index 910bfc2f..5e2530ea 100644
--- a/lib/ext2fs/ChangeLog
+++ b/lib/ext2fs/ChangeLog
@@ -1,3 +1,11 @@
+2005-09-24 Theodore Ts'o <tytso@mit.edu>
+
+ * ext2fs.h, bb_inode.c, closefs.c, initialize.c, mkdir.c,
+ mkjournal.c, res_gdt.c: If fs->now is non-zero, use that
+ as the time instead of the system time when setting
+ various filesystem fields (last modified time, last write
+ time, etc.)
+
2005-08-28 Matthias Andree <matthias.andree@gmx.de>
* Fix compiler warnings about missing memcpy prototypes.
diff --git a/lib/ext2fs/bb_inode.c b/lib/ext2fs/bb_inode.c
index dd8e7c31..97a56087 100644
--- a/lib/ext2fs/bb_inode.c
+++ b/lib/ext2fs/bb_inode.c
@@ -124,9 +124,9 @@ errcode_t ext2fs_update_bb_inode(ext2_filsys fs, ext2_badblocks_list bb_list)
if (retval)
goto cleanup;
- inode.i_atime = inode.i_mtime = time(0);
+ inode.i_atime = inode.i_mtime = fs->now ? fs->now : time(0);
if (!inode.i_ctime)
- inode.i_ctime = time(0);
+ inode.i_ctime = fs->now ? fs->now : time(0);
inode.i_blocks = rec.bad_block_count * (fs->blocksize / 512);
inode.i_size = rec.bad_block_count * fs->blocksize;
diff --git a/lib/ext2fs/closefs.c b/lib/ext2fs/closefs.c
index 8539a1c2..6a151937 100644
--- a/lib/ext2fs/closefs.c
+++ b/lib/ext2fs/closefs.c
@@ -219,7 +219,7 @@ errcode_t ext2fs_flush(ext2_filsys fs)
fs_state = fs->super->s_state;
- fs->super->s_wtime = time(NULL);
+ fs->super->s_wtime = fs->now ? fs->now : time(NULL);
fs->super->s_block_group_nr = 0;
#ifdef EXT2FS_ENABLE_SWAPFS
if (fs->flags & EXT2_FLAG_SWAP_BYTES) {
diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index 9c7eee28..c573af39 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -228,10 +228,11 @@ struct struct_ext2_filsys {
struct ext2_super_block * orig_super;
struct ext2_image_hdr * image_header;
__u32 umask;
+ __u32 now;
/*
* Reserved for future expansion
*/
- __u32 reserved[8];
+ __u32 reserved[7];
/*
* Reserved for the use of the calling application.
diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c
index 82cd9f1d..5a0d100c 100644
--- a/lib/ext2fs/initialize.c
+++ b/lib/ext2fs/initialize.c
@@ -168,7 +168,7 @@ errcode_t ext2fs_initialize(const char *name, int flags,
}
set_field(s_checkinterval, EXT2_DFL_CHECKINTERVAL);
- super->s_mkfs_time = super->s_lastcheck = time(NULL);
+ super->s_mkfs_time = super->s_lastcheck = fs->now ? fs->now : time(NULL);
super->s_creator_os = CREATOR_OS;
diff --git a/lib/ext2fs/mkdir.c b/lib/ext2fs/mkdir.c
index 81e7aea5..45e68205 100644
--- a/lib/ext2fs/mkdir.c
+++ b/lib/ext2fs/mkdir.c
@@ -85,7 +85,7 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t inum,
inode.i_blocks = fs->blocksize / 512;
inode.i_block[0] = blk;
inode.i_links_count = 2;
- inode.i_ctime = inode.i_atime = inode.i_mtime = time(NULL);
+ inode.i_ctime = inode.i_atime = inode.i_mtime = fs->now ? fs->now : time(NULL);
inode.i_size = fs->blocksize;
/*
diff --git a/lib/ext2fs/mkjournal.c b/lib/ext2fs/mkjournal.c
index 76ed5cbb..eb350137 100644
--- a/lib/ext2fs/mkjournal.c
+++ b/lib/ext2fs/mkjournal.c
@@ -229,7 +229,7 @@ static errcode_t write_journal_inode(ext2_filsys fs, ext2_ino_t journal_ino,
inode.i_size += fs->blocksize * size;
inode.i_blocks += (fs->blocksize / 512) * es.newblocks;
- inode.i_mtime = inode.i_ctime = time(0);
+ inode.i_mtime = inode.i_ctime = fs->now ? fs->now : time(0);
inode.i_links_count = 1;
inode.i_mode = LINUX_S_IFREG | 0600;
diff --git a/lib/ext2fs/res_gdt.c b/lib/ext2fs/res_gdt.c
index 8b4ddca6..c03f1da0 100644
--- a/lib/ext2fs/res_gdt.c
+++ b/lib/ext2fs/res_gdt.c
@@ -116,7 +116,7 @@ errcode_t ext2fs_create_resize_inode(ext2_filsys fs)
sb->s_feature_ro_compat |=
EXT2_FEATURE_RO_COMPAT_LARGE_FILE;
}
- inode.i_ctime = time(0);
+ inode.i_ctime = fs->now ? fs->now : time(0);
}
for (rsv_off = 0, gdt_off = fs->desc_blocks,
@@ -208,7 +208,7 @@ out_inode:
inode.i_size);
#endif
if (inode_dirty) {
- inode.i_atime = inode.i_mtime = time(0);
+ inode.i_atime = inode.i_mtime = fs->now ? fs->now : time(0);
retval2 = ext2fs_write_inode(fs, EXT2_RESIZE_INO, &inode);
if (!retval)
retval = retval2;