release-request-ca7a0f27-e01e-4493-95dc-73b265f88cc9-for-git_oc-mr1-release-4365318 snap-temp-L33600000106883904

Change-Id: Iac2f9e1faf3fb704287080a41ca250f9e4a01736
diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c
index 99fedcd..dbe798b 100644
--- a/lib/ext2fs/initialize.c
+++ b/lib/ext2fs/initialize.c
@@ -107,6 +107,7 @@
 	char		*buf = 0;
 	char		c;
 	double		reserved_ratio;
+	char		*time_env;
 
 	if (!param || !ext2fs_blocks_count(param))
 		return EXT2_ET_INVALID_ARGUMENT;
@@ -123,6 +124,11 @@
 #ifdef WORDS_BIGENDIAN
 	fs->flags |= EXT2_FLAG_SWAP_BYTES;
 #endif
+
+	time_env = getenv("E2FSPROGS_FAKE_TIME");
+	if (time_env)
+		fs->now = strtoul(time_env, NULL, 0);
+
 	io_flags = IO_FLAG_RW;
 	if (flags & EXT2_FLAG_EXCLUSIVE)
 		io_flags |= IO_FLAG_EXCLUSIVE;
diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c
index ba39e01..94d0ef1 100644
--- a/lib/ext2fs/openfs.c
+++ b/lib/ext2fs/openfs.c
@@ -126,6 +126,7 @@
 	struct ext2_group_desc *gdp;
 	int		j;
 #endif
+	char		*time_env;
 
 	EXT2_CHECK_MAGIC(manager, EXT2_ET_MAGIC_IO_MANAGER);
 
@@ -139,6 +140,11 @@
 	/* don't overwrite sb backups unless flag is explicitly cleared */
 	fs->flags |= EXT2_FLAG_MASTER_SB_ONLY;
 	fs->umask = 022;
+
+	time_env = getenv("E2FSPROGS_FAKE_TIME");
+	if (time_env)
+		fs->now = strtoul(time_env, NULL, 0);
+
 	retval = ext2fs_get_mem(strlen(name)+1, &fs->device_name);
 	if (retval)
 		goto cleanup;
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index ed10cc4..9ba16b9 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -105,6 +105,7 @@
 static blk64_t	dev_size;
 
 static struct ext2_super_block fs_param;
+static __u32 zero_buf[4];
 static char *fs_uuid = NULL;
 static char *creator_os;
 static char *volume_label;
@@ -833,6 +834,19 @@
 				continue;
 			}
 			param->s_desc_size = desc_size;
+		} else if (strcmp(token, "hash_seed") == 0) {
+			if (!arg) {
+				r_usage++;
+				badopt = token;
+				continue;
+			}
+			if (uuid_parse(arg,
+				(unsigned char *)param->s_hash_seed) != 0) {
+				fprintf(stderr,
+					_("Invalid hash seed: %s\n"), arg);
+				r_usage++;
+				continue;
+			}
 		} else if (strcmp(token, "offset") == 0) {
 			if (!arg) {
 				r_usage++;
@@ -2944,7 +2958,13 @@
 	free(hash_alg_str);
 	fs->super->s_def_hash_version = (hash_alg >= 0) ? hash_alg :
 		EXT2_HASH_HALF_MD4;
-	uuid_generate((unsigned char *) fs->super->s_hash_seed);
+
+	if (memcmp(fs_param.s_hash_seed, zero_buf,
+		sizeof(fs_param.s_hash_seed)) != 0) {
+		memcpy(fs->super->s_hash_seed, fs_param.s_hash_seed,
+			sizeof(fs->super->s_hash_seed));
+	} else
+		uuid_generate((unsigned char *) fs->super->s_hash_seed);
 
 	/*
 	 * Periodic checks can be enabled/disabled via config file.