}
}
+ final int fsync(int fdn) {
+ if(fdn < 0 || fdn >= OPEN_MAX) return -EBADFD;
+ if(fds[fdn] == null) return -EBADFD;
+ FD fd = fds[fdn];
+
+ Seekable s = fd.seekable();
+ if (s == null) return -EINVAL;
+
+ try {
+ s.sync();
+ return 0;
+ } catch (IOException e) {
+ return -EIO;
+ }
+ }
+
/** The syscall dispatcher.
The should be called by subclasses when the syscall instruction is invoked.
<i>syscall</i> should be the contents of V0 and <i>a</i>, <i>b</i>, <i>c</i>, and <i>d</i> should be
case SYS_getgid: return sys_getgid();
case SYS_getegid: return sys_getegid();
+ case SYS_fsync: return fsync(a);
case SYS_memcpy: memcpy(a,b,c); return a;
case SYS_memset: memset(a,b,c); return a;
public static final int SYS_setgroups = 88;
public static final int SYS_resolve_ip = 89;
public static final int SYS_setsid = 90;
+ public static final int SYS_fsync = 91;
public static final int AF_UNIX = 1;
public static final int AF_INET = 2;
public static final int SOCK_STREAM = 1;
SYSCALL_R(getgroups)
SYSCALL_R(setsid)
SYSCALL_R2(__resolve_ip_r,SYS_resolve_ip)
+SYSCALL_R(fsync)
REENT_WRAPPER1(setegid,gid_t)
REENT_WRAPPER2(setgroups,int,const gid_t *)
REENT_WRAPPER0R(setsid,pid_t)
+REENT_WRAPPER1(fsync,int)
extern int __execve_r(struct _reent *ptr, const char *path, char *const argv[], char *const envp[]);
int _execve(const char *path, char *const argv[], char *const envp[]) {
/* do nothing*/
}
-int fsync(int fd) {
- /* do nothing */
- return 0;
-}
-
char *ttyname(int fd) {
return isatty(fd) ? "/dev/console" : NULL;
}
#define SYS_setgroups 88
#define SYS_resolve_ip 89
#define SYS_setsid 90
+#define SYS_fsync 91
public abstract void close() throws IOException;
public abstract int pos() throws IOException;
+ public void sync() throws IOException {
+ throw new IOException("sync not implemented for " + getClass());
+ }
public void resize(long length) throws IOException {
throw new IOException("resize not implemented for " + getClass());
}
public int read(byte[] buf, int offset, int length) throws IOException { return raf.read(buf,offset,length); }
public int write(byte[] buf, int offset, int length) throws IOException { raf.write(buf,offset,length); return length; }
+ public void sync() throws IOException { raf.getFD().sync(); }
public void seek(int pos) throws IOException{ raf.seek(pos); }
public int pos() throws IOException { return (int) raf.getFilePointer(); }
public int length() throws IOException { return (int)raf.length(); }