mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 20:58:22 +00:00
syscalls: misc fixes
This commit is contained in:
@@ -91,8 +91,9 @@ syscallret_t syscall_execve(context_t *context, char *upath, char *uargv[], char
|
||||
goto error;
|
||||
|
||||
if (interp) {
|
||||
vnode_t *interpnode;
|
||||
ret.errno = vfs_lookup(&interpnode, refnode, interp, NULL, 0);
|
||||
vnode_t *interpnode = NULL;
|
||||
vnode_t *interprefnode = *interp == '/' ? sched_getroot() : sched_getcwd();
|
||||
ret.errno = vfs_lookup(&interpnode, interprefnode, interp, NULL, 0);
|
||||
if (ret.errno)
|
||||
goto error;
|
||||
|
||||
|
||||
@@ -37,9 +37,6 @@ __attribute__((noreturn)) void syscall_exit(context_t *context, int status) {
|
||||
}
|
||||
|
||||
if (lastchild) {
|
||||
if (lastchild->sibling->state == SCHED_PROC_STATE_ZOMBIE)
|
||||
haszombie = true;
|
||||
|
||||
lastchild->sibling = sched_initproc->child;
|
||||
sched_initproc->child = proc->child;
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@ static void open(file_t *file, vnode_t *node, int flags) {
|
||||
}
|
||||
|
||||
syscallret_t syscall_pipe2(context_t *, int flags) {
|
||||
// TODO support them
|
||||
__assert(flags == 0);
|
||||
__assert((flags & ~(O_CLOEXEC | O_NONBLOCK)) == 0);
|
||||
syscallret_t ret = {
|
||||
.ret = -1
|
||||
};
|
||||
@@ -33,17 +32,17 @@ syscallret_t syscall_pipe2(context_t *, int flags) {
|
||||
// node held again because two files will point to the same node
|
||||
VOP_HOLD(node);
|
||||
|
||||
ret.errno = fd_new(0, &readfile, &readfd);
|
||||
ret.errno = fd_new(flags & O_CLOEXEC, &readfile, &readfd);
|
||||
if (ret.errno)
|
||||
goto error;
|
||||
|
||||
open(readfile, node, FILE_READ);
|
||||
open(readfile, node, FILE_READ | (flags & O_NONBLOCK));
|
||||
|
||||
ret.errno = fd_new(0, &writefile, &writefd);
|
||||
ret.errno = fd_new(flags & O_CLOEXEC, &writefile, &writefd);
|
||||
if (ret.errno)
|
||||
goto error;
|
||||
|
||||
open(writefile, node, FILE_WRITE);
|
||||
open(writefile, node, FILE_WRITE | (flags & O_NONBLOCK));
|
||||
|
||||
ret.errno = 0;
|
||||
ret.ret = (uint64_t)readfd | ((uint64_t)writefd << 32);
|
||||
|
||||
@@ -37,8 +37,8 @@ syscallret_t syscall_seek(context_t *context, int fd, off_t offset, int whence)
|
||||
case SEEK_SET:
|
||||
newoffset = offset;
|
||||
break;
|
||||
case SEEK_CUR: {
|
||||
uintmax_t newoffset = curroffset + offset;
|
||||
case SEEK_CUR:
|
||||
newoffset = curroffset + offset;
|
||||
if (offset > 0 && newoffset < curroffset) {
|
||||
ret.errno = EOVERFLOW;
|
||||
goto cleanup;
|
||||
@@ -47,9 +47,7 @@ syscallret_t syscall_seek(context_t *context, int fd, off_t offset, int whence)
|
||||
ret.errno = EINVAL;
|
||||
goto cleanup;
|
||||
}
|
||||
newoffset = newoffset;
|
||||
break;
|
||||
}
|
||||
case SEEK_END: {
|
||||
vattr_t attr;
|
||||
ret.errno = VOP_GETATTR(file->vnode, &attr, &_cpu()->thread->proc->cred);
|
||||
@@ -60,8 +58,9 @@ syscallret_t syscall_seek(context_t *context, int fd, off_t offset, int whence)
|
||||
}
|
||||
}
|
||||
|
||||
printf("ret: new %lu old %lu whence %d\n", newoffset, file->offset, whence);
|
||||
file->offset = newoffset;
|
||||
ret.ret = file->offset;
|
||||
ret.ret = newoffset;
|
||||
ret.errno = 0;
|
||||
|
||||
cleanup:
|
||||
|
||||
@@ -88,7 +88,7 @@ syscallret_t syscall_fstatat(context_t *ctx, int dirfd, char *upath, stat_t *ust
|
||||
}
|
||||
|
||||
vnode_t *node = NULL;
|
||||
ret.errno = vfs_lookup(&node, dirnode, upath, NULL, flags & AT_SYMLINK_NOFOLLOW ? VFS_LOOKUP_NOLINK : 0);
|
||||
ret.errno = vfs_lookup(&node, dirnode, path, NULL, flags & AT_SYMLINK_NOFOLLOW ? VFS_LOOKUP_NOLINK : 0);
|
||||
if (ret.errno)
|
||||
goto cleanup;
|
||||
|
||||
@@ -109,5 +109,8 @@ syscallret_t syscall_fstatat(context_t *ctx, int dirfd, char *upath, stat_t *ust
|
||||
fd_release(file);
|
||||
else
|
||||
VOP_RELEASE(dirnode);
|
||||
|
||||
free(path);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user