X-Git-Url: http://git.megacz.com/?p=nestedvm.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fnestedvm%2FRuntime.java;h=bcbadd4d8bde15ef88351904e64b35c985e3a3a0;hp=902e377ce2365a27675fc1c18330caa7bbf028f1;hb=9a641039c47c2619982213501f49e1168fcdbda2;hpb=777acd138d857049f58620b5c2003733798e69f0 diff --git a/src/org/ibex/nestedvm/Runtime.java b/src/org/ibex/nestedvm/Runtime.java index 902e377..bcbadd4 100644 --- a/src/org/ibex/nestedvm/Runtime.java +++ b/src/org/ibex/nestedvm/Runtime.java @@ -194,6 +194,7 @@ public abstract class Runtime implements UsermodeConstants,Registers { addr INTO a java byte array a */ public final void copyin(int addr, byte[] buf, int count) throws ReadFaultException { int x=0; + if(count == 0) return; if((addr&3)!=0) { int word = memRead(addr&~3); switch(addr&3) { @@ -236,6 +237,7 @@ public abstract class Runtime implements UsermodeConstants,Registers { space at addr */ public final void copyout(byte[] buf, int addr, int count) throws FaultException { int x=0; + if(count == 0) return; if((addr&3)!=0) { int word = memRead(addr&~3); switch(addr&3) { @@ -1161,9 +1163,17 @@ public abstract class Runtime implements UsermodeConstants,Registers { private final boolean executable; public HostFStat(File f) { this.f = f; - String name = f.getName(); - // FEATURE: This is ugly.. maybe we should do a file(1) type check - executable = name.endsWith(".mips") || name.endsWith(".sh"); + boolean _executable = false; + // FEATURE: This might be too expensive + try { + FileInputStream fis = new FileInputStream(f); + switch(fis.read()) { + case '\177': _executable = fis.read() == 'E' && fis.read() == 'L' && fis.read() == 'F'; break; + case '#': _executable = fis.read() == '!'; + } + fis.close(); + } catch(IOException e) { /* ignore */ } + executable = _executable; } public int dev() { return 1; } public int inode() { return f.getName().hashCode() & 0xffff; }