Mercurial > hg > Members > menikon > CbC_xv6
changeset 255:8c8f092e4f52
fix
author | menikon |
---|---|
date | Wed, 05 Feb 2020 18:57:44 +0900 |
parents | 66a6aedf60f9 |
children | 20294366d1f9 |
files | src/impl/fs_impl.cbc src/impl/fs_impl.h src/impl/fs_impl_private.cbc |
diffstat | 3 files changed, 41 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/impl/fs_impl.cbc Wed Feb 05 17:39:17 2020 +0900 +++ b/src/impl/fs_impl.cbc Wed Feb 05 18:57:44 2020 +0900 @@ -137,14 +137,16 @@ } __code iputfs_impl(struct fs_impl* fs, struct inode* ip, __code next(...)) { - + if (next == C_iputfs_impl) { + next = fs->next2; + } goto iput_check(fs, ip, next(...)); } -__code iunlockputfs_impl(struct fs_impl* fs, struct inode* ip, __code next(...)) { - - goto next(...); +__code iunlockputfs_impl(struct fs_impl* fs, struct inode* ip, __code next(...)) { + fs->next2 = next; + goto iunlockfs_impl(ip, fs->iput, ...); } typedef struct stat stat; @@ -187,6 +189,7 @@ if ((ip = dirlookup(dp, name, 0)) != 0) { goto dirlink_namecheck(fs, ip, next(...)); } + Gearef(cbc_context, fs)->off = 0; goto dirlink_loopcheck(fs, de, dp, off, next(...)); }
--- a/src/impl/fs_impl.h Wed Feb 05 17:39:17 2020 +0900 +++ b/src/impl/fs_impl.h Wed Feb 05 18:57:44 2020 +0900 @@ -26,5 +26,9 @@ __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 dirlink_namecheck(struct fs_impl* fs_impl, struct inode* ip, __code next(int ret, ...)); + __code dirlink_loopcheck(struct fs_impl* fs_impl, struct dirent* de, struct inode* dp, uint off, __code next(...)); + __code dirlink_loop(struct fs_impl* fs_impl, struct dirent* de, struct inode* ip, uint off, uint inum, __code next(...)); + __code dirlink_noloop(struct fs_impl* fs_impl, struct dirent* de, struct inode* dp, uint off, uint inum, char* name, __code next(...)); __code next(...); + __code next2(...); } fs_impl;
--- a/src/impl/fs_impl_private.cbc Wed Feb 05 17:39:17 2020 +0900 +++ b/src/impl/fs_impl_private.cbc Wed Feb 05 18:57:44 2020 +0900 @@ -283,5 +283,35 @@ } __code dirlink_loopcheck(struct fs_impl* fs_impl, struct dirent* de, struct inode* dp, uint off, __code next(...)){ //:skip + if(off < dp->size){ + goto dirlink_loop(fs_impl, de, dp, off, inum, next(...)); + } + goto dirlink_noloop(fs_impl, de, dp, off, inum, name, next(...)); +} +__code dirlink_loop(struct fs_impl* fs_impl, struct dirent* de, struct inode* dp, uint off, uint inum, __code next(...)){ //:skip + if (readi(dp, (char*) &de, off, sizeof(de)) != sizeof(de)) { + /* + panic("dirlink read"); + */ + } + + if (de->inum == 0) { + goto dirlink_noloop(fs_impl, de, dp, off, inum, name, next(...)); + } + + goto dirlink_loopcheck(fs_impl, de, dp, off + sizeof(de), next(...)); } + +__code dirlink_noloop(struct fs_impl* fs_impl, struct dirent* de, struct inode* dp, uint off, uint inum, char* name, __code next(int ret, ...)){ //:skip + strncpy(de->name, name, DIRSIZ); + de->inum = inum; + + if (writei(dp, (char*) &de, off, sizeof(de)) != sizeof(de)) { + /* + panic("dirlink"); + */ + } + ret = 0; + goto next(ret, ...); +}