Loading fs_mgr/liblp/builder.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -250,6 +250,7 @@ bool MetadataBuilder::Init(const BlockDeviceInfo& device_info, uint32_t metadata geometry_.metadata_slot_count = metadata_slot_count; geometry_.alignment = device_info_.alignment; geometry_.alignment_offset = device_info_.alignment_offset; geometry_.block_device_size = device_info_.size; return true; } Loading fs_mgr/liblp/include/liblp/metadata_format.h +5 −0 Original line number Diff line number Diff line Loading @@ -129,6 +129,11 @@ typedef struct LpMetadataGeometry { * If it cannot be determined, it is assumed to be 0. */ uint32_t alignment_offset; /* 72: Block device size, as specified when the metadata was created. This * can be used to verify the geometry against a target device. */ uint64_t block_device_size; } __attribute__((packed)) LpMetadataGeometry; /* The logical partition metadata has a number of tables; they are described Loading fs_mgr/liblp/utility_test.cpp +10 −2 Original line number Diff line number Diff line Loading @@ -31,8 +31,16 @@ TEST(liblp, SlotNumberForSlotSuffix) { } TEST(liblp, GetMetadataOffset) { LpMetadataGeometry geometry = { LP_METADATA_GEOMETRY_MAGIC, sizeof(geometry), {0}, 16384, 4, 10000, 80000, 0, 0}; LpMetadataGeometry geometry = {LP_METADATA_GEOMETRY_MAGIC, sizeof(geometry), {0}, 16384, 4, 10000, 80000, 0, 0, 1024 * 1024}; EXPECT_EQ(GetPrimaryMetadataOffset(geometry, 0), 4096); EXPECT_EQ(GetPrimaryMetadataOffset(geometry, 1), 4096 + 16384); EXPECT_EQ(GetPrimaryMetadataOffset(geometry, 2), 4096 + 16384 * 2); Loading fs_mgr/liblp/writer.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -108,6 +108,11 @@ static bool ValidateAndSerializeMetadata(int fd, const LpMetadata& metadata, std LERROR << "Not enough space to backup all logical partition metadata slots."; return false; } if (blockdevice_size != metadata.geometry.block_device_size) { LERROR << "Block device size " << blockdevice_size << " does not match metadata requested size " << metadata.geometry.block_device_size; return false; } // Make sure all partition entries reference valid extents. for (const auto& partition : metadata.partitions) { Loading Loading
fs_mgr/liblp/builder.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -250,6 +250,7 @@ bool MetadataBuilder::Init(const BlockDeviceInfo& device_info, uint32_t metadata geometry_.metadata_slot_count = metadata_slot_count; geometry_.alignment = device_info_.alignment; geometry_.alignment_offset = device_info_.alignment_offset; geometry_.block_device_size = device_info_.size; return true; } Loading
fs_mgr/liblp/include/liblp/metadata_format.h +5 −0 Original line number Diff line number Diff line Loading @@ -129,6 +129,11 @@ typedef struct LpMetadataGeometry { * If it cannot be determined, it is assumed to be 0. */ uint32_t alignment_offset; /* 72: Block device size, as specified when the metadata was created. This * can be used to verify the geometry against a target device. */ uint64_t block_device_size; } __attribute__((packed)) LpMetadataGeometry; /* The logical partition metadata has a number of tables; they are described Loading
fs_mgr/liblp/utility_test.cpp +10 −2 Original line number Diff line number Diff line Loading @@ -31,8 +31,16 @@ TEST(liblp, SlotNumberForSlotSuffix) { } TEST(liblp, GetMetadataOffset) { LpMetadataGeometry geometry = { LP_METADATA_GEOMETRY_MAGIC, sizeof(geometry), {0}, 16384, 4, 10000, 80000, 0, 0}; LpMetadataGeometry geometry = {LP_METADATA_GEOMETRY_MAGIC, sizeof(geometry), {0}, 16384, 4, 10000, 80000, 0, 0, 1024 * 1024}; EXPECT_EQ(GetPrimaryMetadataOffset(geometry, 0), 4096); EXPECT_EQ(GetPrimaryMetadataOffset(geometry, 1), 4096 + 16384); EXPECT_EQ(GetPrimaryMetadataOffset(geometry, 2), 4096 + 16384 * 2); Loading
fs_mgr/liblp/writer.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -108,6 +108,11 @@ static bool ValidateAndSerializeMetadata(int fd, const LpMetadata& metadata, std LERROR << "Not enough space to backup all logical partition metadata slots."; return false; } if (blockdevice_size != metadata.geometry.block_device_size) { LERROR << "Block device size " << blockdevice_size << " does not match metadata requested size " << metadata.geometry.block_device_size; return false; } // Make sure all partition entries reference valid extents. for (const auto& partition : metadata.partitions) { Loading