X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fibex%2Fnestedvm%2FRuntime.java;h=74b3a1223b0aaf733c11ead7ddea69a574050d08;hb=7d260c5822b8e63f198b52b24018fc7f19735692;hp=f6a00df4c6c73cb177550f091a8a0a0525e6b880;hpb=49cb14fa5b1e479ed41c38fd60372d9cd3086cd3;p=nestedvm.git diff --git a/src/org/ibex/nestedvm/Runtime.java b/src/org/ibex/nestedvm/Runtime.java index f6a00df..74b3a12 100644 --- a/src/org/ibex/nestedvm/Runtime.java +++ b/src/org/ibex/nestedvm/Runtime.java @@ -1,3 +1,7 @@ +// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Licensed under the Apache Public Source License 2.0 ("the License"). +// You may not use this file except in compliance with the License. + // Copyright 2003 Brian Alliet // Based on org.xwt.imp.MIPS by Adam Megacz // Portions Copyright 2003 Adam Megacz @@ -727,7 +731,6 @@ public abstract class Runtime implements UsermodeConstants,Registers,Cloneable { if((flags & ~(3|O_CREAT|O_EXCL|O_APPEND|O_TRUNC)) != 0) { 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; @@ -736,7 +739,7 @@ public abstract class Runtime implements UsermodeConstants,Registers,Cloneable { if((flags & (O_EXCL|O_CREAT)) == (O_EXCL|O_CREAT)) { try { - if(Platform.atomicCreateFile(f)) throw new ErrnoException(EEXIST); + if(!Platform.atomicCreateFile(f)) throw new ErrnoException(EEXIST); } catch(IOException e) { throw new ErrnoException(EIO); } @@ -1019,7 +1022,7 @@ public abstract class Runtime implements UsermodeConstants,Registers,Cloneable { return -ENOSYS; } } - + /** The syscall dispatcher. The should be called by subclasses when the syscall instruction is invoked. syscall should be the contents of V0 and a, b, c, and d should be @@ -1028,9 +1031,11 @@ public abstract class Runtime implements UsermodeConstants,Registers,Cloneable { protected final int syscall(int syscall, int a, int b, int c, int d, int e, int f) { try { int n = _syscall(syscall,a,b,c,d,e,f); - //if(n < 0) System.err.println("syscall: " + syscall + " returned " + n); + //if(n<0) throw new ErrnoException(-n); return n; } catch(ErrnoException ex) { + //System.err.println("While executing syscall: " + syscall + ":"); + //if(syscall == SYS_open) try { System.err.println("Failed to open " + cstring(a) + " errno " + ex.errno); } catch(Exception e2) { } //ex.printStackTrace(); return -ex.errno; } catch(FaultException ex) { @@ -1061,6 +1066,10 @@ public abstract class Runtime implements UsermodeConstants,Registers,Cloneable { case SYS_getpagesize: return sys_getpagesize(); case SYS_fcntl: return sys_fcntl(a,b,c); case SYS_sysconf: return sys_sysconf(a); + case SYS_getuid: return sys_getuid(); + case SYS_geteuid: return sys_geteuid(); + case SYS_getgid: return sys_getgid(); + case SYS_getegid: return sys_getegid(); case SYS_memcpy: memcpy(a,b,c); return a; case SYS_memset: memset(a,b,c); return a; @@ -1082,6 +1091,11 @@ public abstract class Runtime implements UsermodeConstants,Registers,Cloneable { } } + private int sys_getuid() { return 0; } + private int sys_geteuid() { return 0; } + private int sys_getgid() { return 0; } + private int sys_getegid() { return 0; } + public int xmalloc(int size) { int p=malloc(size); if(p==0) throw new RuntimeException("malloc() failed"); return p; } public int xrealloc(int addr,int newsize) { int p=realloc(addr,newsize); if(p==0) throw new RuntimeException("realloc() failed"); return p; } public int realloc(int addr, int newsize) { try { return call("realloc",addr,newsize); } catch(CallException e) { return 0; } }