limine: Fix assignment of paths broken in 0431623
This commit is contained in:
parent
7db783f080
commit
00b9f44255
@ -9,8 +9,6 @@
|
||||
# include <efi.h>
|
||||
#endif
|
||||
|
||||
#define PATH_MAX 4096
|
||||
|
||||
bool fs_get_guid(struct guid *guid, struct volume *part);
|
||||
char *fs_get_label(struct volume *part);
|
||||
|
||||
@ -18,7 +16,7 @@ struct file_handle {
|
||||
bool is_memfile;
|
||||
bool readall;
|
||||
struct volume *vol;
|
||||
char path[PATH_MAX];
|
||||
char *path;
|
||||
void *fd;
|
||||
void (*read)(void *fd, void *buf, uint64_t loc, uint64_t count);
|
||||
void (*close)(void *fd);
|
||||
|
@ -34,10 +34,18 @@ bool fs_get_guid(struct guid *guid, struct volume *part) {
|
||||
}
|
||||
|
||||
struct file_handle *fopen(struct volume *part, const char *filename) {
|
||||
if (strlen(filename) + 2 > PATH_MAX) {
|
||||
panic(true, "fopen: Path too long");
|
||||
size_t filename_new_len = strlen(filename) + 2;
|
||||
char *filename_new = ext_mem_alloc(filename_new_len);
|
||||
|
||||
if (filename[0] != '/') {
|
||||
filename_new[0] = '/';
|
||||
strcpy(&filename_new[1], filename);
|
||||
} else {
|
||||
strcpy(filename_new, filename);
|
||||
}
|
||||
|
||||
filename = filename_new;
|
||||
|
||||
struct file_handle *ret;
|
||||
|
||||
#if bios == 1
|
||||
@ -45,24 +53,29 @@ struct file_handle *fopen(struct volume *part, const char *filename) {
|
||||
if ((ret = tftp_open(0, 69, filename)) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return ret;
|
||||
goto success;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((ret = ext2_open(part, filename)) != NULL) {
|
||||
return ret;
|
||||
goto success;
|
||||
}
|
||||
if ((ret = fat32_open(part, filename)) != NULL) {
|
||||
return ret;
|
||||
goto success;
|
||||
}
|
||||
if ((ret = iso9660_open(part, filename)) != NULL) {
|
||||
return ret;
|
||||
goto success;
|
||||
}
|
||||
if ((ret = ntfs_open(part, filename)) != NULL) {
|
||||
return ret;
|
||||
goto success;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
success:
|
||||
ret->path = (char *)filename;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void fclose(struct file_handle *fd) {
|
||||
|
@ -200,9 +200,7 @@ static struct limine_file get_file(struct file_handle *file, char *cmdline) {
|
||||
}
|
||||
}
|
||||
|
||||
char *path = ext_mem_alloc(strlen(file->path) + 1);
|
||||
strcpy(path, file->path);
|
||||
ret.path = reported_addr(path);
|
||||
ret.path = reported_addr(file->path);
|
||||
|
||||
ret.address = reported_addr(freadall(file, MEMMAP_KERNEL_AND_MODULES));
|
||||
ret.size = file->size;
|
||||
|
Loading…
Reference in New Issue
Block a user