X-Git-Url: http://git.megacz.com/?p=nestedvm.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fnestedvm%2FUnixRuntime.java;h=151699f8c4c35c20b955291830371011c752070e;hp=a6847ee7d918a88f02c183bd9cc074a2c072b054;hb=7e1e0dc49707b777e71e69c23c0a48e0a2665a4b;hpb=47e2513b584db639600b57c79be03093f99b0073 diff --git a/src/org/ibex/nestedvm/UnixRuntime.java b/src/org/ibex/nestedvm/UnixRuntime.java index a6847ee..151699f 100644 --- a/src/org/ibex/nestedvm/UnixRuntime.java +++ b/src/org/ibex/nestedvm/UnixRuntime.java @@ -33,7 +33,9 @@ public abstract class UnixRuntime extends Runtime implements Cloneable { // FEATURE: Do the proper mangling for non-unix hosts String userdir = getSystemProperty("user.dir"); - cwd = userdir != null && userdir.startsWith("/") && File.separatorChar == '/' ? userdir.substring(1) : ""; + cwd = + userdir != null && userdir.startsWith("/") && File.separatorChar == '/' && HostFS.hostRootDir().getParent() == null + ? userdir.substring(1) : ""; } // NOTE: getDisplayName() is a Java2 function @@ -304,6 +306,12 @@ public abstract class UnixRuntime extends Runtime implements Cloneable { private int exec(String normalizedPath, String[] argv, String[] envp) throws ErrnoException { if(argv.length == 0) argv = new String[]{""}; + // NOTE: For this little hack to work nestedvm.root MUST be "." + /*try { + System.err.println("Execing normalized path: " + normalizedPath); + if(true) return exec(new Interpreter(normalizedPath),argv,envp); + } catch(IOException e) { throw new Error(e); }*/ + Object o = gs.exec(this,normalizedPath); if(o == null) return -ENOENT; @@ -794,8 +802,14 @@ public abstract class UnixRuntime extends Runtime implements Cloneable { public File getRoot() { return root; } private static File hostRootDir() { + if(getSystemProperty("nestedvm.root") != null) { + File f = new File(getSystemProperty("nestedvm.root")); + if(f.isDirectory()) return f; + // fall through to case below + } String cwd = getSystemProperty("user.dir"); File f = new File(cwd != null ? cwd : "."); + if(!f.exists()) throw new Error("Couldn't get File for cwd"); f = new File(f.getAbsolutePath()); while(f.getParent() != null) f = new File(f.getParent()); return f;