still trying to read a file

This commit is contained in:
2025-08-16 21:43:42 +03:00
parent ce6e9642ee
commit 0628470a7c
7 changed files with 44 additions and 36 deletions
+9 -8
View File
@@ -5,6 +5,7 @@
#include "../include/paging.h"
#include "../include/string.h"
#include "../include/screen.h"
#include "../include/fat.h"
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
@@ -156,7 +157,7 @@ int sys_read(TrapFrame *tf)
{
return -EBADF;
}
return fat_fread(current->file_descriptors[tf->ebx], (void*)tf->ecx, tf->edx);
return 0;//fat_fread(current->file_descriptors[tf->ebx], (void*)tf->ecx, tf->edx);
}
}
@@ -187,7 +188,7 @@ int sys_write(TrapFrame *tf)
{
return -EBADF;
}
return fat_fwrite(current->file_descriptors[tf->ebx], (void*)tf->ecx, tf->edx);
return 0;//fat_fwrite(current->file_descriptors[tf->ebx], (void*)tf->ecx, tf->edx);
}
}
@@ -209,7 +210,7 @@ int sys_open(TrapFrame *tf)
{
current->file_descriptors[i] = malloc(sizeof(file_t)); // Kernel malloc
//debug_log("\n====FILE_DESCRIPTOR: %X\n", i);
int result = fat_fopen(current->file_descriptors[i], filename, mode_str);
int result = 0;//fat_fopen(current->file_descriptors[i], filename, mode_str);
if (result < 0) {
free(current->file_descriptors[i]); // Free on failure
current->file_descriptors[i] = NULL;
@@ -230,7 +231,7 @@ int sys_close(TrapFrame *tf)
if(current->file_descriptors[fd] != NULL)
{
//debug_log("SYS_CLOSE: current->file_descriptors[fd] != NULL");
int result = fat_fclose(current->file_descriptors[fd]);
int result = 0;//fat_fclose(current->file_descriptors[fd]);
//debug_log("SYS_CLOSE: fat_fclose result: 0x%X", result);
free(current->file_descriptors[fd]);
current->file_descriptors[fd] = NULL;
@@ -241,10 +242,10 @@ int sys_close(TrapFrame *tf)
int sys_chdir(TrapFrame *tf)
{
strcat(current->cwd->fat->path, "/");
strcat(current->cwd->fat->path, (char*)tf->ebx);
//strcat(current->cwd->fat->path, "/");
//strcat(current->cwd->fat->path, (char*)tf->ebx);
int result = fat_opendir(current->cwd, (const char*)tf->ebx);
int result = 0;//fat_opendir(current->cwd, (const char*)tf->ebx);
if(result == 0)
return 0;
@@ -253,7 +254,7 @@ int sys_chdir(TrapFrame *tf)
int sys_getcwd(TrapFrame *tf)
{
strcpy((char*)tf->ebx, current->cwd->fat->path);
//strcpy((char*)tf->ebx, current->cwd->fat->path);
return tf->ebx;
}