Add sync syscall
This commit is contained in:
parent
a1ea05dc41
commit
78e94fe29b
@ -15,5 +15,6 @@ enclave {
|
||||
void ocall_print_string([in, string] const char* msg);
|
||||
int ocall_run_new_task(void);
|
||||
void ocall_gettimeofday([out] long* seconds, [out] long* microseconds);
|
||||
void ocall_sync(void);
|
||||
};
|
||||
};
|
||||
|
@ -19,6 +19,8 @@ extern ssize_t occlum_write(int fd, const void* buf, size_t size);
|
||||
extern ssize_t occlum_writev(int fd, const struct iovec* iov, int count);
|
||||
extern off_t occlum_lseek(int fd, off_t offset, int whence);
|
||||
|
||||
extern int occlum_sync(void);
|
||||
|
||||
extern int occlum_pipe(int fds[2]);
|
||||
extern int occlum_pipe2(int fds[2], int flags);
|
||||
|
||||
|
@ -153,3 +153,12 @@ pub fn do_dup3(old_fd: FileDesc, new_fd: FileDesc, flags: u32) -> Result<FileDes
|
||||
file_table.put_at(new_fd, file, close_on_spawn);
|
||||
Ok(new_fd)
|
||||
}
|
||||
|
||||
pub fn do_sync() -> Result<(), Error> {
|
||||
unsafe { ocall_sync(); }
|
||||
Ok(())
|
||||
}
|
||||
|
||||
extern {
|
||||
fn ocall_sync() -> sgx_status_t;
|
||||
}
|
||||
|
@ -540,6 +540,19 @@ pub extern "C" fn occlum_dup3(old_fd: c_int, new_fd: c_int, flags: c_int)
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn occlum_sync() -> c_int
|
||||
{
|
||||
match fs::do_sync() {
|
||||
Ok(()) => {
|
||||
0 as c_int
|
||||
}
|
||||
Err(e) => {
|
||||
e.errno.as_retval()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: handle tz: timezone_t
|
||||
#[no_mangle]
|
||||
pub extern "C" fn occlum_gettimeofday(tv: *mut timeval_t) -> c_int
|
||||
|
@ -85,6 +85,10 @@ long dispatch_syscall(int num, long arg0, long arg1, long arg2, long arg3, long
|
||||
ret = occlum_getppid();
|
||||
break;
|
||||
}
|
||||
case SYS_sync: {
|
||||
ret = occlum_sync();
|
||||
break;
|
||||
}
|
||||
case SYS_mmap: {
|
||||
DECL_SYSCALL_ARG(void*, addr, arg0);
|
||||
DECL_SYSCALL_ARG(size_t, length, arg1);
|
||||
|
@ -205,6 +205,10 @@ void ocall_gettimeofday(long* seconds, long* microseconds) {
|
||||
*microseconds = tv.tv_usec;
|
||||
}
|
||||
|
||||
void ocall_sync(void) {
|
||||
sync();
|
||||
}
|
||||
|
||||
|
||||
/* Application entry */
|
||||
int SGX_CDECL main(int argc, const char *argv[])
|
||||
|
Loading…
Reference in New Issue
Block a user