public static final int O_APPEND = 0x0008;
public static final int O_TRUNC = 0x0400;
public static final int O_NONBLOCK = 0x4000;
+ public static final int O_NOCTTY = 0x8000;
+
FD hostFSOpen(final File f, int flags, int mode, final Object data) throws ErrnoException {
if((flags & ~(3|O_CREAT|O_EXCL|O_APPEND|O_TRUNC)) != 0) {
- if(STDERR_DIAG) System.err.println("WARNING: Unsupported flags passed to open(): " + toHex(flags & ~(3|O_CREAT|O_EXCL|O_APPEND|O_TRUNC)));
+ if(STDERR_DIAG)
+ System.err.println("WARNING: Unsupported flags passed to open(\"" + f + "\"): " + toHex(flags & ~(3|O_CREAT|O_EXCL|O_APPEND|O_TRUNC)));
+
throw new ErrnoException(ENOTSUP);
}
boolean write = (flags&3) != RD_ONLY;
/** The open syscall */
private int sys_open(int addr, int flags, int mode) throws ErrnoException, FaultException {
+ flags &= ~O_NOCTTY; // this is meaningless under nestedvm
FD fd = _open(cstring(addr),flags,mode);
if(fd == null) return -ENOENT;
int fdn = addFD(fd);
private int sys_sysconf(int n) {
switch(n) {
case _SC_CLK_TCK: return 1000;
+ case _SC_PAGESIZE: return writePages.length == 1 ? 4096 : (1<<pageShift);
+ case _SC_PHYS_PAGES: return writePages.length == 1 ? (1<<pageShift)/4096 : writePages.length;
default:
if(STDERR_DIAG) System.err.println("WARNING: Attempted to use unknown sysconf key: " + n);
return -EINVAL;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ClassFileCompiler c = new ClassFileCompiler(data,className,baos);
// FEATURE: make this Optional, pass options on compile arguments
- c.parseOptions("unixruntime");
+ c.parseOptions("unixruntime,nosupportcall");
c.go();
baos.close();
byte[] bytecode = baos.toByteArray();
// 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
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;