diff options
author | Theotime Combes <tcombes@google.com> | 2020-08-18 11:18:07 +0000 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2020-08-20 09:22:57 -0700 |
commit | bbfab0dd6b2704305589f500be31c6a10248fb4c (patch) | |
tree | 654f23e8af6cf4dd1a3f92bb7f0ce688ce9e8975 | |
parent | 5c723d171340e0913e4de13cc1a330c60ed79cf0 (diff) | |
download | f2fs-tools-bbfab0dd6b2704305589f500be31c6a10248fb4c.tar.gz |
mkfs.f2fs: add -r (fake_seed) flag
r flag sets the checkpointing seed to 0 (initially used to
remove randomness for apex generation)
Signed-off-by: Theotime Combes <tcombes@google.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | include/f2fs_fs.h | 1 | ||||
-rw-r--r-- | man/mkfs.f2fs.8 | 6 | ||||
-rw-r--r-- | mkfs/f2fs_format.c | 2 | ||||
-rw-r--r-- | mkfs/f2fs_format_main.c | 6 |
4 files changed, 13 insertions, 2 deletions
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h index 20abdf7..b5bda13 100644 --- a/include/f2fs_fs.h +++ b/include/f2fs_fs.h @@ -407,6 +407,7 @@ struct f2fs_configuration { time_t fixed_time; /* mkfs parameters */ + int fake_seed; u_int32_t next_free_nid; u_int32_t quota_inum; u_int32_t quota_dnum; diff --git a/man/mkfs.f2fs.8 b/man/mkfs.f2fs.8 index 729afdf..e2aee76 100644 --- a/man/mkfs.f2fs.8 +++ b/man/mkfs.f2fs.8 @@ -59,6 +59,9 @@ mkfs.f2fs \- create an F2FS file system .B \-q ] [ +.B \-r +] +[ .B \-R .I root_owner ] @@ -216,6 +219,9 @@ Default is disabled. Quiet mode. With it, mkfs.f2fs does not show any messages, including the basic messages. .TP +.BI \-r +Sets the checkpointing srand seed to 0. +.TP .BI \-R Give root_owner option for initial uid/gid assignment. Default is set by getuid()/getgid(), and assigned by "-R $uid:$gid". diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c index cb27b42..a6c542e 100644 --- a/mkfs/f2fs_format.c +++ b/mkfs/f2fs_format.c @@ -670,7 +670,7 @@ static int f2fs_write_check_point_pack(void) } /* 1. cp page 1 of checkpoint pack 1 */ - srand(time(NULL)); + srand((c.fake_seed) ? 0 : time(NULL)); cp->checkpoint_ver = cpu_to_le64(rand() | 0x1); set_cp(cur_node_segno[0], c.cur_seg[CURSEG_HOT_NODE]); set_cp(cur_node_segno[1], c.cur_seg[CURSEG_WARM_NODE]); diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c index 9fe049c..f2f0a80 100644 --- a/mkfs/f2fs_format_main.c +++ b/mkfs/f2fs_format_main.c @@ -58,6 +58,7 @@ static void mkfs_usage() MSG(0, " -O feature1[,feature2,...] e.g. \"encrypt\"\n"); MSG(0, " -C [encoding[:flag1,...]] Support casefolding with optional flags\n"); MSG(0, " -q quiet mode\n"); + MSG(0, " -r set checkpointing seed (srand()) to 0\n"); MSG(0, " -R root_owner [default: 0:0]\n"); MSG(0, " -s # of segments per section [default:1]\n"); MSG(0, " -S sparse mode\n"); @@ -124,7 +125,7 @@ static void add_default_options(void) static void f2fs_parse_options(int argc, char *argv[]) { - static const char *option_string = "qa:c:C:d:e:E:g:il:mo:O:R:s:S:z:t:T:U:Vfw:"; + static const char *option_string = "qa:c:C:d:e:E:g:il:mo:O:rR:s:S:z:t:T:U:Vfw:"; int32_t option=0; int val; char *token; @@ -184,6 +185,9 @@ static void f2fs_parse_options(int argc, char *argv[]) if (parse_feature(feature_table, optarg)) mkfs_usage(); break; + case 'r': + c.fake_seed = 1; + break; case 'R': if (parse_root_owner(optarg, &c.root_uid, &c.root_gid)) mkfs_usage(); |