diff options
author | supercomputer7 <liavalb@gmail.com> | 2019-10-07 03:12:37 +0300 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-10-07 10:11:39 +0200 |
commit | de49714f3690aea07a08d814b7100580b3e1c427 (patch) | |
tree | 7e8eeda1b8d39009a4cd31a91914d849bbde8070 /Kernel/init.cpp | |
parent | b5a043cf425ec2fa2d7154728317a7d55024a095 (diff) | |
download | serenity-de49714f3690aea07a08d814b7100580b3e1c427.zip |
PartitionTable: Initial GPT Support, Adding Block Limit
Also added a script to handle creation of GPT partitioned disk (with
GRUB config file). Block limit will be used to disallow potential access
to other partitions.
Diffstat (limited to 'Kernel/init.cpp')
-rw-r--r-- | Kernel/init.cpp | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/Kernel/init.cpp b/Kernel/init.cpp index d73b1bca1d..279c1d254e 100644 --- a/Kernel/init.cpp +++ b/Kernel/init.cpp @@ -14,6 +14,7 @@ #include <Kernel/Devices/DiskPartition.h> #include <Kernel/Devices/FloppyDiskDevice.h> #include <Kernel/Devices/FullDevice.h> +#include <Kernel/Devices/GPTPartitionTable.h> #include <Kernel/Devices/KeyboardDevice.h> #include <Kernel/Devices/MBRPartitionTable.h> #include <Kernel/Devices/MBVGADevice.h> @@ -96,18 +97,34 @@ VFS* vfs; } MBRPartitionTable mbr(root_dev); + if (!mbr.initialize()) { kprintf("init_stage2: couldn't read MBR from disk\n"); hang(); } - auto partition = mbr.partition(partition_number); - if (!partition) { - kprintf("init_stage2: couldn't get partition %d\n", partition_number); - hang(); + if (mbr.is_protective_mbr()) { + dbgprintf("GPT Partitioned Storage Detected!\n"); + GPTPartitionTable gpt(root_dev); + if (!gpt.initialize()) { + kprintf("init_stage2: couldn't read GPT from disk\n"); + hang(); + } + auto partition = gpt.partition(partition_number); + if (!partition) { + kprintf("init_stage2: couldn't get partition %d\n", partition_number); + hang(); + } + root_dev = *partition; + } else { + dbgprintf("MBR Partitioned Storage Detected!\n"); + auto partition = mbr.partition(partition_number); + if (!partition) { + kprintf("init_stage2: couldn't get partition %d\n", partition_number); + hang(); + } + root_dev = *partition; } - - root_dev = *partition; } auto e2fs = Ext2FS::create(root_dev); |