From 2ce58c995946f85666e793c4f06efff683e76ae4 Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Wed, 12 Nov 2025 00:37:26 +0100 Subject: fixes --- src/fs/devfs/src/open.c | 27 +++++++++++++++++++++------ src/fs/devfs/src/read.c | 2 +- src/fs/devfs/src/read_nb.c | 2 +- src/fs/devfs/src/write.c | 2 +- 4 files changed, 24 insertions(+), 9 deletions(-) (limited to 'src/fs/devfs') diff --git a/src/fs/devfs/src/open.c b/src/fs/devfs/src/open.c index 229ff49..fb822a6 100644 --- a/src/fs/devfs/src/open.c +++ b/src/fs/devfs/src/open.c @@ -21,7 +21,9 @@ #include #include #include +#include #include +#include struct open { @@ -44,14 +46,27 @@ int devfs_open(const struct fs_open *const o, const struct fs_mp *const mp, if (!op) return -1; - - *op = (const struct open){.pr = r, .r = *r}; - *o->fd = (const struct fs_fd) + else { - .inode = *inode, - .mp = *mp - }; + const struct fs_stdstreams *const ss = &o->ss; + const char *const name = inode->memi->name; + struct fs_fd *const fd = o->fd; + if (!strcmp(name, "stderr")) + *fd = ss->streams[STDERR_FILENO]; + else if (!strcmp(name, "stdin")) + *fd = ss->streams[STDIN_FILENO]; + else if (!strcmp(name, "stdout")) + *fd = ss->streams[STDOUT_FILENO]; + else + *fd = (const struct fs_fd) + { + .inode = *inode, + .mp = *mp + }; + } + + *op = (const struct open){.pr = r, .r = *r}; *r = (const struct fs_ret){.f = done, .args = op}; return 0; } diff --git a/src/fs/devfs/src/read.c b/src/fs/devfs/src/read.c index d7214ff..ec3c841 100644 --- a/src/fs/devfs/src/read.c +++ b/src/fs/devfs/src/read.c @@ -86,7 +86,7 @@ int devfs_read(const struct fs_read *const fr, struct fs_ret *const r) const struct drv_event_ops *const ops = &o->ops; - if (ops->read(fr->buf, fr->n, fd->start + fd->offset, &d, ops->args)) + if (ops->read(ops->p, fr->buf, fr->n, fd->start + fd->offset, &d)) goto failure; *r = (const struct fs_ret){.f = wait, .args = re}; diff --git a/src/fs/devfs/src/read_nb.c b/src/fs/devfs/src/read_nb.c index 75b6c25..7b79bf8 100644 --- a/src/fs/devfs/src/read_nb.c +++ b/src/fs/devfs/src/read_nb.c @@ -37,5 +37,5 @@ int devfs_read_nb(const struct fs_read *const fr) const struct drv_event_ops *const ops = &o->ops; - return ops->read_nb(fr->buf, fr->n, ops->args); + return ops->read_nb(ops->p, fr->buf, fr->n); } diff --git a/src/fs/devfs/src/write.c b/src/fs/devfs/src/write.c index fbb0ac8..dd4568f 100644 --- a/src/fs/devfs/src/write.c +++ b/src/fs/devfs/src/write.c @@ -83,7 +83,7 @@ int devfs_write(const struct fs_write *const fw, struct fs_ret *const r) const struct drv_event_ops *const ops = &o->ops; - if (ops->write(fw->buf, fw->n, &d, ops->args)) + if (ops->write(ops->p, fw->buf, fw->n, &d)) goto failure; *r = (const struct fs_ret){.f = wait, .args = w}; -- cgit v1.2.3