view src/impl/file_impl_inode.cbc @ 290:696c6bdc1074

tweak
author menikon
date Sat, 25 Jan 2020 16:42:09 +0900
parents 6e28bd30e8a7
children 4265c6e825af
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* ip = new ip();
    file->file = (union Data*)inode;
    file->st = NULL;
    file->addr = NULL;
    file->n  = 0;
    file->fd  = 0;
    file->stat = C_statinode;
    file->read = C_readinode;
    file->write = C_writeinode;
    file->close = C_closeinode;
    return file;
}

__code statinode(struct inode* ip, struct stat* st, __code next(...)) { //:skip

    goto cbc_statinode(ip, st, next(...));
}

__code cbc_statinode((struct inode* ip, struct stat* st, __code next(...)){
}

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



}