syscalls: make use of stderr and fix chdir syscall return value
This commit is contained in:
@@ -34,6 +34,7 @@ uint16_t vga_entry(unsigned char uc, uint8_t color);
|
|||||||
size_t strlen(const char* str);
|
size_t strlen(const char* str);
|
||||||
void terminal_initialize(void);
|
void terminal_initialize(void);
|
||||||
void terminal_setcolor(uint8_t color);
|
void terminal_setcolor(uint8_t color);
|
||||||
|
uint8_t terminal_getcolor();
|
||||||
void terminal_putentryat(char c, uint8_t color, size_t x, size_t y);
|
void terminal_putentryat(char c, uint8_t color, size_t x, size_t y);
|
||||||
void terminal_putchar(char c);
|
void terminal_putchar(char c);
|
||||||
void terminal_write(const char* data, size_t size);
|
void terminal_write(const char* data, size_t size);
|
||||||
|
|||||||
@@ -36,6 +36,11 @@ void terminal_setcolor(uint8_t color)
|
|||||||
terminal_color = color;
|
terminal_color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t terminal_getcolor()
|
||||||
|
{
|
||||||
|
return terminal_color;
|
||||||
|
}
|
||||||
|
|
||||||
void terminal_putentryat(char c, uint8_t color, size_t x, size_t y)
|
void terminal_putentryat(char c, uint8_t color, size_t x, size_t y)
|
||||||
{
|
{
|
||||||
const size_t index = y * VGA_WIDTH + x;
|
const size_t index = y * VGA_WIDTH + x;
|
||||||
|
|||||||
+15
-1
@@ -4,6 +4,7 @@
|
|||||||
#include "../include/liballoc.h"
|
#include "../include/liballoc.h"
|
||||||
#include "../include/paging.h"
|
#include "../include/paging.h"
|
||||||
#include "../include/string.h"
|
#include "../include/string.h"
|
||||||
|
#include "../include/screen.h"
|
||||||
|
|
||||||
#define STDIN_FILENO 0
|
#define STDIN_FILENO 0
|
||||||
#define STDOUT_FILENO 1
|
#define STDOUT_FILENO 1
|
||||||
@@ -171,6 +172,14 @@ int sys_write(TrapFrame *tf)
|
|||||||
//debug_log("\n=================END OF THAT SHIT=====================\n");
|
//debug_log("\n=================END OF THAT SHIT=====================\n");
|
||||||
return tf->edx;
|
return tf->edx;
|
||||||
}
|
}
|
||||||
|
if(tf->ebx == STDERR_FILENO)
|
||||||
|
{
|
||||||
|
uint8_t prev_color = terminal_getcolor();
|
||||||
|
terminal_setcolor(VGA_COLOR_RED);
|
||||||
|
print((char*)tf->ecx, tf->edx);
|
||||||
|
terminal_setcolor(prev_color);
|
||||||
|
return tf->edx;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -234,7 +243,12 @@ int sys_chdir(TrapFrame *tf)
|
|||||||
{
|
{
|
||||||
strcat(current->cwd->fat->path, "/");
|
strcat(current->cwd->fat->path, "/");
|
||||||
strcat(current->cwd->fat->path, (char*)tf->ebx);
|
strcat(current->cwd->fat->path, (char*)tf->ebx);
|
||||||
return fat_opendir(current->cwd, (const char*)tf->ebx);
|
|
||||||
|
int result = fat_opendir(current->cwd, (const char*)tf->ebx);
|
||||||
|
if(result == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sys_getcwd(TrapFrame *tf)
|
int sys_getcwd(TrapFrame *tf)
|
||||||
|
|||||||
Reference in New Issue
Block a user