Mercurial > hg > Members > menikon > CbC_xv6
changeset 251:b527f27761bf
tweak
author | menikon |
---|---|
date | Wed, 05 Feb 2020 15:35:04 +0900 |
parents | b40deb55b7db |
children | 9d7787e4e214 |
files | src/impl/fs_impl.cbc src/impl/fs_impl.h src/impl/fs_impl_private.cbc src/interface/fs.dg |
diffstat | 4 files changed, 40 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/src/impl/fs_impl.cbc Tue Feb 04 16:11:36 2020 +0900 +++ b/src/impl/fs_impl.cbc Wed Feb 05 15:35:04 2020 +0900 @@ -172,13 +172,14 @@ goto next(strncmp_val, ...); } -__code dirlookupfs_impl(struct fs_impl* fs, struct inode* dp, char* name, uint* poff, dirent* de, __code next(...)) { //:skip +__code dirlookupfs_impl(struct fs_impl* fs, struct inode* dp, char* name, uint off, uint* poff, dirent* de, __code next(...)) { //:skip if (dp->type != T_DIR) { /* panic("dirlookup not DIR"); */ } - goto dirlookup_loopcheck(fs, dp, name, poff, de, next(...)); + Gearef(cbc_context, fs)->off = 0; + goto dirlookup_loopcheck(fs, dp, name, off, poff, de, next(...)); } __code dirlinkfs_impl(struct fs_impl* fs, struct inode* dp, char* name, uint inum, __code next(...)) {
--- a/src/impl/fs_impl.h Tue Feb 04 16:11:36 2020 +0900 +++ b/src/impl/fs_impl.h Wed Feb 05 15:35:04 2020 +0900 @@ -1,26 +1,29 @@ typedef struct fs_impl<Type, Isa> impl fs{ union Data* fs_impl; struct superblock* sb; + int ret; uint dev; short type; struct buf* bp; struct dinode* dip; int inum; - int iget_val; struct inode* dp; char* name; + uint off; uint* poff; dirent* de; - __code allocinode(Type* fs_impl, uint dev, short type, __code next(int iget_val, ...)); - __code allocinode_loop(Type* fs_impl, int inum, uint dev, struct superblock* sb, struct buf* bp, struct dinode* dip, __code next(int iget_val, ...)); - __code allocinode_loopcheck(Type* fs_impl, int inum, uint dev, struct superblock* sb, struct buf* bp, struct dinode* dip, __code next(int iget_val, ...)); - __code allocinode_noloop(Type* fs_impl, int inum, uint dev, struct superblock* sb, struct buf* bp, struct dinode* dip, __code next(int iget_val, ...)); + __code allocinode(Type* fs_impl, uint dev, short type, __code next(...)); + __code allocinode_loop(Type* fs_impl, int inum, uint dev, struct superblock* sb, struct buf* bp, struct dinode* dip, __code next(...)); + __code allocinode_loopcheck(Type* fs_impl, int inum, uint dev, struct superblock* sb, struct buf* bp, struct dinode* dip, __code next(...)); + __code allocinode_noloop(Type* fs_impl, int inum, uint dev, struct superblock* sb, struct buf* bp, struct dinode* dip, __code next(int ret, ...)); __code lockinode1(Type* fs_impl, struct inode *ip, struct buf *bp, struct dinode *dip, __code next(...)); __code lockinode2(Type* fs_impl, struct inode* ip, struct buf* bp, struct dinode* dip, __code next(...)); __code lockinode_sleepcheck(Type* fs_impl, struct inode* ip, __code next(...)); __code iput_check(Type* fs_impl, struct inode* ip, __code next(...)); __code iput_inode_nolink(Type* fs_impl, struct inode* ip, __code next(...)); - __code dirlookup_loopcheck(Type* fs_impl, struct inode* dp, char* name, uint* poff, dirent* de, next(...)); + __code dirlookup_loopcheck(Type* fs_impl, struct inode* dp, char* name, uint off, uint* poff, dirent* de, next(...)); + __code dirlookup_loop(struct fs_impl* fs_impl, struct inode* dp, char* name, uint off, uint* poff, dirent* de, __code next(...)); + __code dirlookup_noloop(struct fs_impl* fs_impl, __code next(int ret, ...)); __code next(...); } fs_impl;
--- a/src/impl/fs_impl_private.cbc Tue Feb 04 16:11:36 2020 +0900 +++ b/src/impl/fs_impl_private.cbc Wed Feb 05 15:35:04 2020 +0900 @@ -14,36 +14,36 @@ fs_impl* createfs_impl2(); */ -__code allocinode(struct fs_impl* fs_impl, uint dev, struct superblock* sb, __code next(int iget_val, ...)){ //:skip +__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(iget_val, ...)); + 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(int iget_val, ...)){ //:skip +__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(iget_val, ...)); + 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(int iget_val, ...)){ //:skip +__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(iget_val, ...)); + 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(iget_val, ...)); + goto allocinode_loopcheck(fs_impl, inum, dev, type, sb, bp, dip, next(...)); } struct { @@ -87,15 +87,15 @@ return ip; } -__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(int iget_val, ...)){ //:skip +__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(int ret, ...)){ //:skip memset(dip, 0, sizeof(*dip)); dip->type = type; log_write(bp); brelse(bp); - iget_val = iget(dev, inum); - goto next(iget_val, ...); + ret = iget(dev, inum); + goto next(ret, ...); } @@ -234,7 +234,21 @@ wakeup(ip); goto next(...); } + typedef struct dirent dirent; -__code dirlookup_loopcheck(struct fs_impl* fs_impl, struct inode* dp, char* name, uint* poff, dirent* de, __code next(...)){ //:skip - goto next(...); +__code dirlookup_loopcheck(struct fs_impl* fs_impl, struct inode* dp, char* name, uint off, uint* poff, dirent* de, __code next(...)){ //:skip + if(off < dp->size){ + goto dirlookup_loop(fs_impl, dp, name, off, poff, de, next(...)); + } + goto dirlookup_noloop(fs_impl, next(...)); } + +__code dirlookup_loop(struct fs_impl* fs_impl, struct inode* dp, char* name, uint off, uint* poff, dirent* de, __code next(...)){ + off += sizeof(de); + goto dirlookup_loopcheck(fs_impl, dp, name, poff, de, next(...)); +} + +__code dirlookup_noloop(struct fs_impl* fs_impl, __code next(int ret, ...)){ + ret = 0; + goto next(ret, ...); +}
--- a/src/interface/fs.dg Tue Feb 04 16:11:36 2020 +0900 +++ b/src/interface/fs.dg Wed Feb 05 15:35:04 2020 +0900 @@ -19,6 +19,7 @@ int namex_val; int strncmp_val; dirent* de; + int ret; __code readsb(Impl* fs, uint dev, struct superblock* sb, __code next(...)); __code iinit(Impl* fs, __code next(...)); @@ -33,7 +34,7 @@ __code readi(Impl* fs, struct inode* ip, char* dst, uint off, uint n, __code next(...)); __code writei(Impl* fs, struct inode* ip, char* src, uint off, uint n, __code next(...)); __code namecmp(Impl* fs, const char* s, const char* t, __code next(int strncmp_val, ...)); - __code dirlookup(struct inode* dp, char* name, uint* poff, dirent* de, __code next(...)); + __code dirlookup(struct inode* dp, char* name, uint* poff, dirent* de, __code next(int ret, ...)); __code dirlink(Impl* fs, struct inode* dp, char* name, uint inum, __code next(...)); __code namei(Impl* fs, char* path, __code next(int namex_val, ...)); __code nameiparent(Impl* fs, char* path, char* name, __code next(int namex_val, ...));