diff --git a/bin/init/main.c b/bin/init/main.c index 1d47d80..53ecccc 100644 --- a/bin/init/main.c +++ b/bin/init/main.c @@ -97,7 +97,7 @@ exit(0x0); } - while (pidStatus(i) > 0x0) { + while (pidStatus(i) != i) { /* fetchAgain: if (mpi_fetchMessage("init",&myMsg) == 0x0) { diff --git a/bin/login/main.c b/bin/login/main.c index 4c882f5..503f96a 100644 --- a/bin/login/main.c +++ b/bin/login/main.c @@ -146,7 +146,7 @@ exit(-1); } else { - while (pidStatus(shellPid) > 0) { + while (pidStatus(shellPid) == shellPid) { sched_yield(); } goto login; diff --git a/sys/fs/ufs/ufs.c b/sys/fs/ufs/ufs.c index 6521ea1..4f5fea9 100644 --- a/sys/fs/ufs/ufs.c +++ b/sys/fs/ufs/ufs.c @@ -225,7 +225,7 @@ } s += d->d_reclen; } - + *ino = 0x0; return 0; } diff --git a/sys/fs/vfs/file.c b/sys/fs/vfs/file.c index 6c0042a..e24b27a 100644 --- a/sys/fs/vfs/file.c +++ b/sys/fs/vfs/file.c @@ -383,6 +383,7 @@ } /* Search For The File */ if ( tmpFd->mp->fs->vfsOpenFile( tmpFd->fileName, tmpFd ) == 0x1 ) { + kprintf("fopen1"); /* If The File Is Found Then Set Up The Descriptor */ /* in order to save resources we will allocate the buffer later when it is needed */ @@ -422,6 +423,7 @@ return (tmpFd); } else { + kprintf("fopen2"); kfree( tmpFd->buffer ); kfree( tmpFd ); spinUnlock( &fdTable_lock ); diff --git a/sys/i386/i386_exec.c b/sys/i386/i386_exec.c index 2a78116..557a3a6 100644 --- a/sys/i386/i386_exec.c +++ b/sys/i386/i386_exec.c @@ -469,6 +469,8 @@ : : "d" ((uint32_t *)(kernelPageDirectory)) ); + sprintf(newProcess->oInfo.cwd, "/"); + kprintf("execFile Return: 0x%X - %i\n", newProcess->tss.eip, newProcess->id); /* Put new thread into the READY state */ @@ -518,6 +520,7 @@ asm("movl %%cr3, %0;" : "=r" (cr3)); fd = fopen(file, "r"); + kprintf("fd: 0x%X", fd); if (fd == 0x0) return (-1); diff --git a/sys/kernel/execve.c b/sys/kernel/execve.c index 1b05c00..c5bbe5a 100644 --- a/sys/kernel/execve.c +++ b/sys/kernel/execve.c @@ -33,5 +33,7 @@ int sys_execve( struct thread *td, struct sys_execve_args *args ) { int ret = sys_exec( td, args->fname, args->argv, args->envp ); td->td_retval[0] = ret; + if (ret != 0) + td->td_retval[1] = -8; return (ret); } diff --git a/sys/kernel/gen_calls.c b/sys/kernel/gen_calls.c index b812633..76b4f8b 100644 --- a/sys/kernel/gen_calls.c +++ b/sys/kernel/gen_calls.c @@ -142,11 +142,23 @@ } int sys_wait4( struct thread *td, struct sys_wait4_args *args ) { + int error = 0; + kprintf("wait4: %i", args->pid); //kprintf("DUMMY FUNC FIX ME! sys_wait4"); kTask_t *tmpTask = schedFindTask( args->pid ); - if ( tmpTask != 0x0 ) - return (tmpTask->state); - return (0); + + if ( tmpTask != 0x0 ) { + while (tmpTask != 0x0) { + sched_yield(); + tmpTask = schedFindTask( args->pid ); + } + td->td_retval[0] = args->pid; + } + else { + td->td_retval[0] = -1; + error = -1; + } + return (error); } int sys_sysarch( struct thread *td, struct sys_sysarch_args *args ) { diff --git a/sys/kernel/syscall.c b/sys/kernel/syscall.c index c9d8629..eeeb9b7 100644 --- a/sys/kernel/syscall.c +++ b/sys/kernel/syscall.c @@ -124,7 +124,8 @@ ************************************************************************/ int sysGetFreePage(struct thread *td, uint32_t *count) { //MrOlsen 2017-12-15 kprintf("sysGetFreePage - Count: %i\n", *count); - return ((int) vmm_getFreeVirtualPage(_current->id, *count, VM_THRD)); + td->td_retval[0] = vmm_getFreeVirtualPage(_current->id, *count, VM_THRD); + return(0); //return(vmm_getFreeVirtualPage(_current->id, *count, VM_TASK)); } diff --git a/sys/kernel/syscall_posix.c b/sys/kernel/syscall_posix.c index 723f5b2..c16adc6 100644 --- a/sys/kernel/syscall_posix.c +++ b/sys/kernel/syscall_posix.c @@ -103,26 +103,13 @@ if (systemCalls[code].sc_status == SYSCALL_DUMMY) kprintf("RET3"); break; - /* - case ERESTART: - frame->tf_eip -= frame->tf_err; - break; - */ - case EJUSTRETURN: - break; default: - frame->tf_eax = error; + frame->tf_eax = td->td_retval[0]; + frame->tf_edx = td->td_retval[1]; frame->tf_eflags |= PSL_C; break; - - if (systemCalls[code].sc_status == SYSCALL_DUMMY) - kprintf("RET2"); } } - /* - if (_current->id == 6) - kprintf("SYSCALL-EXIT"); - */ } int invalidCall() { diff --git a/sys/kernel/vfs_calls.c b/sys/kernel/vfs_calls.c index 9f4daf8..30be331 100644 --- a/sys/kernel/vfs_calls.c +++ b/sys/kernel/vfs_calls.c @@ -80,6 +80,7 @@ int sys_read(struct thread *td, struct sys_read_args *args) { int x = 0; char c = 0x0; + char bf[2]; volatile char *buf = args->buf; struct file *fd = 0x0; @@ -90,14 +91,18 @@ td->td_retval[0] = fread(args->buf, args->nbyte, 1, fd->fd); } else { + bf[1] = '\0'; if ( _current->term == tty_foreground ) c = getchar(); for (x = 0; x < args->nbyte && c != '\n';) { if ( _current->term == tty_foreground ) { - if ( c != 0x0 ) + if ( c != 0x0 ) { buf[x++] = c; + bf[0] = c; + kprint(bf); + } if ( c == '\n') { buf[x++] = c;