mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-31 00:24:51 +00:00
part_blk: probe whole disk if no valid MBR found
Report the whole disk as partition 0 and probe file system. The partitions type is set to 'disk'. Issue #2803.
This commit is contained in:
parent
90360674ed
commit
45743ce884
@ -145,10 +145,11 @@ struct Mbr_partition_table : public Block::Partition_table
|
||||
Mbr *mbr = s.addr<Mbr *>();
|
||||
|
||||
/* no partition table, use whole disc as partition 0 */
|
||||
if (!(mbr->valid()))
|
||||
bool const mbr_valid = mbr->valid();
|
||||
if (!mbr_valid) {
|
||||
_part_list[0] = new (&heap)
|
||||
Block::Partition(0, driver.blk_cnt() - 1);
|
||||
|
||||
} else {
|
||||
_parse_mbr(mbr, [&] (int i, Partition_record *r, unsigned offset) {
|
||||
Genode::log("Partition ", i, ": LBA ",
|
||||
(unsigned int) r->_lba + offset, " (",
|
||||
@ -158,18 +159,23 @@ struct Mbr_partition_table : public Block::Partition_table
|
||||
_part_list[i] = new (&heap)
|
||||
Block::Partition(r->_lba + offset, r->_sectors);
|
||||
});
|
||||
}
|
||||
|
||||
/* Report the partitions */
|
||||
if (reporter.enabled())
|
||||
{
|
||||
if (reporter.enabled()) {
|
||||
|
||||
enum { PROBE_BYTES = 4096, };
|
||||
Genode::size_t const block_size = driver.blk_size();
|
||||
|
||||
Genode::Reporter::Xml_generator xml(reporter, [&] () {
|
||||
|
||||
if (mbr_valid) {
|
||||
xml.attribute("type", "mbr");
|
||||
|
||||
_parse_mbr(mbr, [&] (int i, Partition_record *r, unsigned offset) {
|
||||
|
||||
enum { BYTES = 4096, };
|
||||
Sector fs(driver, r->_lba + offset, BYTES / driver.blk_size());
|
||||
Fs::Type fs_type = Fs::probe(fs.addr<Genode::uint8_t*>(), BYTES);
|
||||
Sector fs(driver, r->_lba + offset, PROBE_BYTES / block_size);
|
||||
Fs::Type fs_type = Fs::probe(fs.addr<Genode::uint8_t*>(), PROBE_BYTES);
|
||||
|
||||
xml.node("partition", [&] {
|
||||
xml.attribute("number", i);
|
||||
@ -183,6 +189,26 @@ struct Mbr_partition_table : public Block::Partition_table
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
xml.attribute("type", "disk");
|
||||
|
||||
enum { PART_NUM = 0, };
|
||||
Block::Partition const &disk = *_part_list[PART_NUM];
|
||||
|
||||
Sector fs(driver, disk.lba, PROBE_BYTES / block_size);
|
||||
Fs::Type fs_type = Fs::probe(fs.addr<Genode::uint8_t*>(), PROBE_BYTES);
|
||||
|
||||
xml.node("partition", [&] {
|
||||
xml.attribute("number", PART_NUM);
|
||||
xml.attribute("start", disk.lba);
|
||||
xml.attribute("length", disk.sectors + 1);
|
||||
xml.attribute("block_size", driver.blk_size());
|
||||
|
||||
if (fs_type.valid()) {
|
||||
xml.attribute("file_system", fs_type);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user