lib/uri: Introduce new file path syntax
diff --git a/common/lib/uri.c b/common/lib/uri.c
index 0b8cd1d5..197e985d 100644
--- a/common/lib/uri.c
+++ b/common/lib/uri.c
@@ -12,7 +12,7 @@
#include <lib/getchar.h>
#include <crypt/blake2b.h>
-// A URI takes the form of: resource://root/path#hash
+// A URI takes the form of: resource(root):/path#hash
// The following function splits up a URI into its components
bool uri_resolve(char *uri, char **resource, char **root, char **path, char **hash) {
size_t length = strlen(uri) + 1;
@@ -24,26 +24,26 @@ bool uri_resolve(char *uri, char **resource, char **root, char **path, char **ha
// Get resource
for (size_t i = 0; ; i++) {
- if (strlen(uri + i) < 3)
+ if (strlen(uri + i) < 1)
return false;
- if (!memcmp(uri + i, "://", 3)) {
+ if (!memcmp(uri + i, "(", 1)) {
*resource = uri;
uri[i] = 0;
- uri += i + 3;
+ uri += i + 1;
break;
}
}
// Get root
for (size_t i = 0; ; i++) {
- if (uri[i] == 0)
+ if (strlen(uri + i) < 3)
return false;
- if (uri[i] == '/') {
+ if (!memcmp(uri + i, "):/", 3)) {
*root = uri;
uri[i] = 0;
- uri += i + 1;
+ uri += i + 3;
break;
}
}
@@ -86,7 +86,7 @@ static bool parse_bios_partition(char *loc, int *drive, int *partition) {
if (loc[i] == ':') {
loc[i] = 0;
if (*loc == 0) {
- panic(true, "Drive number cannot be omitted for hdd:// and odd://");
+ panic(true, "Drive number cannot be omitted for hdd():/ and odd():/");
} else {
val = strtoui(loc, NULL, 10);
if (val < 1 || val > 256) {
@@ -217,9 +217,7 @@ struct file_handle *uri_open(char *uri) {
panic(true, "No resource specified for URI `%#`.", uri);
}
- if (!strcmp(resource, "bios")) {
- panic(true, "bios:// resource is no longer supported. Check CONFIG.md for hdd:// and odd://");
- } else if (!strcmp(resource, "hdd")) {
+ if (!strcmp(resource, "hdd")) {
ret = uri_hdd_dispatch(root, path);
} else if (!strcmp(resource, "odd")) {
ret = uri_odd_dispatch(root, path);
diff --git a/common/protos/limine.c b/common/protos/limine.c
index ca8cc85e..3ae1692c 100644
--- a/common/protos/limine.c
+++ b/common/protos/limine.c
@@ -1079,10 +1079,12 @@ FEAT_START
}
strcpy(module_path_abs_p, k_resource);
module_path_abs_p += strlen(k_resource);
- strcpy(module_path_abs_p, "://");
- module_path_abs_p += 3;
+ strcpy(module_path_abs_p, "(");
+ module_path_abs_p += 1;
strcpy(module_path_abs_p, k_root);
module_path_abs_p += strlen(k_root);
+ strcpy(module_path_abs_p, "):");
+ module_path_abs_p += 2;
get_absolute_path(module_path_abs_p, module_path, k_path);
module_path = module_path_abs;
diff --git a/test/limine.cfg b/test/limine.cfg
index 27c09385..bce31037 100644
--- a/test/limine.cfg
+++ b/test/limine.cfg
@@ -1,6 +1,6 @@
# Some example macros
-${TEST_KERNEL}=boot:///boot/test.elf
-${WALLPAPER_PATH}=boot:///boot/bg.jpg
+${TEST_KERNEL}=boot():/boot/test.elf
+${WALLPAPER_PATH}=boot():/boot/bg.jpg
default_entry: 1
timeout: 3
@@ -20,23 +20,23 @@ term_backdrop: 008080
module_path: ${WALLPAPER_PATH}
module_cmdline: This is the first module.
- module_path: boot:///boot/bg.jpg
+ module_path: boot():/boot/bg.jpg
/Multiboot2 Test
comment: Test of the multiboot2 boot protocol.
protocol: multiboot2
- kernel_path: boot:///boot/multiboot2.elf
+ kernel_path: boot():/boot/multiboot2.elf
kernel_cmdline: This is an example kernel command line.
- module_path: boot:///boot/bg.jpg
+ module_path: boot():/boot/bg.jpg
module_string: This is the first module.
/EFI Chainloading
comment: Test EFI image chainloading.
protocol: efi_chainload
- image_path: boot:///EFI/BOOT/BOOTX64.EFI
+ image_path: boot():/EFI/BOOT/BOOTX64.EFI
/BIOS Chainloading
comment: Test BIOS chainloading.
@@ -51,8 +51,8 @@ term_backdrop: 008080
comment: Test of the multiboot1 boot protocol.
protocol: multiboot1
- kernel_path: boot:///boot/multiboot.elf
+ kernel_path: boot():/boot/multiboot.elf
kernel_cmdline: This is an example kernel command line.
- module_path: boot:///boot/bg.jpg
+ module_path: boot():/boot/bg.jpg
module_string: This is the first module.
