aboutsummaryrefslogtreecommitdiff
path: root/kernel/features/fs.c
diff options
context:
space:
mode:
authorMarvin Borner2021-02-07 16:58:48 +0100
committerMarvin Borner2021-02-07 16:58:48 +0100
commit59894afa1bc0f4efc85917710adf2e93d7e17a5e (patch)
treeeafaa21081430de4a0d09d8ac963ddc4e2f21a00 /kernel/features/fs.c
parenteca4dfd49216f6158df69143994a18a0b3edd4fe (diff)
Added poll syscall
Diffstat (limited to 'kernel/features/fs.c')
-rw-r--r--kernel/features/fs.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/kernel/features/fs.c b/kernel/features/fs.c
index ecb2b85..16a12f7 100644
--- a/kernel/features/fs.c
+++ b/kernel/features/fs.c
@@ -181,6 +181,21 @@ s32 vfs_stat(const char *path, struct stat *buf)
return m->dev->vfs->stat(path, buf, m->dev);
}
+s32 vfs_poll(const char **files)
+{
+ if (!files)
+ return -1;
+
+ for (const char **p = files; *p && **p; p++)
+ if (vfs_ready(*p))
+ return p - files;
+
+ for (const char **p = files; *p && **p; p++)
+ proc_wait_for(vfs_find_dev(*p)->id, PROC_WAIT_DEV, vfs_poll);
+
+ return PROC_MAX_WAIT_IDS + 1;
+}
+
u8 vfs_ready(const char *path)
{
while (*path == ' ')
@@ -268,6 +283,7 @@ void device_install(void)
struct vfs *vfs = malloc(sizeof(*vfs));
vfs->type = VFS_DEVFS;
vfs->read = devfs_read;
+ vfs->perm = devfs_perm;
vfs->ready = devfs_ready;
struct device *dev = malloc(sizeof(*dev));
dev->name = "dev";