Delete unused runtime-abi

This commit is contained in:
Syrus 2019-09-24 22:10:03 -07:00
parent 7bf306eb27
commit fec90b570b
12 changed files with 0 additions and 481 deletions

1
.github/CODEOWNERS vendored
View File

@ -8,7 +8,6 @@ lib/llvm-backend @nlewycky @losfair
# Runtime
lib/runtime-core @Hywan @bjfish
lib/runtime-abi @MarkMcCaskey
lib/runtime @MarkMcCaskey @Hywan @bjfish
lib/runtime-c-api @bjfish @Hywan
lib/win-exception-handler @bjfish @losfair

View File

@ -27,7 +27,6 @@ wasmer-clif-backend = { path = "lib/clif-backend" }
wasmer-singlepass-backend = { path = "lib/singlepass-backend", optional = true }
wasmer-middleware-common = { path = "lib/middleware-common" }
wasmer-runtime = { path = "lib/runtime" }
# wasmer-runtime-abi = { path = "lib/runtime-abi", optional = true }
wasmer-runtime-core = { path = "lib/runtime-core" }
wasmer-emscripten = { path = "lib/emscripten" }
wasmer-llvm-backend = { path = "lib/llvm-backend", optional = true }
@ -43,7 +42,6 @@ members = [
"lib/clif-backend",
"lib/singlepass-backend",
"lib/runtime",
# "lib/runtime-abi",
"lib/runtime-core",
"lib/emscripten",
"lib/spectests",
@ -100,7 +98,6 @@ backend-singlepass = [
]
wasi = ["wasmer-wasi"]
managed = ["backend-singlepass", "wasmer-runtime-core/managed"]
# vfs = ["wasmer-runtime-abi"]
[[example]]
name = "plugin"

View File

@ -1,27 +0,0 @@
[package]
name = "wasmer-runtime-abi"
version = "0.7.0"
description = "Wasmer runtime core library"
license = "MIT"
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
repository = "https://github.com/wasmerio/wasmer"
edition = "2018"
[dependencies]
libc = "0.2.60"
wasmer-runtime-core = { path = "../runtime-core" }
failure = "0.1"
tar = "0.4"
wasmparser = "0.37.0"
zstd = "0.4"
# [target.'cfg(unix)'.dependencies.zbox]
# git = "https://github.com/wasmerio/zbox"
# branch = "bundle-libsodium"
# features = ["libsodium-bundled"]
[dev-dependencies]
tempdir = "0.3"
[features]
debug = []

View File

@ -1,23 +0,0 @@
# runtime-abi
This crate has ABI functions (like syscalls) and extensions to the runtime for enabling ABIs (e.g. virtual filesystem).
## Virtual Filesystem (experimental)
The virtual filesystem allows the runtime to read bundled wasm data as if they were files. Data that is stored in a
custom section compressed with [zstd][1] compression and archived with [tar][2] will be exposed as files and mounted
in the `/` root.
The only current supported operation is the `read` syscall.
The virtual filesystem is not enabled by default. Build with `--features vfs` to use it.
[Zbox][3] is a virtual filesystem that depends on [libsodium][4]. See [installation instructions][5] for libsodium here. One can
statically link libsodium with the [instructions][6] on Zbox's readme.
[1]: https://facebook.github.io/zstd/
[2]: https://www.gnu.org/software/tar/
[3]: https://zbox.io/
[4]: https://download.libsodium.org/doc/
[5]: https://download.libsodium.org/doc/installation
[6]: https://github.com/zboxfs/zbox#static-linking-with-libsodium

View File

@ -1,11 +0,0 @@
#![deny(dead_code, unused_imports, unused_variables, unused_unsafe, unreachable_patterns)]
#![doc(html_favicon_url = "https://wasmer.io/static/icons/favicon.ico")]
#![doc(html_logo_url = "https://avatars3.githubusercontent.com/u/44205449?s=200&v=4")]
#[cfg(not(target_os = "windows"))]
#[macro_use]
extern crate failure;
#[cfg(not(target_os = "windows"))]
pub mod vfs;

View File

@ -1,111 +0,0 @@
use crate::vfs::file_like::{FileLike, Metadata};
use failure::Error;
use std::io;
pub struct Stdin;
pub struct Stdout;
pub struct Stderr;
impl FileLike for Stdin {
fn metadata(&self) -> Result<Metadata, Error> {
unimplemented!()
}
fn set_file_len(&mut self, _len: usize) -> Result<(), failure::Error> {
panic!("Cannot set length of stdin");
}
}
impl io::Read for Stdin {
fn read(&mut self, _buf: &mut [u8]) -> Result<usize, io::Error> {
unimplemented!()
}
}
impl io::Write for Stdin {
fn write(&mut self, _buf: &[u8]) -> Result<usize, io::Error> {
unimplemented!()
}
fn flush(&mut self) -> Result<(), io::Error> {
unimplemented!()
}
}
impl io::Seek for Stdin {
fn seek(&mut self, _pos: io::SeekFrom) -> Result<u64, io::Error> {
unimplemented!()
}
}
impl FileLike for Stdout {
fn metadata(&self) -> Result<Metadata, failure::Error> {
unimplemented!()
}
fn set_file_len(&mut self, _len: usize) -> Result<(), failure::Error> {
panic!("Cannot set length of stdout");
}
}
impl io::Read for Stdout {
fn read(&mut self, _buf: &mut [u8]) -> Result<usize, io::Error> {
unimplemented!()
}
}
impl io::Write for Stdout {
fn write(&mut self, buf: &[u8]) -> Result<usize, io::Error> {
let stdout = io::stdout();
let mut handle = stdout.lock();
handle.write(buf)
}
fn flush(&mut self) -> Result<(), io::Error> {
let stdout = io::stdout();
let mut handle = stdout.lock();
handle.flush()
}
}
impl io::Seek for Stdout {
fn seek(&mut self, _pos: io::SeekFrom) -> Result<u64, io::Error> {
unimplemented!()
}
}
impl FileLike for Stderr {
fn metadata(&self) -> Result<Metadata, failure::Error> {
unimplemented!()
}
fn set_file_len(&mut self, _len: usize) -> Result<(), failure::Error> {
panic!("Cannot set length of stderr");
}
}
impl io::Read for Stderr {
fn read(&mut self, _buf: &mut [u8]) -> Result<usize, io::Error> {
unimplemented!()
}
}
impl io::Write for Stderr {
fn write(&mut self, buf: &[u8]) -> Result<usize, io::Error> {
let stderr = io::stderr();
let mut handle = stderr.lock();
handle.write(buf)
}
fn flush(&mut self) -> Result<(), io::Error> {
let stderr = io::stderr();
let mut handle = stderr.lock();
handle.flush()
}
}
impl io::Seek for Stderr {
fn seek(&mut self, _pos: io::SeekFrom) -> Result<u64, io::Error> {
unimplemented!()
}
}

View File

@ -1,21 +0,0 @@
pub type Fd = isize;
#[derive(Debug)]
pub struct Metadata {
pub len: usize,
pub is_file: bool,
}
pub trait FileLike: std::io::Write + std::io::Read + std::io::Seek {
// get metadata
fn metadata(&self) -> Result<Metadata, failure::Error>;
// write
// fn write_file(&mut self, buf: &[u8]) -> Result<usize, io::Error>;
// read
// fn read_file(&mut self, buf: &mut [u8]) -> Result<usize, io::Error>;
// set_file_len
fn set_file_len(&mut self, len: usize) -> Result<(), failure::Error>;
}

View File

@ -1,5 +0,0 @@
pub mod device_file;
pub mod file_like;
pub mod vfs;
pub mod vfs_header;
pub mod virtual_file;

View File

@ -1,170 +0,0 @@
use crate::vfs::file_like::FileLike;
use crate::vfs::vfs_header::{header_from_bytes, ArchiveType, CompressionType};
use crate::vfs::virtual_file::VirtualFile;
use std::collections::HashMap;
use std::cell::RefCell;
use std::io;
use std::io::Read;
use std::path::{Path, PathBuf};
use std::rc::Rc;
use tar::EntryType;
use zbox::{init_env, OpenOptions, Repo, RepoOpener};
pub struct Vfs {
repo: Repo,
device_files: HashMap<PathBuf, Rc<RefCell<dyn FileLike>>>,
}
impl Vfs {
/// Like `VfsBacking::from_tar_bytes` except it also decompresses from the zstd format.
pub fn from_tar_zstd_bytes<Reader: Read>(tar_bytes: Reader) -> Result<Self, failure::Error> {
let result = zstd::decode_all(tar_bytes);
let decompressed_data = result.unwrap();
Self::from_tar_bytes(&decompressed_data[..])
}
/// Match on the type of the compressed-archive and select the correct unpack method
pub fn from_compressed_bytes(compressed_data_slice: &[u8]) -> Result<Self, failure::Error> {
let data_bytes = &compressed_data_slice[4..];
match header_from_bytes(compressed_data_slice)? {
(_, CompressionType::ZSTD, ArchiveType::TAR) => Self::from_tar_zstd_bytes(data_bytes),
(_, CompressionType::NONE, ArchiveType::TAR) => Self::from_tar_bytes(data_bytes),
}
}
/// Create a vfs from raw bytes in tar format
pub fn from_tar_bytes<Reader: Read>(tar_bytes: Reader) -> Result<Self, failure::Error> {
init_env();
let mut repo = RepoOpener::new()
.create(true)
.open("mem://wasmer_fs", "")
.unwrap();
let _errors = tar::Archive::new(tar_bytes)
.entries()?
.map(|entry| {
let mut entry: tar::Entry<Reader> = entry?;
let path = entry.path()?;
let path = convert_to_absolute_path(path);
let _result = match (entry.header().entry_type(), path.parent()) {
(EntryType::Regular, Some(parent)) => {
if let Err(e) = repo.create_dir_all(parent) {
if e == zbox::Error::AlreadyExists || e == zbox::Error::IsRoot {
} else {
return Err(VfsAggregateError::ZboxError(e));
}
} else {
}
let mut file = repo.create_file(&path)?;
if entry.header().size().unwrap_or(0) > 0 {
io::copy(&mut entry, &mut file)?;
file.finish()?;
}
}
(EntryType::Directory, _) => {
if let Err(e) = repo.create_dir_all(path) {
if e == zbox::Error::AlreadyExists || e == zbox::Error::IsRoot {
} else {
return Err(VfsAggregateError::ZboxError(e));
}
} else {
}
}
_ => return Err(VfsAggregateError::UnsupportedFileType),
};
Ok(())
})
.collect::<Vec<Result<(), VfsAggregateError>>>();
// let import_errors = errors.iter().filter_map(|e| e.err()).collect::<Vec<_>>();
let vfs = Self {
repo,
device_files: HashMap::new(),
// import_errors: vec![],
};
Ok(vfs)
}
pub fn new() -> Result<(Self, Vec<VfsError>), failure::Error> {
init_env();
let repo = RepoOpener::new()
.create(true)
.open("mem://wasmer_fs", "")
.unwrap();
Ok((
Vfs {
repo,
device_files: HashMap::new(),
},
vec![],
))
}
pub fn open_file<P: AsRef<Path>>(&mut self, path: P) -> Option<Rc<RefCell<dyn FileLike>>> {
init_env();
let path = convert_to_absolute_path(path);
if let Ok(file) = OpenOptions::new().write(true).open(&mut self.repo, &path) {
Some(Rc::new(RefCell::new(VirtualFile::new(file))))
} else if let Some(dev_file) = self.device_files.get(&path) {
Some(dev_file.clone())
} else {
None
}
}
pub fn make_dir<P: AsRef<Path>>(&mut self, path: P) {
self.repo.create_dir_all(path).unwrap();
}
pub fn create_device_file<P: AsRef<Path>>(&mut self, path: P, file: Rc<RefCell<dyn FileLike>>) {
self.device_files.insert(path.as_ref().to_path_buf(), file);
}
}
fn convert_to_absolute_path<P: AsRef<Path>>(path: P) -> PathBuf {
let path = path.as_ref();
if path.is_relative() {
std::path::PathBuf::from("/").join(path)
} else {
path.to_path_buf()
}
}
pub type Handle = i32;
#[derive(Debug, Fail)]
pub enum VfsError {
#[fail(display = "File with file descriptor \"{}\" does not exist.", _0)]
FileWithFileDescriptorNotExist(Handle),
#[fail(display = "File descriptor does not exist.")]
FileDescriptorNotExist(Handle),
#[fail(display = "Source file descriptor does not exist.")]
SourceFileDescriptorDoesNotExist,
#[fail(display = "Target file descriptor already exists.")]
TargetFileDescriptorAlreadyExists,
#[fail(display = "Could not get a mutable reference to the file because it is in use.")]
CouldNotGetMutableReferenceToFile,
}
#[derive(Debug, Fail)]
pub enum VfsAggregateError {
#[fail(display = "Entry error.")]
EntryError(std::io::Error),
#[fail(display = "IO error.")]
IoError(std::io::Error),
#[fail(display = "Zbox error.")]
ZboxError(zbox::Error),
#[fail(display = "Unsupported file type.")]
UnsupportedFileType,
}
impl std::convert::From<std::io::Error> for VfsAggregateError {
fn from(error: std::io::Error) -> VfsAggregateError {
VfsAggregateError::EntryError(error)
}
}
impl std::convert::From<zbox::Error> for VfsAggregateError {
fn from(error: zbox::Error) -> VfsAggregateError {
VfsAggregateError::ZboxError(error)
}
}

View File

@ -1,57 +0,0 @@
/// Represents the version of this header schema.
#[repr(u8)]
#[derive(Debug, PartialEq)]
pub enum HeaderVersion {
Version1 = 1,
}
/// Represents the compression type of the file data. Only Zstd or no-compression is supported.
#[repr(u8)]
#[derive(Debug, PartialEq)]
pub enum CompressionType {
NONE = 0,
ZSTD = 1,
}
/// Represents the type of archive. The only supported archive is the Tar format.
#[repr(u8)]
#[derive(Debug, PartialEq)]
pub enum ArchiveType {
TAR = 0,
}
// extract the header data from bytes
pub fn header_from_bytes(
bytes: &[u8],
) -> Result<(HeaderVersion, CompressionType, ArchiveType), HeaderError> {
if let Some(bytes) = bytes.get(..4) {
let version = match bytes[0] {
1 => HeaderVersion::Version1,
x => return Err(HeaderError::UnknownHeaderVersion(x)),
};
let compression_type = match bytes[1] {
0 => CompressionType::NONE,
1 => CompressionType::ZSTD,
x => return Err(HeaderError::UnknownCompressionType(x)),
};
let archive_type = match bytes[2] {
0 => ArchiveType::TAR,
x => return Err(HeaderError::UnknownArchiveType(x)),
};
Ok((version, compression_type, archive_type))
} else {
Err(HeaderError::HeaderTooSmall)
}
}
#[derive(Debug, Fail)]
pub enum HeaderError {
#[fail(display = "The version is not supported: \"{}\"", _0)]
UnknownHeaderVersion(u8),
#[fail(display = "The compression type is unknown: \"{}\"", _0)]
UnknownCompressionType(u8),
#[fail(display = "The archive type is unknown: \"{}\"", _0)]
UnknownArchiveType(u8),
#[fail(display = "The header is too small.")]
HeaderTooSmall,
}

View File

@ -1,51 +0,0 @@
use crate::vfs::file_like::{FileLike, Metadata};
use failure::Error;
use std::io;
pub struct VirtualFile(zbox::File);
impl VirtualFile {
pub fn new(file: zbox::File) -> Self {
VirtualFile(file)
}
}
impl FileLike for VirtualFile {
fn metadata(&self) -> Result<Metadata, Error> {
self.0
.metadata()
.map(|m| Metadata {
len: m.content_len(),
is_file: m.is_file(),
})
.map_err(|e: zbox::Error| e.into())
}
fn set_file_len(&mut self, len: usize) -> Result<(), failure::Error> {
self.0.set_len(len).map_err(|e| e.into())
}
}
impl io::Write for VirtualFile {
fn write(&mut self, buf: &[u8]) -> Result<usize, io::Error> {
let result = self.0.write(buf)?;
self.0.finish().unwrap();
Ok(result)
}
fn flush(&mut self) -> Result<(), io::Error> {
self.0.flush()
}
}
impl io::Read for VirtualFile {
fn read(&mut self, buf: &mut [u8]) -> Result<usize, io::Error> {
self.0.read(buf)
}
}
impl io::Seek for VirtualFile {
fn seek(&mut self, pos: io::SeekFrom) -> Result<u64, io::Error> {
self.0.seek(pos)
}
}

View File

@ -17,7 +17,6 @@ rand = "0.7"
time = "0.1"
typetag = "0.1"
serde = { version = "1", features = ["derive"] }
# wasmer-runtime-abi = { path = "../runtime-abi" }
wasmer-runtime-core = { path = "../runtime-core", version = "0.7.0" }
[target.'cfg(windows)'.dependencies]