# HG changeset patch # User menikon # Date 1580973758 -32400 # Node ID 20294366d1f9571c2c7bce22a49c660db9480058 # Parent 8c8f092e4f52c344dd22130552826e44c754aa80 add readi CodeGear diff -r 8c8f092e4f52 -r 20294366d1f9 src/impl/fs_impl.cbc --- a/src/impl/fs_impl.cbc Wed Feb 05 18:57:44 2020 +0900 +++ b/src/impl/fs_impl.cbc Thu Feb 06 16:22:38 2020 +0900 @@ -159,9 +159,22 @@ goto next(...); } -__code readifs_impl(struct fs_impl* fs, struct inode* ip, char* dst, uint off, uint n, __code next(...)) { +__code readifs_impl(struct fs_impl* fs, struct inode* ip, char* dst, uint off, uint n, __code next(int ret, ...)) { + if (ip->type == T_DEV) { + /* + ここ書く + */ + } - goto next(...); + if (off > ip->size || off + n < off) { + ret = -1; + goto next(ret, ...); + } + + if (off + n > ip->size) { + n = ip->size - off; + } + goto readi_loopcheck(fs, tot, m, dst, off, n, next(...)); } __code writeifs_impl(struct fs_impl* fs, struct inode* ip, char* src, uint off, uint n, __code next(...)) { diff -r 8c8f092e4f52 -r 20294366d1f9 src/impl/fs_impl.h --- a/src/impl/fs_impl.h Wed Feb 05 18:57:44 2020 +0900 +++ b/src/impl/fs_impl.h Thu Feb 06 16:22:38 2020 +0900 @@ -12,6 +12,10 @@ uint off; uint* poff; dirent* de; + uint tot; + uint m; + char* dst; + uint n; __code allocinode(Type* fs_impl, uint dev, short type, __code next(...)); __code allocinode_loop(Type* fs_impl, uint inum, uint dev, struct superblock* sb, struct buf* bp, struct dinode* dip, __code next(...)); @@ -22,6 +26,9 @@ __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 readi_loopcheck(struct fs_impl* fs_impl, uint tot, uint m, char* dst, uint off, uint n, __code next(...)); + __code readi_loop(struct fs_impl* fs_impl, struct inode *ip, struct buf* bp, uint tot, uint m, char* dst, uint off, uint n, __code next(...)); + __code readi_noloop(struct fs_impl* fs_impl, uint n, __code next(int ret, ...)); __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, ...)); diff -r 8c8f092e4f52 -r 20294366d1f9 src/impl/fs_impl_private.cbc --- a/src/impl/fs_impl_private.cbc Wed Feb 05 18:57:44 2020 +0900 +++ b/src/impl/fs_impl_private.cbc Thu Feb 06 16:22:38 2020 +0900 @@ -235,6 +235,22 @@ goto next(...); } +__code readi_loopcheck(struct fs_impl* fs_impl, uint tot, uint m, char* dst, uint off, uint n, __code next(...)){ + if(tot < n){ + goto readi_loop(fs_impl, ip, bp, tot, m, dst, off, n, next(...)); + } + goto readi_noloop(fs_impl, next(...)); +} + +__code readi_loop(struct fs_impl* fs_impl, struct inode* ip, struct buf* bp, uint tot, uint m, char* dst, uint off, uint n, __code next(...)){ //:skip + goto next(...); +} + +__code readi_noloop(struct fs_impl* fs_impl, uint n, __code next(int ret, ...)){ + ret = n; + goto next(ret, ...); + +} typedef struct dirent dirent; __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){