From f8a0b85e382ed0f76fd67f65ba5c5697a8468525 Mon Sep 17 00:00:00 2001 From: Goffredo Baroncelli Date: Wed, 17 Dec 2014 21:14:09 +0100 Subject: btrfs-progs: return the fsid from make_btrfs() The function make_btrfs() has as argument the fsid of the filesystem. If this fsid is empty or null make_btrfs() generates a new fsid. However If the buffer is valid (but the string is empty) the generated fsid is copied back to the caller. Signed-off-by: Goffredo Baroncelli Reviewed-by: Satoru Takeuchi Signed-off-by: David Sterba --- mkfs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'mkfs.c') diff --git a/mkfs.c b/mkfs.c index c069d369..962a7cd2 100644 --- a/mkfs.c +++ b/mkfs.c @@ -1142,7 +1142,7 @@ int main(int ac, char **av) int dev_cnt = 0; int saved_optind; char estr[100]; - char *fs_uuid = NULL; + char fs_uuid[BTRFS_UUID_UNPARSED_SIZE] = { 0 }; u64 features = BTRFS_MKFS_DEFAULT_FEATURES; while(1) { @@ -1235,7 +1235,8 @@ int main(int ac, char **av) source_dir_set = 1; break; case 'U': - fs_uuid = optarg; + strncpy(fs_uuid, optarg, + BTRFS_UUID_UNPARSED_SIZE - 1); break; case 'K': discard = 0; @@ -1261,7 +1262,7 @@ int main(int ac, char **av) exit(1); } - if (fs_uuid) { + if (*fs_uuid) { uuid_t dummy_uuid; if (uuid_parse(fs_uuid, dummy_uuid) != 0) { -- cgit v1.2.3