limine: Make module paths better defined

This commit is contained in:
mintsuki 2022-03-26 08:36:53 +01:00
parent 8aa1372ce9
commit 652b5447fe
4 changed files with 23 additions and 3 deletions

View File

@ -502,6 +502,8 @@ struct limine_module_response {
* `modules` - Pointer to an array of `module_count` pointers to
`struct limine_module` structures.
Note: The first module (module 0) is always the kernel file.
```c
struct limine_module {
void *base;
@ -514,7 +516,7 @@ struct limine_module {
* `base` - The address of the module.
* `length` - The size of the module.
* `path` - The bootloader-specific path of the module.
* `path` - The path of the module within the volume, with a leading slash.
* `cmdline` - A command line associated with the module.
* `file_location` - A pointer to the file location structure for the module.

View File

@ -9,12 +9,15 @@
# include <efi.h>
#endif
#define PATH_MAX 4096
bool fs_get_guid(struct guid *guid, struct volume *part);
struct file_handle {
bool is_memfile;
bool readall;
struct volume *vol;
char path[PATH_MAX];
void *fd;
void (*read)(void *fd, void *buf, uint64_t loc, uint64_t count);
void (*close)(void *fd);

View File

@ -32,6 +32,14 @@ struct file_handle *fopen(struct volume *part, const char *filename) {
ret->vol = part;
if (strlen(filename) + 2 > PATH_MAX) {
panic(true, "fopen: Path too long");
}
ret->path[0] = '/';
strcpy(ret->path + 1, filename);
#if bios == 1
if (part->pxe) {
if (!tftp_open(ret, 0, 69, filename)) {

View File

@ -120,6 +120,9 @@ bool limine_load(char *config, char *cmdline) {
if ((kernel_file = uri_open(kernel_path)) == NULL)
panic(true, "limine: Failed to open kernel with path `%s`. Is the path correct?", kernel_path);
char *kpath = ext_mem_alloc(strlen(kernel_file->path) + 1);
strcpy(kpath, kernel_file->path);
uint8_t *kernel = freadall(kernel_file, MEMMAP_BOOTLOADER_RECLAIMABLE);
size_t kernel_file_size = kernel_file->size;
@ -369,7 +372,7 @@ FEAT_START
modules[0].base = reported_addr(kernel);
modules[0].length = kernel_file_size;
modules[0].path = reported_addr(kernel_path);
modules[0].path = reported_addr(kpath);
modules[0].cmdline = reported_addr(cmdline);
modules[0].file_location = reported_addr(kl);
@ -396,7 +399,11 @@ FEAT_START
m->base = reported_addr(freadall(f, MEMMAP_KERNEL_AND_MODULES));
m->length = f->size;
m->path = reported_addr(module_path);
char *mpath = ext_mem_alloc(strlen(f->path) + 1);
strcpy(mpath, f->path);
m->path = reported_addr(mpath);
m->cmdline = reported_addr(module_cmdline);
struct limine_file_location *l = ext_mem_alloc(sizeof(struct limine_file_location));