:: commit 08d53bff58f762e7ea726373e8e6534e98f078aa

mintsuki <mintsuki@protonmail.com> — 2020-12-10 06:13

parents: 7545864f5b

part: Implement unified namespace between GPT partition UUIDs and filesystem UUIDs

diff --git a/CONFIG.md b/CONFIG.md
index 5126ee39..a03911db 100644
--- a/CONFIG.md
+++ b/CONFIG.md
@@ -101,5 +101,5 @@ The format for `root` changes depending on the resource used.
 A resource can be one of the following:
 * `boot` - The `root` is the 1-based decimal value representing the partition on the boot drive. If omitted, the partition containing the configuration file on the boot drive is used. For example: `boot://2/...` will use partition 2 of the boot drive and `boot:///...` will use the partition containing the config file on the boot drive.
 * `bios` - The `root` takes the form of `drive:partition`; for example: `bios://3:1/...` would use BIOS drive 3, partition 1. Partitions and BIOS drives are both 1-based. Omitting the drive is possible; for example: `bios://:2/...`. Omitting the drive makes Limine use the boot drive.
-* `guid` - The `root` takes the form of a GUID/UUID, such as `guid://736b5698-5ae1-4dff-be2c-ef8f44a61c52/...`. It is a filesystem GUID and not a partition GUID.
-* `tftp` - The `root` is the ip address of the tftp server to load the file from, if the root is left empty (`tftp:///file.elf`) the file will be loaded from the server limine booted from.
+* `guid` - The `root` takes the form of a GUID/UUID, such as `guid://736b5698-5ae1-4dff-be2c-ef8f44a61c52/...`. The GUID is that of either a filesystem, when available, or a GPT partition GUID, when using GPT, in a unified namespace.
+* `tftp` - The `root` is the IP address of the tftp server to load the file from. If the root is left empty (`tftp:///...`) the file will be loaded from the server Limine booted from. This resource is only available when booting off PXE.
diff --git a/limine-pxe.bin b/limine-pxe.bin
index c802c266..0f0f4504 100644
Binary files a/limine-pxe.bin and b/limine-pxe.bin differ
diff --git a/limine.bin b/limine.bin
index 284603e1..3ef8a9b7 100644
Binary files a/limine.bin and b/limine.bin differ
diff --git a/stage2.map b/stage2.map
index 54c53bf1..a0354678 100644
Binary files a/stage2.map and b/stage2.map differ
diff --git a/stage2/lib/part.c b/stage2/lib/part.c
index d54054a4..edb68b2d 100644
--- a/stage2/lib/part.c
+++ b/stage2/lib/part.c
@@ -88,6 +88,9 @@ static int gpt_get_part(struct part *ret, int drive, int partition) {
         ret->guid = guid;
     }
 
+    ret->part_guid_valid = true;
+    ret->part_guid = entry.unique_partition_guid;
+
     return 0;
 }
 
@@ -137,6 +140,8 @@ static int mbr_get_part(struct part *ret, int drive, int partition) {
         ret->guid = guid;
     }
 
+    ret->part_guid_valid = false;
+
     return 0;
 }
 
@@ -205,15 +210,21 @@ load_up:
 }
 
 bool part_get_by_guid(struct part *part, struct guid *guid) {
-    for (size_t i = 0; i < part_index_i; i++) {
-        if (!part_index[i].guid_valid)
-            continue;
-        if (!memcmp(&part_index[i].guid, guid, 16)) {
-            *part = part_index[i];
-            return true;
+    size_t i;
+    for (i = 0; i < part_index_i; i++) {
+        if (part_index[i].guid_valid
+         && memcmp(&part_index[i].guid, guid, 16) == 0) {
+            goto found;
+        }
+        if (part_index[i].part_guid_valid
+         && memcmp(&part_index[i].part_guid, guid, 16) == 0) {
+            goto found;
         }
     }
     return false;
+found:
+    *part = part_index[i];
+    return true;
 }
 
 int part_read(struct part *part, void *buffer, uint64_t loc, uint64_t count) {
diff --git a/stage2/lib/part.h b/stage2/lib/part.h
index 4fb9b08d..7be0e712 100644
--- a/stage2/lib/part.h
+++ b/stage2/lib/part.h
@@ -17,6 +17,8 @@ struct part {
     uint64_t sect_count;
     bool guid_valid;
     struct guid guid;
+    bool part_guid_valid;
+    struct guid part_guid;
 };
 
 void part_create_index(void);
tab: 248 wrap: offon