mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 06:58:22 +00:00
fix stupid bugs
strcmp was funky, added a few guard checks to hashtable, added error printing to initrd and fixed swapgs (again) in isr.asm
This commit is contained in:
@@ -23,9 +23,8 @@ section .text
|
|||||||
|
|
||||||
|
|
||||||
mov rax, ds
|
mov rax, ds
|
||||||
|
cmp rax,0x40
|
||||||
cmp rax,0x43
|
jne .noswapgs
|
||||||
je .noswapgs
|
|
||||||
swapgs
|
swapgs
|
||||||
.noswapgs:
|
.noswapgs:
|
||||||
|
|
||||||
|
|||||||
+8
-2
@@ -152,10 +152,16 @@ void initrd_parse(){
|
|||||||
|
|
||||||
switch(entry.type){
|
switch(entry.type){
|
||||||
case TAR_FILE:
|
case TAR_FILE:
|
||||||
vfs_create(vfs_root(), entry.name, entry.mode);
|
int err = vfs_create(vfs_root(), entry.name, entry.mode);
|
||||||
|
if(err){
|
||||||
|
|
||||||
|
printf("Failed creating %s: ERROR %lu\n", entry.name, err);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case TAR_DIR:
|
case TAR_DIR:
|
||||||
vfs_mkdir(vfs_root(), entry.name, entry.mode);
|
err = vfs_mkdir(vfs_root(), entry.name, entry.mode);
|
||||||
|
if(err)
|
||||||
|
printf("Failed creating %s: ERROR %lu\n", entry.name, err);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
_panic("Unsupported file type in initrd!", 0);
|
_panic("Unsupported file type in initrd!", 0);
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ bool hashtable_init(hashtable* table, size_t size){
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline hashtableentry* getentry(hashtable* table, char* key){
|
static inline hashtableentry* getentry(hashtable* table, char* key){
|
||||||
|
if(!table->size)
|
||||||
|
return NULL;
|
||||||
size_t entryn = hash(key, strlen(key)) % table->size;
|
size_t entryn = hash(key, strlen(key)) % table->size;
|
||||||
|
|
||||||
return &table->entries[entryn];
|
return &table->entries[entryn];
|
||||||
@@ -30,6 +32,9 @@ bool hashtable_insert(hashtable* table, char* key, void* val){
|
|||||||
|
|
||||||
hashtableentry* entry = getentry(table, key);
|
hashtableentry* entry = getentry(table, key);
|
||||||
|
|
||||||
|
if(!entry)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
char* keysave = alloc(strlen(key)+1);
|
char* keysave = alloc(strlen(key)+1);
|
||||||
|
|
||||||
memcpy(keysave, key, strlen(key)+1);
|
memcpy(keysave, key, strlen(key)+1);
|
||||||
@@ -62,6 +67,8 @@ bool hashtable_remove(hashtable* table, char* key){
|
|||||||
|
|
||||||
hashtableentry* entry = getentry(table, key);
|
hashtableentry* entry = getentry(table, key);
|
||||||
|
|
||||||
|
if(!entry) return false;
|
||||||
|
|
||||||
if(!entry->key) return false;
|
if(!entry->key) return false;
|
||||||
|
|
||||||
hashtableentry* prev = NULL;
|
hashtableentry* prev = NULL;
|
||||||
@@ -100,6 +107,9 @@ bool hashtable_remove(hashtable* table, char* key){
|
|||||||
bool hashtable_set(hashtable* table, char* key, void* value){
|
bool hashtable_set(hashtable* table, char* key, void* value){
|
||||||
hashtableentry* entry = getentry(table, key);
|
hashtableentry* entry = getentry(table, key);
|
||||||
|
|
||||||
|
if(!entry)
|
||||||
|
return false;
|
||||||
|
|
||||||
if(!entry->key)
|
if(!entry->key)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -117,6 +127,9 @@ void* hashtable_get(hashtable* table, char* key){
|
|||||||
|
|
||||||
hashtableentry* entry = getentry(table, key);
|
hashtableentry* entry = getentry(table, key);
|
||||||
|
|
||||||
|
if(!entry)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
if(!entry->key)
|
if(!entry->key)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
int strcmp(const char* a, const char* b){
|
int strcmp(const char* a, const char* b){
|
||||||
|
|
||||||
while(*a && (*a++ == *b++));
|
while(*a && (*a == *b)){
|
||||||
|
++a;
|
||||||
|
++b;
|
||||||
|
}
|
||||||
|
|
||||||
return *(const unsigned char*)a - *(const unsigned char*)b;
|
return *(const unsigned char*)a - *(const unsigned char*)b;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user