ref: 96b4563a7ed9f603a6f66cbe21cbd1acb2f0294a
parent: 66168642b95814725e1f6662729b112d80ab3abb
parent: 151cd9f6e9120e3c41600875c6cfa42dc1321a0b
author: Grzegorz Kostka <kostka.grzegorz@gmail.com>
date: Thu Mar 1 14:58:03 EST 2018
Merge pull request #36 from mmmaisel/dev Improvements from ext4-browser project
--- a/include/ext4_blockdev.h
+++ b/include/ext4_blockdev.h
@@ -97,6 +97,9 @@
/**@brief Physical write counter*/
uint32_t bwrite_ctr;
+
+ /**@brief User data pointer*/
+ void* p_user;
};
/**@brief Definition of the simple block device.*/
--- a/include/ext4_mbr.h
+++ b/include/ext4_mbr.h
@@ -60,7 +60,7 @@
uint8_t division[4];
};
-int ext4_mbr_write(struct ext4_blockdev *parent, struct ext4_mbr_parts *parts);
+int ext4_mbr_write(struct ext4_blockdev *parent, struct ext4_mbr_parts *parts, uint32_t disk_id);
#ifdef __cplusplus
}
--- 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_mbr.c
+++ b/src/ext4_mbr.c
@@ -59,7 +59,8 @@
};
struct ext4_mbr {
- uint8_t bootstrap[446];
+ uint8_t bootstrap[442];
+ uint32_t disk_id;
struct ext4_part_entry part_entry[4];
uint16_t signature;
};
@@ -126,7 +127,7 @@
return r;
}
-int ext4_mbr_write(struct ext4_blockdev *parent, struct ext4_mbr_parts *parts)
+int ext4_mbr_write(struct ext4_blockdev *parent, struct ext4_mbr_parts *parts, uint32_t disk_id)
{
int r;
uint64_t disk_size;
@@ -157,6 +158,7 @@
struct ext4_mbr *mbr = (void *)parent->bdif->ph_bbuf;
memset(mbr, 0, sizeof(struct ext4_mbr));
+ mbr->disk_id = disk_id;
uint32_t cyl_it = 0;
for (int i = 0; i < 4; ++i) {
--- 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));