diff options
author | Sami Kerola | 2015-08-02 20:28:59 +0200 |
---|---|---|
committer | Karel Zak | 2015-08-03 11:27:37 +0200 |
commit | 98f8b800dc6f7c3b221ba1fbedc0afd6e5013451 (patch) | |
tree | 34dd1d4cd07fd1894a359ee45a8349d6e74292f3 /disk-utils/mkfs.minix.c | |
parent | mkfs.minix: re-fix block count maths (diff) | |
download | kernel-qcow2-util-linux-98f8b800dc6f7c3b221ba1fbedc0afd6e5013451.tar.gz kernel-qcow2-util-linux-98f8b800dc6f7c3b221ba1fbedc0afd6e5013451.tar.xz kernel-qcow2-util-linux-98f8b800dc6f7c3b221ba1fbedc0afd6e5013451.zip |
tests: add way to control mkfs.minix time stamps
Needed in order to create reproducable file systems image files, so that
out come of mkfs.minix can be checksum'ed.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'disk-utils/mkfs.minix.c')
-rw-r--r-- | disk-utils/mkfs.minix.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/disk-utils/mkfs.minix.c b/disk-utils/mkfs.minix.c index 2da0e6878..94ffacb35 100644 --- a/disk-utils/mkfs.minix.c +++ b/disk-utils/mkfs.minix.c @@ -148,6 +148,20 @@ static void __attribute__((__noreturn__)) usage(FILE *out) exit(out == stderr ? MKFS_EX_USAGE : MKFS_EX_OK); } +#ifdef TEST_SCRIPT +static inline time_t mkfs_minix_time(time_t *t) +{ + const char *str = getenv("MKFS_MINIX_TEST_SECOND_SINCE_EPOCH"); + time_t sec; + + if (str && sscanf(str, "%ld", &sec) == 1) + return sec; + return time(t); +} +#else /* !TEST_SCRIPT */ +# define mkfs_minix_time(x) time(x) +#endif + static void super_set_state(void) { switch (fs_version) { @@ -251,7 +265,7 @@ static void make_bad_inode_v1(struct fs_control *ctl) return; mark_inode(MINIX_BAD_INO); inode->i_nlinks = 1; - inode->i_time = time(NULL); + inode->i_time = mkfs_minix_time(NULL); inode->i_mode = S_IFREG + 0000; inode->i_size = ctl->fs_bad_blocks * MINIX_BLOCK_SIZE; zone = next(0); @@ -299,7 +313,7 @@ static void make_bad_inode_v2_v3 (struct fs_control *ctl) return; mark_inode (MINIX_BAD_INO); inode->i_nlinks = 1; - inode->i_atime = inode->i_mtime = inode->i_ctime = time (NULL); + inode->i_atime = inode->i_mtime = inode->i_ctime = mkfs_minix_time(NULL); inode->i_mode = S_IFREG + 0000; inode->i_size = ctl->fs_bad_blocks * MINIX_BLOCK_SIZE; zone = next (0); @@ -351,7 +365,7 @@ static void make_root_inode_v1(struct fs_control *ctl) { mark_inode(MINIX_ROOT_INO); inode->i_zone[0] = get_free_block(ctl); inode->i_nlinks = 2; - inode->i_time = time(NULL); + inode->i_time = mkfs_minix_time(NULL); if (ctl->fs_bad_blocks) inode->i_size = 3 * ctl->fs_dirsize; else { @@ -372,7 +386,7 @@ static void make_root_inode_v2_v3 (struct fs_control *ctl) { mark_inode (MINIX_ROOT_INO); inode->i_zone[0] = get_free_block (ctl); inode->i_nlinks = 2; - inode->i_atime = inode->i_mtime = inode->i_ctime = time (NULL); + inode->i_atime = inode->i_mtime = inode->i_ctime = mkfs_minix_time(NULL); if (ctl->fs_bad_blocks) inode->i_size = 3 * ctl->fs_dirsize; |