shithub: lwext4

Download patch

ref: 151cd9f6e9120e3c41600875c6cfa42dc1321a0b
parent: fa7ef73d810310ca42d361d337aeb5fea87c3ae4
author: Max Maisel <[email protected]>
date: Thu Mar 1 12:31:32 EST 2018

ext4_mkfs: Added UUID parameter to create new filesystems with non-zero UUID

--- a/include/ext4_mkfs.h
+++ b/include/ext4_mkfs.h
@@ -63,6 +63,7 @@
 	uint16_t feat_incompat;
 	uint32_t bg_desc_reserve_blocks;
 	uint16_t dsc_size;
+	uint8_t uuid[UUID_SIZE];
 	bool journal;
 	const char *label;
 };
--- a/src/ext4_mkfs.c
+++ b/src/ext4_mkfs.c
@@ -95,6 +95,7 @@
 	info->label = sb->volume_name;
 	info->len = (uint64_t)info->block_size * ext4_sb_get_blocks_cnt(sb);
 	info->dsc_size = to_le16(sb->desc_size);
+	memcpy(info->uuid, sb->uuid, UUID_SIZE);
 
 	return EOK;
 }
@@ -260,7 +261,7 @@
 	sb->features_incompatible = to_le32(info->feat_incompat);
 	sb->features_read_only = to_le32(info->feat_ro_compat);
 
-	memset(sb->uuid, 0, sizeof(sb->uuid));
+	memcpy(sb->uuid, info->uuid, UUID_SIZE);
 
 	memset(sb->volume_name, 0, sizeof(sb->volume_name));
 	strncpy(sb->volume_name, info->label, sizeof(sb->volume_name));