Mercurial > hg > CbC > CbC_xv6
view src/impl/fs_impl.cbc @ 306:5ea0b8b12aaf
tweak
author | menikon |
---|---|
date | Fri, 31 Jan 2020 18:48:54 +0900 |
parents | a101eb88b1cd |
children | 4cf83e6ce534 |
line wrap: on
line source
#include "types.h" #include "defs.h" #include "param.h" #include "stat.h" #include "mmu.h" #include "proc.h" #include "spinlock.h" #include "buf.h" #include "fs.h" #include "file.h" #interface "fs.dg" // ---- // typedef struct fs_impl<Impl, Isa> impl fs{ // union Data* fs_impl; // // // // // } fs_impl; // ---- fs* createfs_impl(struct Context* cbc_context) { struct fs* fs = new fs(); struct fs_impl* fs_impl = new fs_impl(); fs->fs = (union Data*)fs_impl; fs_impl->fs_impl = NULL; fs->readsb = C_readsbfs_impl; fs->iinit = C_iinitfs_impl; fs->ialloc = C_iallocfs_impl; fs_impl->allocinode = C_allocinode; fs_impl->allocinode_loop = C_allocinode_loop; fs_impl->allocinode_loopcheck = C_allocinode_loopcheck; fs_impl->allocinode_noloop = C_allocinode_noloop; fs->iupdate = C_iupdatefs_impl; fs->idup = C_idupfs_impl; fs->ilock = C_ilockfs_impl; fs_impl->lockinode1 = C_lockinode1; fs_impl->lockinode_sleepcheck = C_lockinode_sleepcheck; fs->iunlock = C_iunlockfs_impl; fs->iput = C_iputfs_impl; fs->iunlockput = C_iunlockputfs_impl; fs->stati = C_statifs_impl; fs->readi = C_readifs_impl; fs->writei = C_writeifs_impl; fs->namecmp = C_namecmpfs_impl; fs->dirlookup = C_dirlookupfs_impl; fs->dirlink = C_dirlinkfs_impl; fs->namei = C_nameifs_impl; fs->nameiparent = C_nameiparentfs_impl; return fs; } typedef struct superblock superblock; __code readsbfs_impl(struct fs_impl* fs, uint dev, struct superblock* sb, __code next(...)) { //:skip struct buf* bp; bp = bread(dev, 1); memmove(sb, bp->data, sizeof(*sb)); brelse(bp); goto next(...); } struct { struct spinlock lock; struct inode inode[NINODE]; } icache; __code iinitfs_impl(struct fs_impl* fs, __code next(...)) { initlock(&icache.lock, "icache"); goto next(...); } __code iallocfs_impl(struct fs_impl* fs, uint dev, short type, __code next(...)) { goto allocinode(fs, dev, sb, next(...)); } __code iupdatefs_impl(struct fs_impl* fs, struct inode* ip, __code next(...)) { struct buf *bp; struct dinode *dip; bp = bread(ip->dev, IBLOCK(ip->inum)); dip = (struct dinode*) bp->data + ip->inum % IPB; dip->type = ip->type; dip->major = ip->major; dip->minor = ip->minor; dip->nlink = ip->nlink; dip->size = ip->size; memmove(dip->addrs, ip->addrs, sizeof(ip->addrs)); log_write(bp); brelse(bp); goto next(...); } __code idupfs_impl(struct fs_impl* fs, struct inode* ip, __code next(...)) { acquire(&icache.lock); ip->ref++; release(&icache.lock); goto next(ip, ...); } __code ilockfs_impl(struct fs_impl* fs, struct inode* ip, __code next(...)) { goto lockinode1(fs, ip, bp, dip, next(...)); } __code iunlockfs_impl(struct fs_impl* fs, struct inode* ip, __code next(...)) { goto next(...); } __code iputfs_impl(struct fs_impl* fs, struct inode* ip, __code next(...)) { goto next(...); } __code iunlockputfs_impl(struct fs_impl* fs, struct inode* ip, __code next(...)) { goto next(...); } typedef struct stat stat; __code statifs_impl(struct fs_impl* fs , struct inode* ip, struct stat* st, __code next(...)) { //:skip goto next(...); } __code readifs_impl(struct fs_impl* fs, struct inode* ip, char* dst, uint off, uint n, __code next(...)) { goto next(...); } __code writeifs_impl(struct fs_impl* fs, struct inode* ip, char* src, uint off, uint n, __code next(...)) { goto next(...); } __code namecmpfs_impl(struct fs_impl* fs, const char* s, const char* t, __code next(...)) { goto next(...); } __code dirlookupfs_impl(struct inode* dp, char* name, uint* poff, __code next(...)) { goto next(...); } __code dirlinkfs_impl(struct fs_impl* fs, struct inode* dp, char* name, uint inum, __code next(...)) { goto next(...); } __code nameifs_impl(struct fs_impl* fs, char* path, __code next(...)) { goto next(...); } __code nameiparentfs_impl(struct fs_impl* fs, char* path, char* name, __code next(...)) { goto next(...); }