Mercurial > hg > Members > menikon > CbC_xv6
changeset 199:34fae66beb7e
merge
author | menikon <e165723@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 22 Jan 2020 20:29:31 +0900 |
parents | 6e28bd30e8a7 (diff) 429f0c3cc097 (current diff) |
children | b73c5bd61c37 |
files | |
diffstat | 4 files changed, 140 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/impl/file_impl_inode.cbc Wed Jan 22 20:29:31 2020 +0900 @@ -0,0 +1,70 @@ +#include "../context.h" +#interface "file.h" + +// ---- +// typedef struct inode<Impl, Isa> impl file { +// +// } inode; +// ---- + +file* createinode(struct Context* cbc_context) { + struct file* file = new file(); + struct inode* inode = new inode(); + file->file = (union Data*)inode; + file->st = NULL; + file->addr = NULL; + file->n = 0; + file->fd = 0; + file->read = C_readinode; + file->write = C_writeinode; + file->close = C_closeinode; + return file; +} +__code readinode(struct inode* file, char* addr, __code next(...)) { + + goto next(...); +} + +__code writeinode(struct inode* file, char* addr, int n, __code next(...)) { + + goto next(...); +} + +__code closeinode(struct inode* file,int fd, __code next(...)) { + + goto file->cbc_inodecolse(file->file, next); +} + +__code cbc_inodeclose(struct inode* inode, struct file* file, __code next(...)){ + struct file ff; + acquire(*ftable.loc) + + if (f->ref < 1) { + goto cbc_context->kernel_error->panic("file close"); + } + goto inode->cbc_inodeclose2(f,ff,next); +} + +__code cbc_inodeclose2(struct inode* inode, struct file* file, struct file* ff, __code next(...)){ + if (--f->ref > 0) { + release(&ftable.lock); + goto cbc_context->return(); + } + goto inode->cbc_inodeclose3(f,ff,next); +} + +__code cbc_inodeclose3(struct inode* inode, struct file* file, struct file* ff, __code next(...)){ + *ff = *f; + f->ref = 0; + f->type = FD_NONE; + relsease(&ftable.lock); + struct inode* i = ff.inode; + + goto inode->cbc_inodeclose4(i,next); +} + +__code cbc_inodeclose4(struct inode* inode,__code next(...)){ + + + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/impl/file_impl_none.cbc Wed Jan 22 20:29:31 2020 +0900 @@ -0,0 +1,64 @@ +#include "../context.h" +#interface "file.h" + +// ---- +// typedef struct none<Impl, Isa> impl file { +// +// } none; +// ---- + +file* createnone(struct Context* cbc_context) { + struct file* file = new file(); + struct none* none = new none(); + file->file = (union Data*)none; + file->remoe = 0; + file->off = 0; + file->st = NULL; + file->addr = NULL; + file->pipe = 0; + file->inode = 0; + file->n = 0; + file->fd = 0; + file->stat = C_statnone; + file->read = C_readnone; + file->write = C_writenone; + file->close = C_closenone; + return file; +} +__code statnone(struct none* file, struct stat* st, __code next(...)) { + + goto next(...); +} + +__code readnone(struct none* file, char* addr, __code next(...)) { + + goto next(...); +} + +__code writenone(struct none* file, char* addr, int n, __code next(...)) { + + goto next(...); +} + +__code closenone(struct none* file,int fd, __code next(...)) { + + goto file->noneclose(file->file, next); +} + +__code noneclose(struct none* none, struct file* file, __code next(...){ + struct file ff; + acquire(*ftable.loc) + + if (f->ref < 1) { + goto cbc_context->kernel_error->panic("file close"); + } + goto pipe->cbc_noneclose2(f,ff,next); +} + +__code noneclose2(struct none* none,struct file* file, struct file* ff,__code next(...)){ + if (--f->ref > 0) { + release(&ftable.lock); + goto cbc_context->return(); + } + goto pipe->cbc_pipeclose3(f,ff,next); +}