new busybox
[nestedvm.git] / src / org / ibex / nestedvm / UnixRuntime.java
index 6c986e5..e3afe98 100644 (file)
@@ -4,6 +4,8 @@ import org.ibex.nestedvm.util.*;
 import java.io.*;
 import java.util.*;
 
 import java.io.*;
 import java.util.*;
 
+// FEATURE: vfork
+
 public abstract class UnixRuntime extends Runtime implements Cloneable {
     /** The pid of this "process" */
     private int pid;
 public abstract class UnixRuntime extends Runtime implements Cloneable {
     /** The pid of this "process" */
     private int pid;
@@ -114,6 +116,7 @@ public abstract class UnixRuntime extends Runtime implements Cloneable {
             case SYS_exec: return sys_exec(a,b,c);
             case SYS_getdents: return sys_getdents(a,b,c,d);
             case SYS_unlink: return sys_unlink(a);
             case SYS_exec: return sys_exec(a,b,c);
             case SYS_getdents: return sys_getdents(a,b,c,d);
             case SYS_unlink: return sys_unlink(a);
+            case SYS_getppid: return sys_getppid();
 
             default: return super._syscall(syscall,a,b,c,d);
         }
 
             default: return super._syscall(syscall,a,b,c,d);
         }
@@ -122,6 +125,10 @@ public abstract class UnixRuntime extends Runtime implements Cloneable {
     FD _open(String path, int flags, int mode) throws ErrnoException {
         return gs.open(this,normalizePath(path),flags,mode);
     }
     FD _open(String path, int flags, int mode) throws ErrnoException {
         return gs.open(this,normalizePath(path),flags,mode);
     }
+    
+    private int sys_getppid() {
+        return parent == null ? 1 : parent.pid;
+    }
 
     /** The kill syscall.
        SIGSTOP, SIGTSTO, SIGTTIN, and SIGTTOUT pause the process.
 
     /** The kill syscall.
        SIGSTOP, SIGTSTO, SIGTTIN, and SIGTTOUT pause the process.
@@ -635,6 +642,9 @@ public abstract class UnixRuntime extends Runtime implements Cloneable {
         }
 
         public synchronized Object exec(UnixRuntime r, String path) throws ErrnoException {
         }
 
         public synchronized Object exec(UnixRuntime r, String path) throws ErrnoException {
+            // FIXME: Hideous hack to make a standalone busybox possible
+            if(path.equals("bin/busybox") && r.getClass().getName().endsWith("BusyBox"))
+                return r.getClass();
             FStat fstat = stat(r,path);
             if(fstat == null) return null;
             long mtime = fstat.mtime();
             FStat fstat = stat(r,path);
             if(fstat == null) return null;
             long mtime = fstat.mtime();