@@ -203,7 +203,7 @@ int make_btrfs(int fd, const char *device, const char *label, char *fs_uuid,
memset(&super, 0, sizeof(super));
num_bytes = (num_bytes / sectorsize) * sectorsize;
- if (fs_uuid) {
+ if (fs_uuid && *fs_uuid) {
if (uuid_parse(fs_uuid, super.fsid) != 0) {
fprintf(stderr, "could not parse UUID: %s\n", fs_uuid);
ret = -EINVAL;
@@ -216,6 +216,11 @@ int make_btrfs(int fd, const char *device, const char *label, char *fs_uuid,
}
} else {
uuid_generate(super.fsid);
+ /*
+ * if the fs_uuid is a valid pointer, return the generated uuid
+ */
+ if (fs_uuid)
+ uuid_unparse(super.fsid, fs_uuid);
}
uuid_generate(super.dev_item.uuid);
uuid_generate(chunk_tree_uuid);
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 <kreijack@inwind.it> --- utils.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)