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;
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);
}
/** The open syscall */
private int sys_open(int addr, int flags, int mode) throws ErrnoException, FaultException {
+ String name = cstring(addr);
+
+ // HACK: TeX, or GPC, or something really sucks
+ if(name.length() == 1024 && getClass().getName().equals("tests.TeX")) name = name.trim();
+
flags &= ~O_NOCTTY; // this is meaningless under nestedvm
- FD fd = _open(cstring(addr),flags,mode);
+ FD fd = _open(name,flags,mode);
if(fd == null) return -ENOENT;
int fdn = addFD(fd);
if(fdn == -1) { fd.close(); return -ENFILE; }
for(i=arg;i<OPEN_MAX;i++) if(fds[i]==null) break;
if(i==OPEN_MAX) return -EMFILE;
fds[i] = fd.dup();
- return 0;
+ return i;
case F_GETFL:
return fd.flags();
case F_SETFD: