Compare commits
2 Commits
26324259f2
...
20429929dd
Author | SHA1 | Date | |
---|---|---|---|
20429929dd | |||
58ca030711 |
@ -116,8 +116,8 @@ void InitRD::for_each(void (*callback)(File& f))
|
||||
}
|
||||
}
|
||||
|
||||
#define INITRD_MAX_FILES_IN_DIR 8
|
||||
#define INITRD_MAX_FILES 32
|
||||
#define INITRD_MAX_FILES_IN_DIR 16
|
||||
#define INITRD_MAX_FILES 64
|
||||
|
||||
namespace InitRD
|
||||
{
|
||||
@ -154,13 +154,13 @@ void initrd_for_each_dir(void (*callback)(InitRD::Directory& f))
|
||||
}
|
||||
}
|
||||
|
||||
static InitRD::File files[32];
|
||||
static InitRD::File files[INITRD_MAX_FILES];
|
||||
static uint32_t total_files = 0;
|
||||
|
||||
static InitRD::Directory dirs[32];
|
||||
static InitRD::Directory dirs[INITRD_MAX_FILES];
|
||||
static uint32_t total_dirs = 0;
|
||||
|
||||
static VFS::Node nodes[63]; // One of the dirs is the initrd_root
|
||||
static VFS::Node nodes[INITRD_MAX_FILES + (INITRD_MAX_FILES - 1)]; // One of the dirs is the initrd_root
|
||||
static uint32_t total_nodes = 0;
|
||||
|
||||
ssize_t initrd_read(VFS::Node* node, size_t offset, size_t length, char* buffer)
|
||||
@ -345,12 +345,20 @@ static bool initrd_register_file(InitRD::File& f, uint64_t inode)
|
||||
static void initrd_scan()
|
||||
{
|
||||
initrd_for_each_dir([](InitRD::Directory& dir) {
|
||||
if (total_dirs >= 32) return;
|
||||
if (total_dirs >= 32)
|
||||
{
|
||||
kwarnln("Failed to register directory %s: Too many directories in initrd", dir.name);
|
||||
return;
|
||||
}
|
||||
uint64_t inode = total_dirs;
|
||||
if (initrd_register_dir(dir, inode)) dirs[total_dirs++] = dir;
|
||||
});
|
||||
InitRD::for_each([](InitRD::File& f) {
|
||||
if (total_files >= 32) return;
|
||||
if (total_files >= 32)
|
||||
{
|
||||
kwarnln("Failed to register file %s: Too many files in initrd", f.name);
|
||||
return;
|
||||
}
|
||||
uint64_t inode = total_files;
|
||||
if (initrd_register_file(f, inode)) files[total_files++] = f;
|
||||
});
|
||||
@ -375,7 +383,7 @@ void InitRD::init()
|
||||
(void*)bootboot.initrd_ptr, Utilities::get_blocks_from_size(PAGE_SIZE, bootboot.initrd_size));
|
||||
kdbgln("physical base at %lx, size %lx, mapped to %p", bootboot.initrd_ptr, bootboot.initrd_size, initrd_base);
|
||||
kdbgln("total blocks: %ld", get_total_blocks());
|
||||
void* leak = kmalloc(4); // leak some memory so that kmalloc doesn't continually allocate and free pages
|
||||
void* leak = kmalloc(4); // leak some memory so that kmalloc doesn't continously allocate and free pages
|
||||
initrd_initialize_root();
|
||||
initrd_scan();
|
||||
VFS::mount_root(&initrd_root);
|
||||
|
Loading…
Reference in New Issue
Block a user