changeset 313:9d7787e4e214

build success
author menikon
date Wed, 05 Feb 2020 16:40:02 +0900
parents b527f27761bf
children eb62acc627f1
files src/impl/fs_impl.h src/impl/fs_impl_private.cbc
diffstat 2 files changed, 33 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/impl/fs_impl.h	Wed Feb 05 15:35:04 2020 +0900
+++ b/src/impl/fs_impl.h	Wed Feb 05 16:40:02 2020 +0900
@@ -6,7 +6,7 @@
     short type;
     struct buf* bp;
     struct dinode* dip;
-    int inum;
+    uint inum;
     struct inode* dp;
     char* name;
     uint off;
@@ -14,9 +14,9 @@
     dirent* de;
 
     __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 allocinode_loop(Type* fs_impl, uint inum, uint dev, struct superblock* sb, struct buf* bp, struct dinode* dip, __code next(...));
+    __code allocinode_loopcheck(Type* fs_impl, uint inum, uint dev, struct superblock* sb, struct buf* bp, struct dinode* dip, __code next(...));
+    __code allocinode_noloop(Type* fs_impl, uint 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(...));
--- a/src/impl/fs_impl_private.cbc	Wed Feb 05 15:35:04 2020 +0900
+++ b/src/impl/fs_impl_private.cbc	Wed Feb 05 16:40:02 2020 +0900
@@ -25,7 +25,7 @@
 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
+__code allocinode_loopcheck(struct fs_impl* fs_impl, uint 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(...));
     }
@@ -34,7 +34,7 @@
 */
 }
 
-__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
+__code allocinode_loop(struct fs_impl* fs_impl, uint 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){
@@ -87,7 +87,7 @@
     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 ret, ...)){ //:skip
+__code allocinode_noloop(struct fs_impl* fs_impl, uint 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;
@@ -238,12 +238,36 @@
 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){
-        goto dirlookup_loop(fs_impl, dp, name, off, poff, de, next(...));
+        goto dirlookup_loop(fs_impl, dp, name, off, inum, 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(...)){
+__code dirlookup_loop(struct fs_impl* fs_impl, struct inode* dp, char* name, uint off, uint inum, uint* poff, dirent* de, __code next(int ret, ...)){
+    if (readi(dp, (char*) &de, off, sizeof(de)) != sizeof(de)) {
+        /*
+        panic("dirlink read");
+        goto panic(...);
+        */
+    }
+
+    if (de->inum == 0) {
+        /*
+        coninue;
+        */
+    }
+
+    if (namecmp(name, de->name) == 0) {
+        // entry matches path element
+        if (poff) {
+            *poff = off;
+        }
+
+        inum = de->inum;
+        ret = iget(dp->dev, inum);
+        goto next(ret, ...);
+    }
+
     off += sizeof(de);
     goto dirlookup_loopcheck(fs_impl, dp, name, poff, de, next(...));
 }