mirror of
https://github.com/limine-bootloader/limine
synced 2025-02-13 15:44:28 +03:00
Fix ext2fs bug
This commit is contained in:
parent
2fc3b21295
commit
8be6ea8a3d
BIN
qloader2.bin
BIN
qloader2.bin
Binary file not shown.
@ -210,7 +210,8 @@ static int ext2fs_parse_dirent(struct ext2fs_dir_entry *dir, struct ext2fs_file_
|
||||
if (*path == '/')
|
||||
path++;
|
||||
|
||||
struct ext2fs_inode current_inode = fd->root_inode;
|
||||
struct ext2fs_inode *current_inode = balloc(sizeof(struct ext2fs_inode));
|
||||
*current_inode = fd->root_inode;
|
||||
|
||||
bool escape = false;
|
||||
|
||||
@ -225,14 +226,15 @@ next:
|
||||
else
|
||||
path++;
|
||||
|
||||
uint64_t offset = current_inode.i_blocks[0] * fd->block_size;
|
||||
uint64_t offset = current_inode->i_blocks[0] * fd->block_size;
|
||||
|
||||
while (offset < current_inode.i_size + offset) {
|
||||
uint64_t stop = current_inode->i_size + offset;
|
||||
while (offset < stop) {
|
||||
// preliminary read
|
||||
read_partition(fd->drive, &fd->part, dir, offset, sizeof(struct ext2fs_dir_entry));
|
||||
|
||||
// name read
|
||||
char* name = balloc(dir->name_len);
|
||||
char *name = balloc(dir->name_len);
|
||||
read_partition(fd->drive, &fd->part, name, offset + sizeof(struct ext2fs_dir_entry), dir->name_len);
|
||||
|
||||
int r = strncmp(token, name, dir->name_len);
|
||||
@ -241,10 +243,11 @@ next:
|
||||
|
||||
if (!r) {
|
||||
if (escape) {
|
||||
brewind(sizeof(struct ext2fs_inode));
|
||||
return 0;
|
||||
} else {
|
||||
// update the current inode
|
||||
ext2fs_get_inode(¤t_inode, fd->drive, &fd->part, dir->inode, sb);
|
||||
ext2fs_get_inode(current_inode, fd->drive, &fd->part, dir->inode, sb);
|
||||
goto next;
|
||||
}
|
||||
}
|
||||
@ -252,6 +255,7 @@ next:
|
||||
offset += dir->rec_len;
|
||||
}
|
||||
|
||||
brewind(sizeof(struct ext2fs_inode));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -268,7 +272,11 @@ int ext2fs_open(struct ext2fs_file_handle *ret, int drive, int partition, const
|
||||
ext2fs_get_inode(&ret->root_inode, drive, &ret->part, 2, &sb);
|
||||
|
||||
struct ext2fs_dir_entry entry;
|
||||
ext2fs_parse_dirent(&entry, ret, &sb, path);
|
||||
int r = ext2fs_parse_dirent(&entry, ret, &sb, path);
|
||||
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
ext2fs_get_inode(&ret->inode, drive, &ret->part, entry.inode, &sb);
|
||||
ret->size = ret->inode.i_size;
|
||||
|
||||
|
@ -38,9 +38,6 @@ int fopen(struct file_handle *ret, int disk, int partition, const char *filename
|
||||
return 0;
|
||||
}
|
||||
|
||||
print("fs: Could not determine the file system of disk %u partition %u\n",
|
||||
disk, partition);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -334,5 +334,10 @@ out:
|
||||
va_end(args);
|
||||
text_write(print_buf, print_buf_i);
|
||||
|
||||
#ifdef E9_OUTPUT
|
||||
for (size_t i = 0; i < print_buf_i; i++)
|
||||
port_out_b(0xe9, print_buf[i]);
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include <fs/file.h>
|
||||
|
||||
#define SEPARATOR '\n'
|
||||
#define CONFIG_NAME "qloader2.cfg"
|
||||
#define MAX_CONFIG_SIZE 4096
|
||||
|
||||
static char *config_addr;
|
||||
@ -13,8 +12,10 @@ static char *config_addr;
|
||||
int init_config(int drive, int part) {
|
||||
struct file_handle f;
|
||||
|
||||
if (fopen(&f, drive, part, CONFIG_NAME)) {
|
||||
return -1;
|
||||
if (fopen(&f, drive, part, "/qloader2.cfg")) {
|
||||
if (fopen(&f, drive, part, "/boot/qloader2.cfg")) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (f.size >= MAX_CONFIG_SIZE) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user