# HG changeset patch # User menikon # Date 1579779219 -32400 # Node ID ab5a80021afe9c6d39544b26c9298351262188f5 # Parent b73c5bd61c37dd90307d65d993c30c7b08e02908# Parent 02bb0f8be908b7aa9445b7c8292168c19dbd9d1e merge diff -r 02bb0f8be908 -r ab5a80021afe src/impl/file_impl_inode.cbc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/impl/file_impl_inode.cbc Thu Jan 23 20:33:39 2020 +0900 @@ -0,0 +1,70 @@ +#include "../context.h" +#interface "file.h" + +// ---- +// typedef struct inode 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(...)){ + + + +} diff -r 02bb0f8be908 -r ab5a80021afe src/impl/file_impl_none.cbc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/impl/file_impl_none.cbc Thu Jan 23 20:33:39 2020 +0900 @@ -0,0 +1,64 @@ +#include "../context.h" +#interface "file.h" + +// ---- +// typedef struct none 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); +} diff -r 02bb0f8be908 -r ab5a80021afe src/impl/inode.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/impl/inode.h Thu Jan 23 20:33:39 2020 +0900 @@ -0,0 +1,3 @@ +typedef struct inode impl file { + +} inode; diff -r 02bb0f8be908 -r ab5a80021afe src/impl/none.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/impl/none.h Thu Jan 23 20:33:39 2020 +0900 @@ -0,0 +1,3 @@ +typedef struct none impl file { + +} none;