Implemented MOUNT command for initrc.conf. Documentation in initrc.conf. (initrc.c:initrc_read())
This commit is contained in:
parent
6e82ad6d00
commit
c5bd4e5766
|
|
@ -1,5 +1,10 @@
|
|||
ECHO "Initrc for Kimi's OS"
|
||||
MODULE boot/idm.elf
|
||||
ECHO "Initrc for Kimi's OS" # Prints a string to the debug log
|
||||
MODULE boot/idm.elf # Loads and executes a module located at the path
|
||||
MODULE boot/ifsm.elf
|
||||
# This is a comment
|
||||
# source file dest offset
|
||||
# MOUNT /dev/disk/ide0 /home 0x1000 # this is hexadecimal
|
||||
# 4096 this is decimal
|
||||
#0010000 this is octal
|
||||
MOUNT /dev/disk/ide0 /home
|
||||
END # does nothing but make the whole thing slightly more efficient ( stops before end of file's page)
|
||||
|
|
|
|||
|
|
@ -14,5 +14,5 @@ _start:
|
|||
jmp $
|
||||
|
||||
section .bss
|
||||
stack_bottom: resb 0x4000
|
||||
stack_bottom: resb 0x10000
|
||||
stack_top:
|
||||
|
|
@ -38,7 +38,7 @@ void sysinit(){
|
|||
mlog("KERNEL", "Filename: %s\n", MLOG_PRINT, dir_data[i]->name);
|
||||
vfs_detect_partitions(dir_data[i]);
|
||||
}
|
||||
dispatch_message(0);
|
||||
// dispatch_message(0);
|
||||
printf("Bleh\n");
|
||||
//why did i stop working on this? what was wrong with this?
|
||||
for(;;);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "kstdlib.h"
|
||||
#include <stdarg.h>
|
||||
#include "memory.h"
|
||||
#include "string.h"
|
||||
|
||||
char* log_info_types[] = {
|
||||
"\b",
|
||||
|
|
@ -100,3 +101,26 @@ void vector_pop(uint32_t pos, vector_t *vector, void *element){
|
|||
}
|
||||
vector->size--;
|
||||
}
|
||||
|
||||
uint32_t atoi(char *str, uint32_t base){
|
||||
// char reverse[strlen(str)];
|
||||
// // printf("strlen: %d, %s", strlen(str), str);
|
||||
// uint32_t j = 0;
|
||||
// for(uint32_t i = strlen(str) - 1; i >= 0; i--){
|
||||
// j
|
||||
// }
|
||||
uint32_t i = 0;
|
||||
uint32_t total = 0;
|
||||
while(str[i]){
|
||||
char c = str[i];
|
||||
total *= base;
|
||||
if(c >= 48 && c <= (57 - ((10 - base) * (base < 10)))){
|
||||
total += (c-48);
|
||||
}
|
||||
if(base > 10 && c >= 97 && c <= 102 - (16 - base)){
|
||||
total += (c - 97 + 10);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
|
@ -26,6 +26,9 @@ void *vector_get(uint32_t pos, vector_t *vector);
|
|||
void vector_set(uint32_t pos, vector_t *vector, void *new_element);
|
||||
void vector_push(vector_t *vector, void *new_element);
|
||||
void vector_pop(uint32_t pos, vector_t *vector, void *element);
|
||||
uint32_t atoi(char *str, uint32_t base);
|
||||
|
||||
|
||||
|
||||
typedef struct kernel_info{
|
||||
void *mmap_ptr;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,12 @@
|
|||
//link: create symlink from one file to another (useful for actually selecting where to mount things)
|
||||
//exec: execute program in userspace
|
||||
|
||||
int is_num(char c){
|
||||
if(c < 48 || (c > 57 && c < 97)) return 0;
|
||||
if(c > 102) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void initrc_read(vfile_t *file){
|
||||
mlog("KERNEL", "Reading initrc:\n", MLOG_PRINT);
|
||||
|
|
@ -17,6 +23,9 @@ void initrc_read(vfile_t *file){
|
|||
uint32_t i = 0;
|
||||
while(strcmp(statement, "END")){
|
||||
uint32_t s_i = 0;
|
||||
while(ptr[i] == ' ' || ptr[i] == '\t' || ptr[i] == '\n'){
|
||||
i++;
|
||||
}
|
||||
while(ptr[i] != ' ' && ptr[i] != '\n' && ptr[i]){
|
||||
statement[s_i++] = ptr[i];
|
||||
i++;
|
||||
|
|
@ -27,7 +36,7 @@ void initrc_read(vfile_t *file){
|
|||
i++;
|
||||
}
|
||||
}
|
||||
if(!strcmp(statement, "ECHO")){
|
||||
else if(!strcmp(statement, "ECHO")){
|
||||
//this is purely for testing purposes.
|
||||
printf("[ INITRC ]");
|
||||
i++;
|
||||
|
|
@ -39,11 +48,11 @@ void initrc_read(vfile_t *file){
|
|||
}
|
||||
printf("\n");
|
||||
}
|
||||
if(!strcmp(statement, "MODULE")){
|
||||
else if(!strcmp(statement, "MODULE")){
|
||||
i++;
|
||||
char module_name[512];
|
||||
int j = 0;
|
||||
for(; j < 512 && ptr[i + j] && ptr[i+j] != '\n'; j++){
|
||||
for(; j < 512 && ptr[i + j] && ptr[i+j] != '\n' && ptr[i + j] != ' '; j++){
|
||||
module_name[j] = ptr[i + j];
|
||||
}
|
||||
i+=j;
|
||||
|
|
@ -56,10 +65,73 @@ void initrc_read(vfile_t *file){
|
|||
}
|
||||
module_start(module->access.data.ptr);
|
||||
}
|
||||
// printf("%d\n", i);
|
||||
if(i >= size){
|
||||
else if(!strcmp(statement, "MOUNT")){
|
||||
char mount_src_name[512] = {0};
|
||||
char mount_dest[512] = {0};
|
||||
uint32_t offset = 0;
|
||||
i++;
|
||||
int j = 0;
|
||||
for(; j < 512 && ptr[i + j] && ptr[i+j] != '\n' && ptr[i+j] != ' '; j++){
|
||||
mount_src_name[j] = ptr[i + j];
|
||||
}
|
||||
i+=j;
|
||||
mount_src_name[j] = 0;
|
||||
for(j = 1; ptr[i + j] && ptr[i + j] != '\n' && ptr[i + j] != ' '; j++){
|
||||
mount_dest[j-1] = ptr[i + j];
|
||||
}
|
||||
|
||||
mount_dest[j-1] = 0;
|
||||
i += j;
|
||||
if(ptr[i] == ' '){
|
||||
i++;
|
||||
j = 0;
|
||||
char atoi_str[512] = {0};
|
||||
|
||||
uint32_t base = 10;
|
||||
if(ptr[i + j + 1] == 'x'){
|
||||
// printf("base 16\n");
|
||||
i+=2;
|
||||
base = 16;
|
||||
}
|
||||
else if(ptr[i+j] == '0' && ptr[i+j+1] == '0'){
|
||||
// printf("Base 8!\n");
|
||||
i += 2;
|
||||
base = 8;
|
||||
}
|
||||
|
||||
for(; j < 512 && ptr[i + j] && ptr[i+j] != '\n' && ptr[i + j] != ' ' && is_num(ptr[i+j]); j++){
|
||||
atoi_str[j] = ptr[i + j];
|
||||
}
|
||||
i += j;
|
||||
atoi_str[j] = 0;
|
||||
|
||||
offset = atoi(atoi_str, base);
|
||||
|
||||
// printf("String: %s, Result: %d\n", atoi_str, offset);
|
||||
|
||||
}
|
||||
|
||||
// if(ptr[i] )
|
||||
|
||||
// printf("TEST: %s, %s, %d\n", mount_src_name, mount_dest, ptr[i]);
|
||||
|
||||
vfile_t *to_mount = fget_file(mount_src_name);
|
||||
dispatch_message(MESSAGE_MOUNT_FS, to_mount, mount_dest, offset);
|
||||
}
|
||||
else if(!strcmp(statement, "END")){
|
||||
return;
|
||||
}
|
||||
else{
|
||||
printf("FATAL ERROR: Unknown Instruction: %s\n", statement);
|
||||
asm("int $6");
|
||||
}
|
||||
// printf("%d\n", i);
|
||||
while(ptr[i] != '\n'){
|
||||
i++;
|
||||
if(i >= size){
|
||||
return;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
|
@ -278,7 +278,7 @@ vfile_t *fget_file(char *name){
|
|||
char *tmp = dir;
|
||||
uint32_t filename_offset = 0;
|
||||
vfile_t *current_dir = &root_dir;
|
||||
vfile_t *tmpfile;
|
||||
vfile_t *tmpfile = 0;
|
||||
while(tmp != 0){
|
||||
dir = tmp;
|
||||
tmpfile = search_dir(tmp, *current_dir);
|
||||
|
|
|
|||
Loading…
Reference in New Issue