// 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
case SYS_fork: return sys_fork();
case SYS_pipe: return sys_pipe(a);
case SYS_dup2: return sys_dup2(a,b);
+ case SYS_dup: return sys_dup(a);
case SYS_waitpid: return sys_waitpid(a,b,c);
case SYS_stat: return sys_stat(a,b);
case SYS_lstat: return sys_lstat(a,b);
return 0;
}
+ private int sys_dup(int oldd) {
+ if(oldd < 0 || oldd >= OPEN_MAX) return -EBADFD;
+ if(fds[oldd] == null) return -EBADFD;
+ FD fd = fds[oldd].dup();
+ int newd = addFD(fd);
+ if(newd < 0) { fd.close(); return -ENFILE; }
+ return newd;
+ }
+
private int sys_stat(int cstring, int addr) throws FaultException, ErrnoException {
FStat s = gs.stat(this,normalizePath(cstring(cstring)));
if(s == null) return -ENOENT;
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;