view src/impl/file_impl_inode.cbc @ 201:b73c5bd61c37

merge
author menikon <e165723@ie.u-ryukyu.ac.jp>
date Thu, 23 Jan 2020 01:55:03 +0900
parents 6e28bd30e8a7
children 696c6bdc1074
line wrap: on
line source

#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(...)){



}