mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 15:08:21 +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;
|
goto error;
|
||||||
|
|
||||||
if (interp) {
|
if (interp) {
|
||||||
vnode_t *interpnode;
|
vnode_t *interpnode = NULL;
|
||||||
ret.errno = vfs_lookup(&interpnode, refnode, interp, NULL, 0);
|
vnode_t *interprefnode = *interp == '/' ? sched_getroot() : sched_getcwd();
|
||||||
|
ret.errno = vfs_lookup(&interpnode, interprefnode, interp, NULL, 0);
|
||||||
if (ret.errno)
|
if (ret.errno)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
|||||||
@@ -37,9 +37,6 @@ __attribute__((noreturn)) void syscall_exit(context_t *context, int status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lastchild) {
|
if (lastchild) {
|
||||||
if (lastchild->sibling->state == SCHED_PROC_STATE_ZOMBIE)
|
|
||||||
haszombie = true;
|
|
||||||
|
|
||||||
lastchild->sibling = sched_initproc->child;
|
lastchild->sibling = sched_initproc->child;
|
||||||
sched_initproc->child = proc->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) {
|
syscallret_t syscall_pipe2(context_t *, int flags) {
|
||||||
// TODO support them
|
__assert((flags & ~(O_CLOEXEC | O_NONBLOCK)) == 0);
|
||||||
__assert(flags == 0);
|
|
||||||
syscallret_t ret = {
|
syscallret_t ret = {
|
||||||
.ret = -1
|
.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
|
// node held again because two files will point to the same node
|
||||||
VOP_HOLD(node);
|
VOP_HOLD(node);
|
||||||
|
|
||||||
ret.errno = fd_new(0, &readfile, &readfd);
|
ret.errno = fd_new(flags & O_CLOEXEC, &readfile, &readfd);
|
||||||
if (ret.errno)
|
if (ret.errno)
|
||||||
goto error;
|
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)
|
if (ret.errno)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
open(writefile, node, FILE_WRITE);
|
open(writefile, node, FILE_WRITE | (flags & O_NONBLOCK));
|
||||||
|
|
||||||
ret.errno = 0;
|
ret.errno = 0;
|
||||||
ret.ret = (uint64_t)readfd | ((uint64_t)writefd << 32);
|
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:
|
case SEEK_SET:
|
||||||
newoffset = offset;
|
newoffset = offset;
|
||||||
break;
|
break;
|
||||||
case SEEK_CUR: {
|
case SEEK_CUR:
|
||||||
uintmax_t newoffset = curroffset + offset;
|
newoffset = curroffset + offset;
|
||||||
if (offset > 0 && newoffset < curroffset) {
|
if (offset > 0 && newoffset < curroffset) {
|
||||||
ret.errno = EOVERFLOW;
|
ret.errno = EOVERFLOW;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@@ -47,9 +47,7 @@ syscallret_t syscall_seek(context_t *context, int fd, off_t offset, int whence)
|
|||||||
ret.errno = EINVAL;
|
ret.errno = EINVAL;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
newoffset = newoffset;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case SEEK_END: {
|
case SEEK_END: {
|
||||||
vattr_t attr;
|
vattr_t attr;
|
||||||
ret.errno = VOP_GETATTR(file->vnode, &attr, &_cpu()->thread->proc->cred);
|
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;
|
file->offset = newoffset;
|
||||||
ret.ret = file->offset;
|
ret.ret = newoffset;
|
||||||
ret.errno = 0;
|
ret.errno = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ syscallret_t syscall_fstatat(context_t *ctx, int dirfd, char *upath, stat_t *ust
|
|||||||
}
|
}
|
||||||
|
|
||||||
vnode_t *node = NULL;
|
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)
|
if (ret.errno)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@@ -109,5 +109,8 @@ syscallret_t syscall_fstatat(context_t *ctx, int dirfd, char *upath, stat_t *ust
|
|||||||
fd_release(file);
|
fd_release(file);
|
||||||
else
|
else
|
||||||
VOP_RELEASE(dirnode);
|
VOP_RELEASE(dirnode);
|
||||||
|
|
||||||
|
free(path);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user