syscalls: ioctl

This commit is contained in:
Matheus
2023-07-05 20:19:36 -03:00
parent 50597114d1
commit f76046a56b
8 changed files with 51 additions and 8 deletions
+23
View File
@@ -0,0 +1,23 @@
#include <kernel/syscalls.h>
#include <kernel/file.h>
#include <kernel/vfs.h>
syscallret_t syscall_ioctl(context_t *, int fd, unsigned long request, void *arg) {
syscallret_t ret = {
.ret = -1
};
file_t *file = fd_get(fd);
if (file == NULL) {
ret.errno = EBADF;
return ret;
}
int r = 0;
ret.errno = VOP_IOCTL(file->vnode, request, arg, &r);
ret.ret = ret.errno ? -1 : r;
fd_release(file);
return ret;
}
-1
View File
@@ -46,7 +46,6 @@ syscallret_t syscall_pipe2(context_t *, int flags) {
ret.errno = 0;
ret.ret = (uint64_t)readfd | ((uint64_t)writefd << 32);
printf("pipe2: readfd %d writefd %d wrefcount %d\n", readfd, writefd, writefile->refcount);
return ret;
-1
View File
@@ -58,7 +58,6 @@ 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 = newoffset;
ret.errno = 0;