limine: Fix assignment of paths broken in 0431623
diff --git a/common/fs/file.h b/common/fs/file.h
index 62602171..a26c5daf 100644
--- a/common/fs/file.h
+++ b/common/fs/file.h
@@ -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);
diff --git a/common/fs/file.s2.c b/common/fs/file.s2.c
index 42d11068..9e5287bf 100644
--- a/common/fs/file.s2.c
+++ b/common/fs/file.s2.c
@@ -38,10 +38,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
@@ -49,7 +57,7 @@ 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
@@ -57,19 +65,24 @@ struct file_handle *fopen(struct volume *part, const char *filename) {
return ret;
}
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) {
diff --git a/common/protos/limine.c b/common/protos/limine.c
index 51cb625f..3bb011c9 100644
--- a/common/protos/limine.c
+++ b/common/protos/limine.c
@@ -76,9 +76,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;
