Separate log and output streams
This commit is contained in:
+1
-2
@@ -713,9 +713,8 @@ static uint64_t directory_stream_read(stream_t *self, uint64_t max, char *to) {
|
||||
return 0;
|
||||
}
|
||||
uint64_t length = string_length(node->name);
|
||||
uint64_t to_read = length + 1 > max ? max : length + 1;
|
||||
uint64_t to_read = length > max ? max : length;
|
||||
memory_copy(node->name, to_read, to);
|
||||
to[to_read - 1] = '\0';
|
||||
return to_read;
|
||||
}
|
||||
|
||||
|
||||
+6
-4
@@ -58,8 +58,10 @@ void kernel_main() {
|
||||
kernel->kernel_stack = kernel->kernel_rsp = (uint8_t *)memory_allocate(PAGE_SIZE) + PAGE_SIZE;
|
||||
kernel->user_stack = kernel->user_rsp = (uint8_t *)memory_allocate(PAGE_SIZE) + PAGE_SIZE;
|
||||
kernel->cwd = memory_allocate(sizeof(path_t));
|
||||
kernel->fds[kernel->free_fd++] = keyboard_init();
|
||||
kernel->fds[kernel->free_fd++] = vga_init();
|
||||
kernel->fds[STDIN] = keyboard_init();
|
||||
kernel->fds[STDOUT] = vga_init();
|
||||
kernel->fds[STDERR] = kernel->fds[STDOUT];
|
||||
kernel->free_fd = STDERR + 1;
|
||||
kernel->code = EXIT_CODE_OK;
|
||||
|
||||
current_process = kernel;
|
||||
@@ -79,10 +81,10 @@ void kernel_main() {
|
||||
fs_read(shell_node, 0, shell_node->size, shell_code);
|
||||
fs_close(shell_node);
|
||||
|
||||
process_t *terminal = process_create(kernel, terminal_code, terminal_node->size, 0, 1);
|
||||
process_t *terminal = process_create(kernel, terminal_code, terminal_node->size, STDIN, STDOUT);
|
||||
memory_free(terminal_code);
|
||||
|
||||
process_t *shell = process_create(kernel, shell_code, shell_node->size, 0, 1);
|
||||
process_t *shell = process_create(kernel, shell_code, shell_node->size, STDIN, STDOUT);
|
||||
memory_free(shell_code);
|
||||
|
||||
uint64_t *terminal_stack = (uint64_t *)terminal->user_stack;
|
||||
|
||||
@@ -75,9 +75,10 @@ process_t *process_create(const process_t *parent, const uint8_t *code, uint64_t
|
||||
proc->pid = free_pid++;
|
||||
proc->state = PROCESS_RUNNING;
|
||||
proc->cwd = path_open_again(parent->cwd);
|
||||
proc->fds[0] = parent->fds[stdin];
|
||||
proc->fds[1] = parent->fds[stdout];
|
||||
proc->free_fd = 2;
|
||||
proc->fds[STDIN] = parent->fds[stdin];
|
||||
proc->fds[STDOUT] = parent->fds[stdout];
|
||||
proc->fds[STDERR] = parent->fds[STDERR];
|
||||
proc->free_fd = STDERR + 1;
|
||||
proc->code = EXIT_CODE_OK;
|
||||
|
||||
return proc;
|
||||
@@ -129,7 +130,7 @@ void process_next() {
|
||||
}
|
||||
|
||||
void process_destroy(process_t *proc) {
|
||||
for (uint64_t i = 2; i < MAX_FDS; i++) {
|
||||
for (uint64_t i = STDERR + 1; i < MAX_FDS; i++) {
|
||||
if (proc->fds[i]) {
|
||||
proc->fds[i]->close(proc->fds[i]);
|
||||
proc->fds[i] = NUL;
|
||||
|
||||
Reference in New Issue
Block a user