e2fsprogs: Make -U option consistent between tune2fs and mke2fs

Submitted by Drew Davenport on April 13, 2017, 7:47 p.m.

Details

Message ID 20170413194702.GA41849@google.com
State New
Headers show

Commit Message

Drew Davenport April 13, 2017, 7:47 p.m.
Allow "null", "clear", "random", or "time" for the -U option for
mke2fs, which are already allowed options for tune2fs.

Signed-off-by: Drew Davenport <ddavenport@google.com>
---
 misc/mke2fs.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Andreas Dilger April 13, 2017, 10:24 p.m.
On Apr 13, 2017, at 1:47 PM, Drew Davenport <ddavenport@google.com> wrote:
> 
> Allow "null", "clear", "random", or "time" for the -U option for
> mke2fs, which are already allowed options for tune2fs.
> 
> Signed-off-by: Drew Davenport <ddavenport@google.com>

Looks OK, but please also add this to the mke2fs man page, then you can add:

Reviewed-by: Andreas Dilger <adilger@dilger.ca>

> ---
> misc/mke2fs.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/misc/mke2fs.c b/misc/mke2fs.c
> index 49c6e94d..b8d078a0 100644
> --- a/misc/mke2fs.c
> +++ b/misc/mke2fs.c
> @@ -2914,7 +2914,14 @@ int main (int argc, char *argv[])
> 	 * Parse or generate a UUID for the filesystem
> 	 */
> 	if (fs_uuid) {
> -		if (uuid_parse(fs_uuid, fs->super->s_uuid) !=0) {
> +		if ((strcasecmp(fs_uuid, "null") == 0) ||
> +		    (strcasecmp(fs_uuid, "clear") == 0)) {
> +			uuid_clear(fs->super->s_uuid);
> +		} else if (strcasecmp(fs_uuid, "time") == 0) {
> +			uuid_generate_time(fs->super->s_uuid);
> +		} else if (strcasecmp(fs_uuid, "random") == 0) {
> +			uuid_generate(fs->super->s_uuid);
> +		} else if (uuid_parse(fs_uuid, fs->super->s_uuid) != 0) {
> 			com_err(device_name, 0, "could not parse UUID: %s\n",
> 				fs_uuid);
> 			exit(1);
> --
> 2.12.2.762.g0e3151a226-goog
> 


Cheers, Andreas

Patch hide | download patch | download mbox

diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 49c6e94d..b8d078a0 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -2914,7 +2914,14 @@  int main (int argc, char *argv[])
 	 * Parse or generate a UUID for the filesystem
 	 */
 	if (fs_uuid) {
-		if (uuid_parse(fs_uuid, fs->super->s_uuid) !=0) {
+		if ((strcasecmp(fs_uuid, "null") == 0) ||
+		    (strcasecmp(fs_uuid, "clear") == 0)) {
+			uuid_clear(fs->super->s_uuid);
+		} else if (strcasecmp(fs_uuid, "time") == 0) {
+			uuid_generate_time(fs->super->s_uuid);
+		} else if (strcasecmp(fs_uuid, "random") == 0) {
+			uuid_generate(fs->super->s_uuid);
+		} else if (uuid_parse(fs_uuid, fs->super->s_uuid) != 0) {
 			com_err(device_name, 0, "could not parse UUID: %s\n",
 				fs_uuid);
 			exit(1);