Mercurial > hg > Members > menikon > CbC_xv6
view src/impl/fs_impl_private.cbc @ 242:5217253368ad
rewrite ialloc
author | menikon |
---|---|
date | Fri, 31 Jan 2020 16:17:06 +0900 |
parents | bc2f3d24faa9 |
children | c5c4f9e233ad |
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_impl.h" /* fs_impl* createfs_impl2(); */ __code allocinode(struct fs_impl* fs_impl, uint dev, struct superblock* sb, __code next(...)){ //:skip readsb(dev, sb); Gearef(cbc_context, fs_impl)->inum = 1; goto allocinode_loopcheck(fs_impl, inum, dev, sb, bp, dip, next(...)); } typedef struct buf buf; typedef struct dinode dinode; __code allocinode_loopcheck(struct fs_impl* fs_impl, int inum, uint dev, struct superblock* sb, struct buf* bp, struct dinode* dip, __code next(...)){ //:skip if( inum < sb->ninodes){ goto allocinode_loop(fs_impl, inum, dev, type, sb, bp, dip, next(...)); } /* goto cbc_context->panic(...); */ } __code allocinode_loop(struct fs_impl* fs_impl, int inum, uint dev, short type, struct superblock* sb, struct buf* bp, struct dinode* dip, __code next(...)){ //:skip bp = bread(dev, IBLOCK(inum)); dip = (struct dinode*) bp->data + inum % IPB; if(dip->type = 0){ goto allocinode_noloop(fs_impl, inum, dev, sb, bp, dip, next(...)); } brelse(bp); inum++; goto allocinode_loopcheck(fs_impl, inum, dev, type, sb, bp, dip, next(...)); } __code allocinode_noloop(struct fs_impl* fs_impl, int inum, uint dev, short type, struct superblock* sb, struct buf* bp, struct dinode* dip, __code next(...)){ //:skip memset(dip, 0, sizeof(*dip)); dip->type = type; log_write(bp); brelse(bp); int iget_val = iget(dev, inum); goto next(iget_val, ...); }