diff options
Diffstat (limited to 'src/fs')
| -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 | ||||
| -rw-r--r-- | src/fs/include/fs/fs.h | 40 | ||||
| -rw-r--r-- | src/fs/include/fs/inode.h | 1 | ||||
| -rw-r--r-- | src/fs/iso9660/src/eof.c | 4 | ||||
| -rw-r--r-- | src/fs/iso9660/src/open.c | 5 | ||||
| -rw-r--r-- | src/fs/ramfs/src/search.c | 4 |
9 files changed, 57 insertions, 30 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}; diff --git a/src/fs/include/fs/fs.h b/src/fs/include/fs/fs.h index 60c1788..66bfe84 100644 --- a/src/fs/include/fs/fs.h +++ b/src/fs/include/fs/fs.h @@ -30,6 +30,23 @@ struct fs_mountpoint; struct fs_mp_prv; struct fs_fd_prv; +struct fs_mp +{ + const char *src, *tgt; + const struct fs *fs; + struct fs_mp_prv *prv; +}; + +struct fs_fd +{ + int error; + off_t start, offset, size; + struct fs_fd_prv *prv; + struct fs_mp mp; + const struct fs_mp *tgt_mp; + union inode_result inode; +}; + struct fs_stat { const char *path; @@ -62,6 +79,11 @@ struct fs_umount gid_t gid; }; +struct fs_stdstreams +{ + struct fs_fd streams[3]; +}; + struct fs_open { const char *path; @@ -70,6 +92,7 @@ struct fs_open mode_t mode; uid_t uid; gid_t gid; + struct fs_stdstreams ss; }; struct fs_read @@ -114,23 +137,6 @@ struct fs struct inode_ops iops; }; -struct fs_mp -{ - const char *src, *tgt; - const struct fs *fs; - struct fs_mp_prv *prv; -}; - -struct fs_fd -{ - int error; - off_t start, offset, size; - struct fs_fd_prv *prv; - struct fs_mp mp; - const struct fs_mp *tgt_mp; - union inode_result inode, tgt_inode; -}; - typedef int (*fs_update_fn)(struct fs_mp_prv *); int fs_register(const struct fs *fs); diff --git a/src/fs/include/fs/inode.h b/src/fs/include/fs/inode.h index a7759f9..9447ab2 100644 --- a/src/fs/include/fs/inode.h +++ b/src/fs/include/fs/inode.h @@ -20,6 +20,7 @@ #define FS_INODE_H #include <state.h> +#include <sys/stat.h> #include <sys/types.h> #include <time.h> diff --git a/src/fs/iso9660/src/eof.c b/src/fs/iso9660/src/eof.c index 1c36b63..d53461b 100644 --- a/src/fs/iso9660/src/eof.c +++ b/src/fs/iso9660/src/eof.c @@ -21,10 +21,10 @@ #include <iso9660/types.h> #include <fs/inode.h> +/* TODO: eof seems redundant because of caio_eof */ int iso9660_eof(const struct fs_fd *const fd) { - const union inode_result *const i = &fd->tgt_inode; - const off_t sz = i->cachei.size; + const off_t sz = fd->size; if (!sz) return 1; diff --git a/src/fs/iso9660/src/open.c b/src/fs/iso9660/src/open.c index 9818719..979ea91 100644 --- a/src/fs/iso9660/src/open.c +++ b/src/fs/iso9660/src/open.c @@ -31,6 +31,7 @@ struct open struct fs_fd *fd; struct fs_ret *pr, r; struct fs_mp mp; + struct fs_stdstreams ss; }; static int search_done(const enum state state, const char *const relpath, @@ -57,7 +58,6 @@ static int search_done(const enum state state, const char *const relpath, *fd = (const struct fs_fd) { .start = mpinode->prv->offset, - .tgt_inode.cachei = op->inode, .size = mpinode->size, .tgt_mp = &op->mp, .inode = *inode, @@ -93,7 +93,8 @@ int iso9660_open(const struct fs_open *const o, const struct fs_mp *const mp, .inode = *i, .mp = *mp, .pr = r, - .r = *r + .r = *r, + .ss = o->ss }; if (inode_search(&s, r)) diff --git a/src/fs/ramfs/src/search.c b/src/fs/ramfs/src/search.c index 24e2a98..076603d 100644 --- a/src/fs/ramfs/src/search.c +++ b/src/fs/ramfs/src/search.c @@ -20,6 +20,7 @@ #include <ramfs/types.h> #include <fs/fs.h> #include <state.h> +#include <errno.h> #include <stdbool.h> #include <stdlib.h> #include <string.h> @@ -76,7 +77,10 @@ static int find_node(const char *const path, struct inode **const out, } if (!found) + { + errno = ENOENT; goto end; + } } ret = 0; |
