diff options
author | Zoltán Böszörményi <zboszor@pr.hu> | 2020-07-09 13:21:11 +0200 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2020-07-09 19:58:05 -0700 |
commit | 31acef041716cd718b793dcd7c498c7e0522f67a (patch) | |
tree | e84d053fe51e261818729401f76453b9e90e6a1f | |
parent | d03cab6c93d634fe746f55302bbcd28a9eb545a7 (diff) | |
download | f2fs-tools-31acef041716cd718b793dcd7c498c7e0522f67a.tar.gz |
mkfs.f2fs: allow setting volume UUID manually
This patch adds an option to assign UUID manually.
Usage:
# mkfs.f2fs -U uuid_string
Signed-off-by: Zoltán Böszörményi <zboszor@pr.hu>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | include/f2fs_fs.h | 1 | ||||
-rw-r--r-- | mkfs/f2fs_format.c | 9 | ||||
-rw-r--r-- | mkfs/f2fs_format_main.c | 6 |
3 files changed, 14 insertions, 2 deletions
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h index 709bfd8..f60dc0f 100644 --- a/include/f2fs_fs.h +++ b/include/f2fs_fs.h @@ -371,6 +371,7 @@ struct f2fs_configuration { __u8 sb_version[VERSION_LEN + 1]; __u8 version[VERSION_LEN + 1]; char *vol_label; + char *vol_uuid; u_int16_t s_encoding; u_int16_t s_encoding_flags; int heap; diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c index 4999cac..be19c36 100644 --- a/mkfs/f2fs_format.c +++ b/mkfs/f2fs_format.c @@ -442,7 +442,14 @@ static int f2fs_prepare_super_block(void) return -1; } - uuid_generate(sb->uuid); + if (c.vol_uuid) { + if (uuid_parse(c.vol_uuid, sb->uuid)) { + MSG(0, "\tError: supplied string is not a valid UUID\n"); + return -1; + } + } else { + uuid_generate(sb->uuid); + } /* precompute checksum seed for metadata */ if (c.feature & cpu_to_le32(F2FS_FEATURE_INODE_CHKSUM)) diff --git a/mkfs/f2fs_format_main.c b/mkfs/f2fs_format_main.c index 3d86c44..0d77a77 100644 --- a/mkfs/f2fs_format_main.c +++ b/mkfs/f2fs_format_main.c @@ -52,6 +52,7 @@ static void mkfs_usage() MSG(0, " -g add default options\n"); MSG(0, " -i extended node bitmap, node ratio is 20%% by default\n"); MSG(0, " -l label\n"); + MSG(0, " -U uuid\n"); MSG(0, " -m support zoned block device [default:0]\n"); MSG(0, " -o overprovision percentage [default:auto]\n"); MSG(0, " -O feature1[,feature2,...] e.g. \"encrypt\"\n"); @@ -108,7 +109,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:Vfw:"; + static const char *option_string = "qa:c:C:d:e:E:g:il:mo:O:R:s:S:z:t:U:Vfw:"; int32_t option=0; int val; char *token; @@ -186,6 +187,9 @@ static void f2fs_parse_options(int argc, char *argv[]) case 't': c.trim = atoi(optarg); break; + case 'U': + c.vol_uuid = strdup(optarg); + break; case 'f': force_overwrite = 1; break; |