Make fd_tell host independent

This commit is contained in:
Jakub Konka
2019-07-21 10:01:17 +02:00
committed by Dan Gohman
parent 5bbf59e1c5
commit 919262b5b9
3 changed files with 7 additions and 15 deletions

View File

@@ -27,14 +27,6 @@ pub(crate) fn fd_pwrite(file: &File, buf: &[u8], offset: host::__wasi_filesize_t
.map_err(|e| e.raw_os_error().map_or(host::__WASI_EIO, errno_from_host))
}
pub(crate) fn fd_tell(file: &File) -> Result<u64> {
use nix::unistd::{lseek, Whence};
match lseek(file.as_raw_fd(), 0, Whence::SeekCur) {
Ok(newoffset) => Ok(newoffset as u64),
Err(e) => Err(host_impl::errno_from_nix(e.as_errno().unwrap())),
}
}
pub(crate) fn fd_fdstat_get(fd: &File) -> Result<host::__wasi_fdflags_t> {
use nix::fcntl::{fcntl, OFlag, F_GETFL};
match fcntl(fd.as_raw_fd(), F_GETFL).map(OFlag::from_bits_truncate) {