Implement VFS syscalls
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m29s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m29s
This commit is contained in:
@@ -103,25 +103,38 @@ struct elf_aux proc_load_segments (struct proc* proc, uint8_t* elf) {
|
||||
return aux;
|
||||
}
|
||||
|
||||
struct proc* proc_from_file (const char* mountpoint, const char* path) {
|
||||
struct proc* proc_from_file (struct procgroup* procgroup, const char* mountpoint,
|
||||
const char* path) {
|
||||
struct fs_desc_buffer desc;
|
||||
|
||||
if (vfs_describe (mountpoint, path, &desc) != ST_OK)
|
||||
if (vfs_open (procgroup, mountpoint, path) != ST_OK)
|
||||
return NULL;
|
||||
|
||||
if (desc.type != FS_FILE)
|
||||
if (vfs_describe (procgroup, mountpoint, path, &desc) != ST_OK) {
|
||||
vfs_close (procgroup, mountpoint, path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (desc.type != FS_FILE) {
|
||||
vfs_close (procgroup, mountpoint, path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uint8_t* temp_buffer = malloc (desc.size);
|
||||
|
||||
if (temp_buffer == NULL)
|
||||
return NULL;
|
||||
|
||||
if (vfs_read (mountpoint, path, temp_buffer, 0, desc.size) != ST_OK) {
|
||||
free (temp_buffer);
|
||||
if (temp_buffer == NULL) {
|
||||
vfs_close (procgroup, mountpoint, path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (vfs_read (procgroup, mountpoint, path, temp_buffer, 0, desc.size) != ST_OK) {
|
||||
free (temp_buffer);
|
||||
vfs_close (procgroup, mountpoint, path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
vfs_close (procgroup, mountpoint, path);
|
||||
|
||||
bool ok = proc_check_elf (temp_buffer);
|
||||
|
||||
DEBUG ("Spawning %s:%s, elf header %s\n", mountpoint, path, ok ? "ok" : "bad");
|
||||
@@ -300,11 +313,11 @@ void proc_init (void) {
|
||||
irq_attach (&proc_irq_sched, NULL, CPU_REQUEST_SCHED);
|
||||
#endif
|
||||
|
||||
struct proc* spin_proc = proc_from_file ("ramdisk", "/spin");
|
||||
struct proc* spin_proc = proc_from_file (NULL, "ramdisk", "/spin");
|
||||
struct cpu* spin_cpu = thiscpu;
|
||||
proc_register (spin_proc, &spin_cpu);
|
||||
|
||||
struct proc* init = proc_from_file ("ramdisk", "/init");
|
||||
struct proc* init = proc_from_file (NULL, "ramdisk", "/init");
|
||||
init->procgroup->capabilities |= (PROC_CAP_TERMINAL | PROC_CAP_KB);
|
||||
struct cpu* init_cpu = thiscpu;
|
||||
proc_register (init, &init_cpu);
|
||||
|
||||
Reference in New Issue
Block a user