changeset 317:20294366d1f9

add readi CodeGear
author menikon
date Thu, 06 Feb 2020 16:22:38 +0900
parents 8c8f092e4f52
children d4ff2fb275b5
files src/impl/fs_impl.cbc src/impl/fs_impl.h src/impl/fs_impl_private.cbc
diffstat 3 files changed, 38 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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(...)) {
--- 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, ...));
--- 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){