mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-29 21:58:20 +00:00
kernel: poll system and poll syscall
This commit is contained in:
@@ -145,7 +145,7 @@ int devfs_setattr(vnode_t *node, vattr_t *attr, cred_t *cred) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int devfs_poll(vnode_t *node, int events) {
|
||||
int devfs_poll(vnode_t *node, polldata_t *data, int events) {
|
||||
devnode_t *devnode = (devnode_t *)node;
|
||||
if (devnode->master)
|
||||
devnode = devnode->master;
|
||||
@@ -153,7 +153,7 @@ int devfs_poll(vnode_t *node, int events) {
|
||||
if (devnode->devops->poll == NULL)
|
||||
return ENODEV;
|
||||
|
||||
return devnode->devops->poll(devnode->attr.rdevminor, events);
|
||||
return devnode->devops->poll(devnode->attr.rdevminor, data, events);
|
||||
}
|
||||
|
||||
int devfs_mmap(vnode_t *node, void *addr, uintmax_t offset, int flags, cred_t *cred) {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <logging.h>
|
||||
#include <errno.h>
|
||||
#include <kernel/abi.h>
|
||||
#include <kernel/poll.h>
|
||||
|
||||
#define BUFFER_SIZE 16 * PAGE_SIZE
|
||||
|
||||
@@ -147,7 +148,7 @@ int pipefs_write(vnode_t *node, void *buffer, size_t size, uintmax_t offset, int
|
||||
return error;
|
||||
}
|
||||
|
||||
int pipefs_poll(vnode_t *node, int events) {
|
||||
int pipefs_poll(vnode_t *node, polldata_t *data, int events) {
|
||||
pipenode_t *pipenode = (pipenode_t *)node;
|
||||
int revents = 0;
|
||||
VOP_LOCK(node);
|
||||
|
||||
+1
-12
@@ -29,17 +29,6 @@ static int tmpfs_mount(vfs_t **vfs, vnode_t *mountpoint, vnode_t *backing, void
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tmpfs_poll(vnode_t *node, int event) {
|
||||
int ret = 0;
|
||||
|
||||
if (event & POLLIN)
|
||||
ret |= POLLIN;
|
||||
if (event & POLLOUT)
|
||||
ret |= POLLOUT;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define DATAMMUFLAGS (ARCH_MMU_FLAGS_WRITE | ARCH_MMU_FLAGS_READ | ARCH_MMU_FLAGS_NOEXEC)
|
||||
|
||||
// expects to be called with node locked
|
||||
@@ -491,7 +480,7 @@ static vops_t vnops = {
|
||||
.getattr = tmpfs_getattr,
|
||||
.setattr = tmpfs_setattr,
|
||||
.lookup = tmpfs_lookup,
|
||||
.poll = tmpfs_poll,
|
||||
.poll = vfs_pollstub,
|
||||
.read = tmpfs_read,
|
||||
.write = tmpfs_write,
|
||||
.access = tmpfs_access,
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <kernel/alloc.h>
|
||||
#include <errno.h>
|
||||
#include <arch/cpu.h>
|
||||
#include <kernel/poll.h>
|
||||
|
||||
#define PATHNAME_MAX 512
|
||||
#define MAXLINKDEPTH 64
|
||||
@@ -27,6 +28,18 @@ static cred_t *getcred() {
|
||||
return &_cpu()->thread->proc->cred;
|
||||
}
|
||||
|
||||
int vfs_pollstub(vnode_t *node, struct polldata *, int events) {
|
||||
int revents = 0;
|
||||
|
||||
if (events & POLLIN)
|
||||
revents |= POLLIN;
|
||||
|
||||
if (events & POLLOUT)
|
||||
revents |= POLLOUT;
|
||||
|
||||
return revents;
|
||||
}
|
||||
|
||||
void vfs_init() {
|
||||
__assert(hashtable_init(&fstable, 20) == 0);
|
||||
vfsroot = alloc(sizeof(vnode_t));
|
||||
|
||||
Reference in New Issue
Block a user