projects
/
nestedvm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
5bea48b
)
make jdk 1.1 compliant part 1
author
brian
<brian@brianweb.net>
Sun, 23 May 2004 08:15:02 +0000
(
01:15
-0700)
committer
brian
<brian@brianweb.net>
Sun, 23 May 2004 08:15:02 +0000
(
01:15
-0700)
darcs-hash:
20040523081502
-24bed-
fa3c46b4733c75a6637c225464e7ad4e70177efd
.gz
src/org/ibex/nestedvm/ClassFileCompiler.java
patch
|
blob
|
history
src/org/ibex/nestedvm/Compiler.java
patch
|
blob
|
history
src/org/ibex/nestedvm/Runtime.java
patch
|
blob
|
history
src/org/ibex/nestedvm/UnixRuntime.java
patch
|
blob
|
history
src/org/ibex/nestedvm/util/InodeCache.java
patch
|
blob
|
history
diff --git
a/src/org/ibex/nestedvm/ClassFileCompiler.java
b/src/org/ibex/nestedvm/ClassFileCompiler.java
index
3df1d4e
..
2f5b609
100644
(file)
--- a/
src/org/ibex/nestedvm/ClassFileCompiler.java
+++ b/
src/org/ibex/nestedvm/ClassFileCompiler.java
@@
-477,7
+477,7
@@
public class ClassFileCompiler extends Compiler implements org.apache.bcel.Const
private InstructionHandle realStart;
private MethodGen curMethod;
private InstructionHandle realStart;
private MethodGen curMethod;
- private boolean jumpable(int addr) { return jumpableAddresses.contains(new Integer(addr)); }
+ private boolean jumpable(int addr) { return jumpableAddresses.get(new Integer(addr)) != null; }
private void emitText(int addr, DataInputStream dis, int size) throws Exn,IOException {
if(textDone) throw new Exn("Multiple text segments");
private void emitText(int addr, DataInputStream dis, int size) throws Exn,IOException {
if(textDone) throw new Exn("Multiple text segments");
@@
-570,7
+570,7
@@
public class ClassFileCompiler extends Compiler implements org.apache.bcel.Const
pushConst(firstAddrOfNext);
setPC();
// mark the start of the next method as jumpable
pushConst(firstAddrOfNext);
setPC();
// mark the start of the next method as jumpable
- jumpableAddresses.add(new Integer(firstAddrOfNext));
+ jumpableAddresses.put(new Integer(firstAddrOfNext),Boolean.TRUE);
}
insnList.move(returnHandle,insnList.getEnd());
}
insnList.move(returnHandle,insnList.getEnd());
@@
-648,7
+648,7
@@
public class ClassFileCompiler extends Compiler implements org.apache.bcel.Const
//System.err.println("Delay slot is jumpable - This code is untested + " + toHex(nextInsn));
if(pc+4==endOfMethod) {
// the delay slot is at the start of the next method
//System.err.println("Delay slot is jumpable - This code is untested + " + toHex(nextInsn));
if(pc+4==endOfMethod) {
// the delay slot is at the start of the next method
- jumpableAddresses.add(new Integer(pc+8)); // make the 2nd insn of the next method jumpable
+ jumpableAddresses.put(new Integer(pc+8),Boolean.TRUE); // make the 2nd insn of the next method jumpable
branch(pc,pc+8); // jump over it
//System.err.println("delay slot: " + toHex(pc+8));
unreachable = true;
branch(pc,pc+8); // jump over it
//System.err.println("delay slot: " + toHex(pc+8));
unreachable = true;
diff --git
a/src/org/ibex/nestedvm/Compiler.java
b/src/org/ibex/nestedvm/Compiler.java
index
ebdf29d
..
b5835dd
100644
(file)
--- a/
src/org/ibex/nestedvm/Compiler.java
+++ b/
src/org/ibex/nestedvm/Compiler.java
@@
-83,7
+83,7
@@
public abstract class Compiler implements Registers {
}
/** A set of all addresses that can be jumped too (only available if pruneCases == true) */
}
/** A set of all addresses that can be jumped too (only available if pruneCases == true) */
- protected Set jumpableAddresses;
+ protected Hashtable jumpableAddresses;
/** Some important symbols */
ELF.Symbol userInfo, gp;
/** Some important symbols */
ELF.Symbol userInfo, gp;
@@
-211,9
+211,9
@@
public abstract class Compiler implements Registers {
if(pruneCases) {
// Find all possible branches
if(pruneCases) {
// Find all possible branches
- jumpableAddresses = new HashSet();
+ jumpableAddresses = new Hashtable();
- jumpableAddresses.add(new Integer(elf.header.entry));
+ jumpableAddresses.put(new Integer(elf.header.entry),Boolean.TRUE);
ELF.SHeader text = elf.sectionWithName(".text");
if(text == null) throw new Exn("No .text segment");
ELF.SHeader text = elf.sectionWithName(".text");
if(text == null) throw new Exn("No .text segment");
@@
-244,13
+244,13
@@
public abstract class Compiler implements Registers {
_go();
}
_go();
}
- private void findBranchesInSymtab(ELF.Symtab symtab, Set jumps) {
+ private void findBranchesInSymtab(ELF.Symtab symtab, Hashtable jumps) {
ELF.Symbol[] symbols = symtab.symbols;
int n=0;
for(int i=0;i<symbols.length;i++) {
ELF.Symbol s = symbols[i];
if(s.type == ELF.Symbol.STT_FUNC) {
ELF.Symbol[] symbols = symtab.symbols;
int n=0;
for(int i=0;i<symbols.length;i++) {
ELF.Symbol s = symbols[i];
if(s.type == ELF.Symbol.STT_FUNC) {
- if(jumps.add(new Integer(s.addr))) {
+ if(jumps.put(new Integer(s.addr),Boolean.TRUE) == null) {
//System.err.println("Adding symbol from symtab: " + s.name + " at " + toHex(s.addr));
n++;
}
//System.err.println("Adding symbol from symtab: " + s.name + " at " + toHex(s.addr));
n++;
}
@@
-259,7
+259,7
@@
public abstract class Compiler implements Registers {
if(printStats) System.err.println("Found " + n + " additional possible branch targets in Symtab");
}
if(printStats) System.err.println("Found " + n + " additional possible branch targets in Symtab");
}
- private void findBranchesInText(int base, DataInputStream dis, int size, Set jumps) throws IOException {
+ private void findBranchesInText(int base, DataInputStream dis, int size, Hashtable jumps) throws IOException {
int count = size/4;
int pc = base;
int n=0;
int count = size/4;
int pc = base;
int n=0;
@@
-282,10
+282,10
@@
public abstract class Compiler implements Registers {
case 0:
switch(subcode) {
case 9: // JALR
case 0:
switch(subcode) {
case 9: // JALR
- if(jumps.add(new Integer(pc+8))) n++; // return address
+ if(jumps.put(new Integer(pc+8),Boolean.TRUE) == null) n++; // return address
break;
case 12: // SYSCALL
break;
case 12: // SYSCALL
- if(jumps.add(new Integer(pc+4))) n++;
+ if(jumps.put(new Integer(pc+4),Boolean.TRUE) == null) n++;
break;
}
break;
break;
}
break;
@@
-293,31
+293,31
@@
public abstract class Compiler implements Registers {
switch(rt) {
case 16: // BLTZAL
case 17: // BGTZAL
switch(rt) {
case 16: // BLTZAL
case 17: // BGTZAL
- if(jumps.add(new Integer(pc+8))) n++; // return address
+ if(jumps.put(new Integer(pc+8),Boolean.TRUE) == null) n++; // return address
// fall through
case 0: // BLTZ
case 1: // BGEZ
// fall through
case 0: // BLTZ
case 1: // BGEZ
- if(jumps.add(new Integer(pc+branchTarget*4+4))) n++;
+ if(jumps.put(new Integer(pc+branchTarget*4+4),Boolean.TRUE) == null) n++;
break;
}
break;
case 3: // JAL
break;
}
break;
case 3: // JAL
- if(jumps.add(new Integer(pc+8))) n++; // return address
+ if(jumps.put(new Integer(pc+8),Boolean.TRUE) == null) n++; // return address
// fall through
case 2: // J
// fall through
case 2: // J
- if(jumps.add(new Integer((pc&0xf0000000)|(jumpTarget << 2)))) n++;
+ if(jumps.put(new Integer((pc&0xf0000000)|(jumpTarget << 2)),Boolean.TRUE) == null) n++;
break;
case 4: // BEQ
case 5: // BNE
case 6: // BLEZ
case 7: // BGTZ
break;
case 4: // BEQ
case 5: // BNE
case 6: // BLEZ
case 7: // BGTZ
- if(jumps.add(new Integer(pc+branchTarget*4+4))) n++;
+ if(jumps.put(new Integer(pc+branchTarget*4+4),Boolean.TRUE) == null) n++;
break;
case 9: { // ADDIU
if(pc - lui_pc[rs] <= 4*32) {
int t = (lui_val[rs]<<16)+signedImmediate;
if((t&3)==0 && t >= base && t < base+size) {
break;
case 9: { // ADDIU
if(pc - lui_pc[rs] <= 4*32) {
int t = (lui_val[rs]<<16)+signedImmediate;
if((t&3)==0 && t >= base && t < base+size) {
- if(jumps.add(new Integer(t))) {
+ if(jumps.put(new Integer(t),Boolean.TRUE) == null) {
//System.err.println("Possible jump to " + toHex(t) + " (" + inter.sourceLine(t) + ") from " + toHex(pc) + " (" + inter.sourceLine(pc) + ")");
n++;
}
//System.err.println("Possible jump to " + toHex(t) + " (" + inter.sourceLine(t) + ") from " + toHex(pc) + " (" + inter.sourceLine(pc) + ")");
n++;
}
@@
-336,7
+336,7
@@
public abstract class Compiler implements Registers {
case 17: // FPU Instructions
switch(rs) {
case 8: // BC1F, BC1T
case 17: // FPU Instructions
switch(rs) {
case 8: // BC1F, BC1T
- if(jumps.add(new Integer(pc+branchTarget*4+4))) n++;
+ if(jumps.put(new Integer(pc+branchTarget*4+4),Boolean.TRUE) == null) n++;
break;
}
break;
break;
}
break;
@@
-346,13
+346,13
@@
public abstract class Compiler implements Registers {
if(printStats) System.err.println("Found " + n + " additional possible branch targets in Text segment");
}
if(printStats) System.err.println("Found " + n + " additional possible branch targets in Text segment");
}
- private void findBranchesInData(DataInputStream dis, int size, Set jumps, int textStart, int textEnd) throws IOException {
+ private void findBranchesInData(DataInputStream dis, int size, Hashtable jumps, int textStart, int textEnd) throws IOException {
int count = size/4;
int n=0;
for(int i=0;i<count;i++) {
int word = dis.readInt();
if((word&3)==0 && word >= textStart && word < textEnd) {
int count = size/4;
int n=0;
for(int i=0;i<count;i++) {
int word = dis.readInt();
if((word&3)==0 && word >= textStart && word < textEnd) {
- if(jumps.add(new Integer(word))) {
+ if(jumps.put(new Integer(word),Boolean.TRUE) == null) {
//System.err.println("Added " + toHex(word) + " as possible branch target (fron data segment)");
n++;
}
//System.err.println("Added " + toHex(word) + " as possible branch target (fron data segment)");
n++;
}
@@
-388,7
+388,7
@@
public abstract class Compiler implements Registers {
public void set(Object val) {
if(field == null) return;
try {
public void set(Object val) {
if(field == null) return;
try {
- field.setAccessible(true);
+ /*field.setAccessible(true); NOT in JDK 1.1 */
field.set(Compiler.this,val);
} catch(IllegalAccessException e) {
System.err.println(e);
field.set(Compiler.this,val);
} catch(IllegalAccessException e) {
System.err.println(e);
@@
-397,7
+397,7
@@
public abstract class Compiler implements Registers {
public Object get() {
if(field == null) return null;
try {
public Object get() {
if(field == null) return null;
try {
- field.setAccessible(true);
+ /*field.setAccessible(true); NOT in JDK 1.1 */
return field.get(Compiler.this);
} catch(IllegalAccessException e) {
System.err.println(e); return null;
return field.get(Compiler.this);
} catch(IllegalAccessException e) {
System.err.println(e); return null;
diff --git
a/src/org/ibex/nestedvm/Runtime.java
b/src/org/ibex/nestedvm/Runtime.java
index
272e4e6
..
64ebd33
100644
(file)
--- a/
src/org/ibex/nestedvm/Runtime.java
+++ b/
src/org/ibex/nestedvm/Runtime.java
@@
-359,7
+359,8
@@
public abstract class Runtime implements UsermodeConstants,Registers,Cloneable {
if(page == null) throw new WriteFaultException(a<<2);
int index = a&pageWordMask;
int n = min(c,pageWords-index);
if(page == null) throw new WriteFaultException(a<<2);
int index = a&pageWordMask;
int n = min(c,pageWords-index);
- Arrays.fill(page,index,index+n,fourBytes);
+ /* Arrays.fill(page,index,index+n,fourBytes);*/
+ for(int i=index;i<index+n;i++) page[i] = fourBytes;
a += n; c -= n;
}
addr = a<<2; count&=3;
a += n; c -= n;
}
addr = a<<2; count&=3;
@@
-721,8
+722,7
@@
public abstract class Runtime implements UsermodeConstants,Registers,Cloneable {
if((flags & (O_EXCL|O_CREAT)) == (O_EXCL|O_CREAT)) {
try {
if((flags & (O_EXCL|O_CREAT)) == (O_EXCL|O_CREAT)) {
try {
- // NOTE: createNewFile is a Java2 function
- if(!f.createNewFile()) throw new ErrnoException(EEXIST);
+ if(Platform.atomicCreateFile(f)) throw new ErrnoException(EEXIST);
} catch(IOException e) {
throw new ErrnoException(EIO);
}
} catch(IOException e) {
throw new ErrnoException(EIO);
}
diff --git
a/src/org/ibex/nestedvm/UnixRuntime.java
b/src/org/ibex/nestedvm/UnixRuntime.java
index
ce47c4d
..
24be4e8
100644
(file)
--- a/
src/org/ibex/nestedvm/UnixRuntime.java
+++ b/
src/org/ibex/nestedvm/UnixRuntime.java
@@
-41,19
+41,18
@@
public abstract class UnixRuntime extends Runtime implements Cloneable {
? userdir.substring(1) : "";
}
? userdir.substring(1) : "";
}
- // NOTE: getDisplayName() is a Java2 function
private static String posixTZ() {
StringBuffer sb = new StringBuffer();
TimeZone zone = TimeZone.getDefault();
int off = zone.getRawOffset() / 1000;
private static String posixTZ() {
StringBuffer sb = new StringBuffer();
TimeZone zone = TimeZone.getDefault();
int off = zone.getRawOffset() / 1000;
- sb.append(zone.getDisplayName(false,TimeZone.SHORT));
+ sb.append(Platform.timeZoneGetDisplayName(zone,false,false));
if(off > 0) sb.append("-");
else off = -off;
sb.append(off/3600); off = off%3600;
if(off > 0) sb.append(":").append(off/60); off=off%60;
if(off > 0) sb.append(":").append(off);
if(zone.useDaylightTime())
if(off > 0) sb.append("-");
else off = -off;
sb.append(off/3600); off = off%3600;
if(off > 0) sb.append(":").append(off/60); off=off%60;
if(off > 0) sb.append(":").append(off);
if(zone.useDaylightTime())
- sb.append(zone.getDisplayName(true,TimeZone.SHORT));
+ sb.append(Platform.timeZoneGetDisplayName(zone,true,false));
return sb.toString();
}
return sb.toString();
}
@@
-93,7
+92,7
@@
public abstract class UnixRuntime extends Runtime implements Cloneable {
synchronized(parent.children) {
int i = parent.activeChildren.indexOf(prev);
if(i == -1) throw new Error("should never happen");
synchronized(parent.children) {
int i = parent.activeChildren.indexOf(prev);
if(i == -1) throw new Error("should never happen");
- parent.activeChildren.set(i,this);
+ parent.activeChildren.setElementAt(this,i);
}
} else {
int newpid = -1;
}
} else {
int newpid = -1;
@@
-194,12
+193,15
@@
public abstract class UnixRuntime extends Runtime implements Cloneable {
synchronized(children) {
for(;;) {
if(pid == -1) {
synchronized(children) {
for(;;) {
if(pid == -1) {
- if(exitedChildren.size() > 0) done = (UnixRuntime)exitedChildren.remove(exitedChildren.size() - 1);
+ if(exitedChildren.size() > 0) {
+ done = (UnixRuntime)exitedChildren.elementAt(exitedChildren.size() - 1);
+ exitedChildren.removeElementAt(exitedChildren.size() - 1);
+ }
} else if(pid > 0) {
UnixRuntime t = gs.tasks[pid];
if(t.parent != this) return -ECHILD;
if(t.state == EXITED) {
} else if(pid > 0) {
UnixRuntime t = gs.tasks[pid];
if(t.parent != this) return -ECHILD;
if(t.state == EXITED) {
- if(!exitedChildren.remove(t)) throw new Error("should never happen");
+ if(!exitedChildren.removeElement(t)) throw new Error("should never happen");
done = t;
}
} else {
done = t;
}
} else {
@@
-227,12
+229,12
@@
public abstract class UnixRuntime extends Runtime implements Cloneable {
UnixRuntime child = (UnixRuntime) e.nextElement();
gs.tasks[child.pid] = null;
}
UnixRuntime child = (UnixRuntime) e.nextElement();
gs.tasks[child.pid] = null;
}
- exitedChildren.clear();
+ exitedChildren.removeAllElements();
for(Enumeration e = activeChildren.elements(); e.hasMoreElements(); ) {
UnixRuntime child = (UnixRuntime) e.nextElement();
child.parent = null;
}
for(Enumeration e = activeChildren.elements(); e.hasMoreElements(); ) {
UnixRuntime child = (UnixRuntime) e.nextElement();
child.parent = null;
}
- activeChildren.clear();
+ activeChildren.removeAllElements();
}
UnixRuntime _parent = parent;
}
UnixRuntime _parent = parent;
@@
-243,8
+245,8
@@
public abstract class UnixRuntime extends Runtime implements Cloneable {
if(parent == null) {
gs.tasks[pid] = null;
} else {
if(parent == null) {
gs.tasks[pid] = null;
} else {
- if(!parent.activeChildren.remove(this)) throw new Error("should never happen _exited: pid: " + pid);
- parent.exitedChildren.add(this);
+ if(!parent.activeChildren.removeElement(this)) throw new Error("should never happen _exited: pid: " + pid);
+ parent.exitedChildren.addElement(this);
parent.children.notify();
}
}
parent.children.notify();
}
}
@@
-287,7
+289,7
@@
public abstract class UnixRuntime extends Runtime implements Cloneable {
activeChildren = new Vector();
exitedChildren = new Vector();
}
activeChildren = new Vector();
exitedChildren = new Vector();
}
- activeChildren.add(r);
+ activeChildren.addElement(r);
state.r[V0] = 0; // return 0 to child
state.pc += 4; // skip over syscall instruction
state.r[V0] = 0; // return 0 to child
state.pc += 4; // skip over syscall instruction
@@
-531,6
+533,8
@@
public abstract class UnixRuntime extends Runtime implements Cloneable {
return n;
}
return n;
}
+ // FIXME: UDP is totally broken
+
static class SocketFD extends FD {
public static final int TYPE_STREAM = 0;
public static final int TYPE_DGRAM = 1;
static class SocketFD extends FD {
public static final int TYPE_STREAM = 0;
public static final int TYPE_DGRAM = 1;
@@
-552,7
+556,7
@@
public abstract class UnixRuntime extends Runtime implements Cloneable {
public void setOptions() {
try {
if(o != null && type() == TYPE_STREAM && !listen()) {
public void setOptions() {
try {
if(o != null && type() == TYPE_STREAM && !listen()) {
- ((Socket)o).setKeepAlive((options & SO_KEEPALIVE) != 0);
+ Platform.socketSetKeepAlive((Socket)o,(options & SO_KEEPALIVE) != 0);
}
} catch(SocketException e) {
if(STDERR_DIAG) e.printStackTrace();
}
} catch(SocketException e) {
if(STDERR_DIAG) e.printStackTrace();
@@
-584,8
+588,10
@@
public abstract class UnixRuntime extends Runtime implements Cloneable {
throw new ErrnoException(EIO);
}
} else {
throw new ErrnoException(EIO);
}
} else {
+ if(off != 0) throw new IllegalArgumentException("off must be 0");
DatagramSocket ds = (DatagramSocket) o;
DatagramSocket ds = (DatagramSocket) o;
- dp.setData(a,off,length);
+ dp.setData(a);
+ dp.setLength(length);
try {
ds.receive(dp);
} catch(IOException e) {
try {
ds.receive(dp);
} catch(IOException e) {
@@
-605,8
+611,10
@@
public abstract class UnixRuntime extends Runtime implements Cloneable {
throw new ErrnoException(EIO);
}
} else {
throw new ErrnoException(EIO);
}
} else {
+ if(off != 0) throw new IllegalArgumentException("off must be 0");
DatagramSocket ds = (DatagramSocket) o;
DatagramSocket ds = (DatagramSocket) o;
- dp.setData(a,off,length);
+ dp.setData(a);
+ dp.setLength(length);
try {
ds.send(dp);
} catch(IOException e) {
try {
ds.send(dp);
} catch(IOException e) {
@@
-653,7
+661,7
@@
public abstract class UnixRuntime extends Runtime implements Cloneable {
InetAddress inetAddr;
try {
InetAddress inetAddr;
try {
- inetAddr = InetAddress.getByAddress(ip);
+ inetAddr = Platform.inetAddressFromBytes(ip);
} catch(UnknownHostException e) {
return -EADDRNOTAVAIL;
}
} catch(UnknownHostException e) {
return -EADDRNOTAVAIL;
}
@@
-669,9
+677,9
@@
public abstract class UnixRuntime extends Runtime implements Cloneable {
break;
}
case SocketFD.TYPE_DGRAM: {
break;
}
case SocketFD.TYPE_DGRAM: {
- DatagramSocket s = (DatagramSocket) fd.o;
- if(s == null) s = new DatagramSocket();
- s.connect(inetAddr,port);
+ if(fd.dp == null) fd.dp = new DatagramPacket(null,0);
+ fd.dp.setAddress(inetAddr);
+ fd.dp.setPort(port);
break;
}
default:
break;
}
default:
@@
-763,7
+771,7
@@
public abstract class UnixRuntime extends Runtime implements Cloneable {
copyin(addr+4,ip,4);
try {
copyin(addr+4,ip,4);
try {
- inetAddr = InetAddress.getByAddress(ip);
+ inetAddr = Platform.inetAddressFromBytes(ip);
} catch(UnknownHostException e) {
return -EADDRNOTAVAIL;
}
} catch(UnknownHostException e) {
return -EADDRNOTAVAIL;
}
@@
-849,8
+857,8
@@
public abstract class UnixRuntime extends Runtime implements Cloneable {
Socket s = (Socket) fd.o;
try {
Socket s = (Socket) fd.o;
try {
- if(how == SHUT_RD || how == SHUT_RDWR) s.shutdownInput();
- if(how == SHUT_WR || how == SHUT_RDWR) s.shutdownOutput();
+ if(how == SHUT_RD || how == SHUT_RDWR) Platform.socketHalfClose(s,false);
+ if(how == SHUT_WR || how == SHUT_RDWR) Platform.socketHalfClose(s,true);
} catch(IOException e) {
return -EIO;
}
} catch(IOException e) {
return -EIO;
}
@@
-978,7
+986,7
@@
public abstract class UnixRuntime extends Runtime implements Cloneable {
}
}
}
}
- private static class MP implements Comparable {
+ private static class MP implements Sort.Sortable {
public MP(String path, FS fs) { this.path = path; this.fs = fs; }
public String path;
public FS fs;
public MP(String path, FS fs) { this.path = path; this.fs = fs; }
public String path;
public FS fs;
@@
-1010,7
+1018,7
@@
public abstract class UnixRuntime extends Runtime implements Cloneable {
MP[] newMPS = new MP[oldLength + 1];
if(oldLength != 0) System.arraycopy(mps,0,newMPS,0,oldLength);
newMPS[oldLength] = new MP(path,fs);
MP[] newMPS = new MP[oldLength + 1];
if(oldLength != 0) System.arraycopy(mps,0,newMPS,0,oldLength);
newMPS[oldLength] = new MP(path,fs);
- Arrays.sort(newMPS);
+ Sort.sort(newMPS);
mps = newMPS;
int highdevno = 0;
for(int i=0;i<mps.length;i++) highdevno = max(highdevno,mps[i].fs.devno);
mps = newMPS;
int highdevno = 0;
for(int i=0;i<mps.length;i++) highdevno = max(highdevno,mps[i].fs.devno);
@@
-1321,20
+1329,30
@@
public abstract class UnixRuntime extends Runtime implements Cloneable {
if(r.sm != null && !r.sm.allowWrite(f)) throw new ErrnoException(EACCES);
if(f.exists() && f.isDirectory()) throw new ErrnoException(EEXIST);
if(f.exists()) throw new ErrnoException(ENOTDIR);
if(r.sm != null && !r.sm.allowWrite(f)) throw new ErrnoException(EACCES);
if(f.exists() && f.isDirectory()) throw new ErrnoException(EEXIST);
if(f.exists()) throw new ErrnoException(ENOTDIR);
- File parent = f.getParentFile();
+ File parent = getParentFile(f);
if(parent!=null && (!parent.exists() || !parent.isDirectory())) throw new ErrnoException(ENOTDIR);
if(!f.mkdir()) throw new ErrnoException(EIO);
}
if(parent!=null && (!parent.exists() || !parent.isDirectory())) throw new ErrnoException(ENOTDIR);
if(!f.mkdir()) throw new ErrnoException(EIO);
}
+ private static File getParentFile(File f) {
+ String p = f.getParent();
+ return p == null ? null : new File(f,p);
+ }
+
public class HostDirFD extends DirFD {
private final File f;
private final File[] children;
public class HostDirFD extends DirFD {
private final File f;
private final File[] children;
- public HostDirFD(File f) { this.f = f; children = f.listFiles(); }
+ public HostDirFD(File f) {
+ this.f = f;
+ String[] l = f.list();
+ children = new File[l.length];
+ for(int i=0;i<l.length;i++) children[i] = new File(f,l[i]);
+ }
public int size() { return children.length; }
public String name(int n) { return children[n].getName(); }
public int inode(int n) { return inodes.get(children[n].getAbsolutePath()); }
public int parentInode() {
public int size() { return children.length; }
public String name(int n) { return children[n].getName(); }
public int inode(int n) { return inodes.get(children[n].getAbsolutePath()); }
public int parentInode() {
- File parent = f.getParentFile();
+ File parent = getParentFile(f);
return parent == null ? -1 : inodes.get(parent.getAbsolutePath());
}
public int myInode() { return inodes.get(f.getAbsolutePath()); }
return parent == null ? -1 : inodes.get(parent.getAbsolutePath());
}
public int myInode() { return inodes.get(f.getAbsolutePath()); }
@@
-1421,7
+1439,11
@@
public abstract class UnixRuntime extends Runtime implements Cloneable {
}
private FD devZeroFD = new FD() {
}
private FD devZeroFD = new FD() {
- public int read(byte[] a, int off, int length) { Arrays.fill(a,off,off+length,(byte)0); return length; }
+ public int read(byte[] a, int off, int length) {
+ /*Arrays.fill(a,off,off+length,(byte)0);*/
+ for(int i=off;i<off+length;i++) a[i] = 0;
+ return length;
+ }
public int write(byte[] a, int off, int length) { return length; }
public int seek(int n, int whence) { return 0; }
public FStat _fstat() { return new DevFStat(){ public int inode() { return ZERO_INODE; } }; }
public int write(byte[] a, int off, int length) { return length; }
public int seek(int n, int whence) { return 0; }
public FStat _fstat() { return new DevFStat(){ public int inode() { return ZERO_INODE; } }; }
diff --git
a/src/org/ibex/nestedvm/util/InodeCache.java
b/src/org/ibex/nestedvm/util/InodeCache.java
index
c4cedb9
..
cb1d7f0
100644
(file)
--- a/
src/org/ibex/nestedvm/util/InodeCache.java
+++ b/
src/org/ibex/nestedvm/util/InodeCache.java
@@
-37,12
+37,14
@@
public class InodeCache {
clear();
}
clear();
}
+ private static void fill(Object[] a,Object o) { for(int i=0;i<a.length;i++) a[i] = o; }
+ private static void fill(short[] a, short s) { for(int i=0;i<a.length;i++) a[i] = s; }
public final void clear() {
size = usedSlots = 0;
mru = lru = -1;
public final void clear() {
size = usedSlots = 0;
mru = lru = -1;
- Arrays.fill(keys,null);
- Arrays.fill(inodes,SHORT_NULL);
- Arrays.fill(reverse,SHORT_NULL);
+ fill(keys,null);
+ fill(inodes,SHORT_NULL);
+ fill(reverse,SHORT_NULL);
}
public final short get(Object key) {
}
public final short get(Object key) {