changeset 323:f0b337cb6024 default tip

use goto err->panic
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sat, 08 Feb 2020 20:37:42 +0900
parents b85ac65a3b52
children
files src/impl/KernelError.cbc src/impl/fs_impl.cbc src/impl/fs_impl_private.cbc
diffstat 3 files changed, 40 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/src/impl/KernelError.cbc	Fri Feb 07 19:00:16 2020 +0900
+++ b/src/impl/KernelError.cbc	Sat Feb 08 20:37:42 2020 +0900
@@ -20,7 +20,7 @@
 }
 
 __code infinity_loopKernelError(struct KernelError* err, __code next(...)) {
-
+  goto next(...);
 }
 
 __code errorKernelError(struct KernelError* err, int err_code, __code next(...)) {
--- a/src/impl/fs_impl.cbc	Fri Feb 07 19:00:16 2020 +0900
+++ b/src/impl/fs_impl.cbc	Sat Feb 08 20:37:42 2020 +0900
@@ -8,6 +8,7 @@
 #include "buf.h"
 #include "fs.h"
 #include "file.h"
+#interface "Err.h"
 #interface "fs.dg"
 
 // ----
@@ -154,10 +155,10 @@
 __code iunlockfs_impl(struct fs_impl* fs, struct inode* ip, __code next(...)) {
     
     if (ip == 0 || !(ip->flags & I_BUSY) || ip->ref < 1) {
-        /*
-        panic("iunlock");
-        goto panic();
-        */
+       char* msg = "iunlock";
+       struct Err* err = createKernelError(&proc->cbc_context);
+       Gearef(cbc_context, Err)->msg = msg;
+       goto meta(cbc_context, err->panic);
     }
 
     acquire(&icache.lock);
@@ -234,9 +235,10 @@
 
 __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");
-        */
+       char* msg = "dirlookup not DIR";
+       struct Err* err = createKernelError(&proc->cbc_context);
+       Gearef(cbc_context, Err)->msg = msg;
+       goto meta(cbc_context, err->panic);
     }
     Gearef(cbc_context, fs)->off = 0;
     goto dirlookup_loopcheck(fs, dp, name, off, poff, de, next(...));
--- a/src/impl/fs_impl_private.cbc	Fri Feb 07 19:00:16 2020 +0900
+++ b/src/impl/fs_impl_private.cbc	Sat Feb 08 20:37:42 2020 +0900
@@ -9,6 +9,7 @@
 #include "fs.h"
 #include "file.h"
 #interface "fs_impl.h"
+#interface "Err.h"
 #define min(a, b) ((a) < (b) ? (a) : (b))
 
 /*
@@ -30,9 +31,11 @@
     if( inum < sb->ninodes){
         goto allocinode_loop(fs_impl, inum, dev, type, sb, bp, dip, next(...));
     }
-/*
-    goto cbc_context->panic(...);
-*/
+    char* msg = "failed allocinode...";
+    struct Err* err = createKernelError(&proc->cbc_context);
+    Gearef(cbc_context, Err)->msg = msg;
+    goto meta(cbc_context, err->panic);
+
 }
 
 __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
@@ -103,11 +106,10 @@
 __code lockinode1(struct fs_impl* fs_impl, struct inode* ip, struct buf* bp, struct dinode* dip, __code next(...)){ //:skip
 
     if (ip == 0 || ip->ref < 1) {
-       
-    /*
-    panic("ilock");
-    goto panic();
-    */
+       char* msg = "ilock";
+       struct Err* err = createKernelError(&proc->cbc_context);
+       Gearef(cbc_context, Err)->msg = msg;
+       goto meta(cbc_context, err->panic);
      }
     acquire(&icache.lock);
 
@@ -136,10 +138,10 @@
         ip->flags |= I_VALID;
 
         if (ip->type == 0) {
-             /*
-             panic("ilock: no type");
-             goto panic();
-             */
+             char* msg = "ilock: no type";
+             struct Err* err = createKernelError(&proc->cbc_context);
+             Gearef(cbc_context, Err)->msg = msg;
+             goto meta(cbc_context, err->panic);
         }
     }
     goto next(...);
@@ -219,9 +221,10 @@
 __code iput_inode_nolink(struct fs_impl* fs_impl, struct inode* ip, __code next(...)){
     
     if (ip->flags & I_BUSY) {
-        /*
-        panic("iput busy"); 
-        */
+        char* msg = "iput busy";
+        struct Err* err = createKernelError(&proc->cbc_context);
+        Gearef(cbc_context, Err)->msg = msg;
+        goto meta(cbc_context, err->panic);
     }   
         
     ip->flags |= I_BUSY;
@@ -394,10 +397,10 @@
 
 __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(...);
-        */
+        char* msg = "dirlink read";
+        struct Err* err = createKernelError(&proc->cbc_context);
+        Gearef(cbc_context, Err)->msg = msg;
+        goto meta(cbc_context, err->panic);
     }
 
     if (de->inum == 0) {
@@ -440,9 +443,10 @@
 
 __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");
-        */
+       char* msg = "dirlink read";
+       struct Err* err = createKernelError(&proc->cbc_context);
+       Gearef(cbc_context, Err)->msg = msg;
+       goto meta(cbc_context, err->panic);
     }
 
     if (de->inum == 0) {
@@ -457,9 +461,10 @@
     de->inum = inum;
 
     if (writei(dp, (char*) &de, off, sizeof(de)) != sizeof(de)) {
-        /*
-        panic("dirlink");
-        */
+       char* msg = "dirlink read";
+       struct Err* err = createKernelError(&proc->cbc_context);
+       Gearef(cbc_context, Err)->msg = msg;
+       goto meta(cbc_context, err->panic);
     }
     ret = 0;
     goto next(ret, ...);