diff options
| author | Xavier Del Campo Romero <xavi92@disroot.org> | 2025-11-12 00:37:26 +0100 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi92@disroot.org> | 2025-11-16 22:57:45 +0100 |
| commit | 2ce58c995946f85666e793c4f06efff683e76ae4 (patch) | |
| tree | fbf2658bb0b0f61dadcf4ca27f997eaded78aae5 /src/fs/devfs | |
| parent | 5ce25ae3b5d8666d373f7d7e336546ce8508c213 (diff) | |
fixesHEADhelloworldmaster
Diffstat (limited to 'src/fs/devfs')
| -rw-r--r-- | src/fs/devfs/src/open.c | 27 | ||||
| -rw-r--r-- | src/fs/devfs/src/read.c | 2 | ||||
| -rw-r--r-- | src/fs/devfs/src/read_nb.c | 2 | ||||
| -rw-r--r-- | src/fs/devfs/src/write.c | 2 |
4 files changed, 24 insertions, 9 deletions
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 <devfs/ops.h> #include <fs/fs.h> #include <state.h> +#include <unistd.h> #include <stdlib.h> +#include <string.h> 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}; |
