guess i forgot a lot of these that dont build on linux

This commit is contained in:
Pat Hickey
2020-08-18 15:01:04 -07:00
parent 0e1c534e07
commit 73aef4c6ca
12 changed files with 44 additions and 44 deletions

2
Cargo.lock generated
View File

@@ -2804,7 +2804,7 @@ dependencies = [
"cfg-if", "cfg-if",
"filetime", "filetime",
"libc", "libc",
"log", "tracing",
] ]
[[package]] [[package]]

View File

@@ -36,7 +36,7 @@ pub(crate) fn path_unlink_file(resolved: PathGet) -> WasiResult<()> {
} }
} }
Err(err) => { Err(err) => {
log::debug!("path_unlink_file fstatat error: {:?}", err); tracing::debug!("path_unlink_file fstatat error: {:?}", err);
} }
} }
} }
@@ -50,8 +50,8 @@ pub(crate) fn path_unlink_file(resolved: PathGet) -> WasiResult<()> {
pub(crate) fn path_symlink(old_path: &str, resolved: PathGet) -> WasiResult<()> { pub(crate) fn path_symlink(old_path: &str, resolved: PathGet) -> WasiResult<()> {
use yanix::file::{fstatat, symlinkat, AtFlags}; use yanix::file::{fstatat, symlinkat, AtFlags};
log::debug!("path_symlink old_path = {:?}", old_path); tracing::debug!("path_symlink old_path = {:?}", old_path);
log::debug!("path_symlink resolved = {:?}", resolved); tracing::debug!("path_symlink resolved = {:?}", resolved);
match unsafe { symlinkat(old_path, resolved.dirfd().as_raw_fd(), resolved.path()) } { match unsafe { symlinkat(old_path, resolved.dirfd().as_raw_fd(), resolved.path()) } {
Err(err) => { Err(err) => {
@@ -71,7 +71,7 @@ pub(crate) fn path_symlink(old_path: &str, resolved: PathGet) -> WasiResult<()>
} { } {
Ok(_) => return Err(WasiError::EEXIST), Ok(_) => return Err(WasiError::EEXIST),
Err(err) => { Err(err) => {
log::debug!("path_symlink fstatat error: {:?}", err); tracing::debug!("path_symlink fstatat error: {:?}", err);
} }
} }
} }
@@ -119,7 +119,7 @@ pub(crate) fn path_rename(resolved_old: PathGet, resolved_new: PathGet) -> WasiR
} }
} }
Err(err) => { Err(err) => {
log::debug!("path_rename fstatat error: {:?}", err); tracing::debug!("path_rename fstatat error: {:?}", err);
} }
} }
} }

View File

@@ -43,12 +43,12 @@ impl From<io::Error> for WasiError {
winerror::ERROR_DIRECTORY => Self::ENOTDIR, winerror::ERROR_DIRECTORY => Self::ENOTDIR,
winerror::ERROR_ALREADY_EXISTS => Self::EEXIST, winerror::ERROR_ALREADY_EXISTS => Self::EEXIST,
x => { x => {
log::debug!("unknown error value: {}", x); tracing::debug!("unknown error value: {}", x);
Self::EIO Self::EIO
} }
}, },
None => { None => {
log::debug!("Other I/O error: {}", err); tracing::debug!("Other I/O error: {}", err);
Self::EIO Self::EIO
} }
} }

View File

@@ -9,13 +9,13 @@ use crate::old::snapshot_0::sys::entry_impl::determine_type_rights;
use crate::old::snapshot_0::sys::host_impl::{self, path_from_host}; use crate::old::snapshot_0::sys::host_impl::{self, path_from_host};
use crate::old::snapshot_0::sys::hostcalls_impl::fs_helpers::PathGetExt; use crate::old::snapshot_0::sys::hostcalls_impl::fs_helpers::PathGetExt;
use crate::old::snapshot_0::wasi::{self, WasiError, WasiResult}; use crate::old::snapshot_0::wasi::{self, WasiError, WasiResult};
use log::{debug, trace};
use std::convert::TryInto; use std::convert::TryInto;
use std::fs::{File, Metadata, OpenOptions}; use std::fs::{File, Metadata, OpenOptions};
use std::io::{self, Seek, SeekFrom}; use std::io::{self, Seek, SeekFrom};
use std::os::windows::fs::{FileExt, OpenOptionsExt}; use std::os::windows::fs::{FileExt, OpenOptionsExt};
use std::os::windows::prelude::{AsRawHandle, FromRawHandle}; use std::os::windows::prelude::{AsRawHandle, FromRawHandle};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use tracing::{debug, trace};
use winapi::shared::winerror; use winapi::shared::winerror;
use winx::file::{AccessMode, CreationDisposition, FileModeInformation, Flags}; use winx::file::{AccessMode, CreationDisposition, FileModeInformation, Flags};
@@ -156,7 +156,7 @@ pub(crate) fn path_open(
} }
Err(err) => match err.raw_os_error() { Err(err) => match err.raw_os_error() {
Some(code) => { Some(code) => {
log::debug!("path_open at symlink_metadata error code={:?}", code); tracing::debug!("path_open at symlink_metadata error code={:?}", code);
if code as u32 != winerror::ERROR_FILE_NOT_FOUND { if code as u32 != winerror::ERROR_FILE_NOT_FOUND {
return Err(err.into()); return Err(err.into());
@@ -165,7 +165,7 @@ pub(crate) fn path_open(
// trying to open it // trying to open it
} }
None => { None => {
log::debug!("Inconvertible OS error: {}", err); tracing::debug!("Inconvertible OS error: {}", err);
return Err(WasiError::EIO); return Err(WasiError::EIO);
} }
}, },
@@ -397,7 +397,7 @@ pub(crate) fn path_rename(resolved_old: PathGet, resolved_new: PathGet) -> WasiR
}; };
match err.raw_os_error() { match err.raw_os_error() {
Some(code) => { Some(code) => {
log::debug!("path_rename at rename error code={:?}", code); tracing::debug!("path_rename at rename error code={:?}", code);
match code as u32 { match code as u32 {
winerror::ERROR_ACCESS_DENIED => { winerror::ERROR_ACCESS_DENIED => {
// So most likely dealing with new_path == dir. // So most likely dealing with new_path == dir.
@@ -427,7 +427,7 @@ pub(crate) fn path_rename(resolved_old: PathGet, resolved_new: PathGet) -> WasiR
Err(err.into()) Err(err.into())
} }
None => { None => {
log::debug!("Inconvertible OS error: {}", err); tracing::debug!("Inconvertible OS error: {}", err);
Err(WasiError::EIO) Err(WasiError::EIO)
} }
} }
@@ -474,7 +474,7 @@ pub(crate) fn path_symlink(old_path: &str, resolved: PathGet) -> WasiResult<()>
}; };
match err.raw_os_error() { match err.raw_os_error() {
Some(code) => { Some(code) => {
log::debug!("path_symlink at symlink_file error code={:?}", code); tracing::debug!("path_symlink at symlink_file error code={:?}", code);
match code as u32 { match code as u32 {
winerror::ERROR_NOT_A_REPARSE_POINT => { winerror::ERROR_NOT_A_REPARSE_POINT => {
// try creating a dir symlink instead // try creating a dir symlink instead
@@ -500,7 +500,7 @@ pub(crate) fn path_symlink(old_path: &str, resolved: PathGet) -> WasiResult<()>
Err(err.into()) Err(err.into())
} }
None => { None => {
log::debug!("Inconvertible OS error: {}", err); tracing::debug!("Inconvertible OS error: {}", err);
Err(WasiError::EIO) Err(WasiError::EIO)
} }
} }
@@ -526,7 +526,7 @@ pub(crate) fn path_unlink_file(resolved: PathGet) -> WasiResult<()> {
}; };
match err.raw_os_error() { match err.raw_os_error() {
Some(code) => { Some(code) => {
log::debug!("path_unlink_file at symlink_file error code={:?}", code); tracing::debug!("path_unlink_file at symlink_file error code={:?}", code);
if code as u32 == winerror::ERROR_ACCESS_DENIED { if code as u32 == winerror::ERROR_ACCESS_DENIED {
// try unlinking a dir symlink instead // try unlinking a dir symlink instead
return fs::remove_dir(path).map_err(Into::into); return fs::remove_dir(path).map_err(Into::into);
@@ -535,7 +535,7 @@ pub(crate) fn path_unlink_file(resolved: PathGet) -> WasiResult<()> {
Err(err.into()) Err(err.into())
} }
None => { None => {
log::debug!("Inconvertible OS error: {}", err); tracing::debug!("Inconvertible OS error: {}", err);
Err(WasiError::EIO) Err(WasiError::EIO)
} }
} }

View File

@@ -61,7 +61,7 @@ pub(crate) fn openat(dirfd: &File, path: &str) -> WasiResult<File> {
Err(e) => e, Err(e) => e,
}; };
if let Some(code) = err.raw_os_error() { if let Some(code) = err.raw_os_error() {
log::debug!("openat error={:?}", code); tracing::debug!("openat error={:?}", code);
if code as u32 == winerror::ERROR_INVALID_NAME { if code as u32 == winerror::ERROR_INVALID_NAME {
return Err(WasiError::ENOTDIR); return Err(WasiError::ENOTDIR);
} }
@@ -90,7 +90,7 @@ pub(crate) fn readlinkat(dirfd: &File, s_path: &str) -> WasiResult<String> {
Err(e) => e, Err(e) => e,
}; };
if let Some(code) = err.raw_os_error() { if let Some(code) = err.raw_os_error() {
log::debug!("readlinkat error={:?}", code); tracing::debug!("readlinkat error={:?}", code);
if code as u32 == winerror::ERROR_INVALID_NAME { if code as u32 == winerror::ERROR_INVALID_NAME {
if s_path.ends_with('/') { if s_path.ends_with('/') {
// strip "/" and check if exists // strip "/" and check if exists
@@ -130,7 +130,7 @@ pub(crate) fn concatenate<P: AsRef<Path>>(dirfd: &File, path: P) -> WasiResult<P
// components with `out_path` // components with `out_path`
let out_path = PathBuf::from(strip_extended_prefix(out_path)); let out_path = PathBuf::from(strip_extended_prefix(out_path));
log::debug!("out_path={:?}", out_path); tracing::debug!("out_path={:?}", out_path);
Ok(out_path) Ok(out_path)
} }

View File

@@ -24,7 +24,7 @@ pub(crate) fn unlink_file(dirfd: &OsDir, path: &str) -> Result<()> {
} }
} }
Err(err) => { Err(err) => {
log::debug!("path_unlink_file fstatat error: {:?}", err); tracing::debug!("path_unlink_file fstatat error: {:?}", err);
} }
} }
} }
@@ -38,8 +38,8 @@ pub(crate) fn unlink_file(dirfd: &OsDir, path: &str) -> Result<()> {
pub(crate) fn symlink(old_path: &str, new_dirfd: &OsDir, new_path: &str) -> Result<()> { pub(crate) fn symlink(old_path: &str, new_dirfd: &OsDir, new_path: &str) -> Result<()> {
use yanix::file::{fstatat, symlinkat, AtFlags}; use yanix::file::{fstatat, symlinkat, AtFlags};
log::debug!("path_symlink old_path = {:?}", old_path); tracing::debug!("path_symlink old_path = {:?}", old_path);
log::debug!( tracing::debug!(
"path_symlink (new_dirfd, new_path) = ({:?}, {:?})", "path_symlink (new_dirfd, new_path) = ({:?}, {:?})",
new_dirfd, new_dirfd,
new_path new_path
@@ -58,7 +58,7 @@ pub(crate) fn symlink(old_path: &str, new_dirfd: &OsDir, new_path: &str) -> Resu
{ {
Ok(_) => return Err(Errno::Exist), Ok(_) => return Err(Errno::Exist),
Err(err) => { Err(err) => {
log::debug!("path_symlink fstatat error: {:?}", err); tracing::debug!("path_symlink fstatat error: {:?}", err);
} }
} }
} }
@@ -106,7 +106,7 @@ pub(crate) fn rename(
} }
} }
Err(err) => { Err(err) => {
log::debug!("path_rename fstatat error: {:?}", err); tracing::debug!("path_rename fstatat error: {:?}", err);
} }
} }
} }

View File

@@ -5,12 +5,12 @@ use crate::sys::osdir::OsDir;
use crate::sys::osfile::OsFile; use crate::sys::osfile::OsFile;
use crate::sys::AsFile; use crate::sys::AsFile;
use crate::wasi::{types, Result}; use crate::wasi::{types, Result};
use log::trace;
use std::convert::TryInto; use std::convert::TryInto;
use std::fs::{File, OpenOptions}; use std::fs::{File, OpenOptions};
use std::os::windows::fs::OpenOptionsExt; use std::os::windows::fs::OpenOptionsExt;
use std::os::windows::prelude::{AsRawHandle, FromRawHandle}; use std::os::windows::prelude::{AsRawHandle, FromRawHandle};
use std::path::Path; use std::path::Path;
use tracing::trace;
use winx::file::{AccessMode, FileModeInformation, Flags}; use winx::file::{AccessMode, FileModeInformation, Flags};
pub(crate) fn fdstat_get(file: &File) -> Result<types::Fdflags> { pub(crate) fn fdstat_get(file: &File) -> Result<types::Fdflags> {

View File

@@ -134,12 +134,12 @@ impl From<io::Error> for Errno {
winerror::ERROR_DIRECTORY => Self::Notdir, winerror::ERROR_DIRECTORY => Self::Notdir,
winerror::ERROR_ALREADY_EXISTS => Self::Exist, winerror::ERROR_ALREADY_EXISTS => Self::Exist,
x => { x => {
log::debug!("winerror: unknown error value: {}", x); tracing::debug!("winerror: unknown error value: {}", x);
Self::Io Self::Io
} }
}, },
None => { None => {
log::debug!("Other I/O error: {}", err); tracing::debug!("Other I/O error: {}", err);
Self::Io Self::Io
} }
} }

View File

@@ -46,7 +46,7 @@ fn concatenate<P: AsRef<Path>>(file: &OsDir, path: P) -> Result<PathBuf> {
// components with `out_path` // components with `out_path`
let out_path = PathBuf::from(strip_extended_prefix(out_path)); let out_path = PathBuf::from(strip_extended_prefix(out_path));
log::debug!("out_path={:?}", out_path); tracing::debug!("out_path={:?}", out_path);
Ok(out_path) Ok(out_path)
} }
@@ -138,7 +138,7 @@ pub(crate) fn readlinkat(dirfd: &OsDir, s_path: &str) -> Result<String> {
Err(e) => e, Err(e) => e,
}; };
if let Some(code) = err.raw_os_error() { if let Some(code) = err.raw_os_error() {
log::debug!("readlinkat error={:?}", code); tracing::debug!("readlinkat error={:?}", code);
if code as u32 == winerror::ERROR_INVALID_NAME { if code as u32 == winerror::ERROR_INVALID_NAME {
if s_path.ends_with('/') { if s_path.ends_with('/') {
// strip "/" and check if exists // strip "/" and check if exists
@@ -170,7 +170,7 @@ pub(crate) fn link(
let new_path = concatenate(new_dirfd, new_path)?; let new_path = concatenate(new_dirfd, new_path)?;
if follow_symlinks { if follow_symlinks {
// in particular, this will return an error if the target path doesn't exist // in particular, this will return an error if the target path doesn't exist
log::debug!("Following symlinks for path: {:?}", old_path); tracing::debug!("Following symlinks for path: {:?}", old_path);
old_path = fs::canonicalize(&old_path).map_err(|e| match e.raw_os_error() { old_path = fs::canonicalize(&old_path).map_err(|e| match e.raw_os_error() {
// fs::canonicalize under Windows will return: // fs::canonicalize under Windows will return:
// * ERROR_FILE_NOT_FOUND, if it encounters a dangling symlink // * ERROR_FILE_NOT_FOUND, if it encounters a dangling symlink
@@ -184,7 +184,7 @@ pub(crate) fn link(
Err(e) => e, Err(e) => e,
}; };
if let Some(code) = err.raw_os_error() { if let Some(code) = err.raw_os_error() {
log::debug!("path_link at fs::hard_link error code={:?}", code); tracing::debug!("path_link at fs::hard_link error code={:?}", code);
if code as u32 == winerror::ERROR_ACCESS_DENIED { if code as u32 == winerror::ERROR_ACCESS_DENIED {
// If an attempt is made to create a hard link to a directory, POSIX-compliant // If an attempt is made to create a hard link to a directory, POSIX-compliant
// implementations of link return `EPERM`, but `ERROR_ACCESS_DENIED` is converted // implementations of link return `EPERM`, but `ERROR_ACCESS_DENIED` is converted
@@ -248,7 +248,7 @@ pub(crate) fn open(
} }
Err(err) => match err.raw_os_error() { Err(err) => match err.raw_os_error() {
Some(code) => { Some(code) => {
log::debug!("path_open at symlink_metadata error code={:?}", code); tracing::debug!("path_open at symlink_metadata error code={:?}", code);
match code as u32 { match code as u32 {
winerror::ERROR_FILE_NOT_FOUND => { winerror::ERROR_FILE_NOT_FOUND => {
// file not found, let it proceed to actually // file not found, let it proceed to actually
@@ -263,7 +263,7 @@ pub(crate) fn open(
}; };
} }
None => { None => {
log::debug!("Inconvertible OS error: {}", err); tracing::debug!("Inconvertible OS error: {}", err);
return Err(Errno::Io); return Err(Errno::Io);
} }
}, },
@@ -353,7 +353,7 @@ pub(crate) fn rename(
}; };
match err.raw_os_error() { match err.raw_os_error() {
Some(code) => { Some(code) => {
log::debug!("path_rename at rename error code={:?}", code); tracing::debug!("path_rename at rename error code={:?}", code);
match code as u32 { match code as u32 {
winerror::ERROR_ACCESS_DENIED => { winerror::ERROR_ACCESS_DENIED => {
// So most likely dealing with new_path == dir. // So most likely dealing with new_path == dir.
@@ -385,7 +385,7 @@ pub(crate) fn rename(
Err(err.into()) Err(err.into())
} }
None => { None => {
log::debug!("Inconvertible OS error: {}", err); tracing::debug!("Inconvertible OS error: {}", err);
Err(Errno::Io) Err(Errno::Io)
} }
} }
@@ -417,7 +417,7 @@ pub(crate) fn symlink(old_path: &str, new_dirfd: &OsDir, new_path_: &str) -> Res
}; };
match err.raw_os_error() { match err.raw_os_error() {
Some(code) => { Some(code) => {
log::debug!("path_symlink at symlink_file error code={:?}", code); tracing::debug!("path_symlink at symlink_file error code={:?}", code);
match code as u32 { match code as u32 {
// If the target contains a trailing slash, the Windows API returns // If the target contains a trailing slash, the Windows API returns
// ERROR_INVALID_NAME (which corresponds to ENOENT) instead of // ERROR_INVALID_NAME (which corresponds to ENOENT) instead of
@@ -442,7 +442,7 @@ pub(crate) fn symlink(old_path: &str, new_dirfd: &OsDir, new_path_: &str) -> Res
Err(err.into()) Err(err.into())
} }
None => { None => {
log::debug!("Inconvertible OS error: {}", err); tracing::debug!("Inconvertible OS error: {}", err);
Err(Errno::Io) Err(Errno::Io)
} }
} }
@@ -468,7 +468,7 @@ pub(crate) fn unlink_file(dirfd: &OsDir, path: &str) -> Result<()> {
}; };
match err.raw_os_error() { match err.raw_os_error() {
Some(code) => { Some(code) => {
log::debug!("path_unlink_file at symlink_file error code={:?}", code); tracing::debug!("path_unlink_file at symlink_file error code={:?}", code);
if code as u32 == winerror::ERROR_ACCESS_DENIED { if code as u32 == winerror::ERROR_ACCESS_DENIED {
// try unlinking a dir symlink instead // try unlinking a dir symlink instead
return fs::remove_dir(path).map_err(Into::into); return fs::remove_dir(path).map_err(Into::into);
@@ -477,7 +477,7 @@ pub(crate) fn unlink_file(dirfd: &OsDir, path: &str) -> Result<()> {
Err(err.into()) Err(err.into())
} }
None => { None => {
log::debug!("Inconvertible OS error: {}", err); tracing::debug!("Inconvertible OS error: {}", err);
Err(Errno::Io) Err(Errno::Io)
} }
} }

View File

@@ -7,12 +7,12 @@ use crate::sys::stdio::{Stderr, Stdin, Stdout};
use crate::sys::AsFile; use crate::sys::AsFile;
use crate::wasi::{types, Errno, Result}; use crate::wasi::{types, Errno, Result};
use lazy_static::lazy_static; use lazy_static::lazy_static;
use log::{debug, error, trace, warn};
use std::convert::TryInto; use std::convert::TryInto;
use std::sync::mpsc::{self, Receiver, RecvTimeoutError, Sender, TryRecvError}; use std::sync::mpsc::{self, Receiver, RecvTimeoutError, Sender, TryRecvError};
use std::sync::Mutex; use std::sync::Mutex;
use std::thread; use std::thread;
use std::time::Duration; use std::time::Duration;
use tracing::{debug, error, trace, warn};
struct StdinPoll { struct StdinPoll {
request_tx: Sender<()>, request_tx: Sender<()>,
@@ -241,7 +241,7 @@ pub(crate) fn oneoff(
handle_error_event(event, Errno::Notsup, events); handle_error_event(event, Errno::Notsup, events);
} }
} else { } else {
log::error!("can poll FdEvent for OS resources only"); tracing::error!("can poll FdEvent for OS resources only");
return Err(Errno::Badf); return Err(Errno::Badf);
} }
} }

View File

@@ -9,7 +9,7 @@ repository = "https://github.com/bytecodealliance/wasmtime"
edition = "2018" edition = "2018"
[dependencies] [dependencies]
log = "0.4" tracing = "0.1.15"
libc = { version = "0.2", features = ["extra_traits"] } libc = { version = "0.2", features = ["extra_traits"] }
bitflags = "1.2" bitflags = "1.2"
cfg-if = "0.1.9" cfg-if = "0.1.9"

View File

@@ -25,7 +25,7 @@ impl FileTimeExt for filetime::FileTime {
let sec = match self.seconds().try_into() { let sec = match self.seconds().try_into() {
Ok(sec) => sec, Ok(sec) => sec,
Err(_) => { Err(_) => {
log::debug!("filetime_to_timespec failed converting seconds to required width"); tracing::debug!("filetime_to_timespec failed converting seconds to required width");
return Err(Error::from_raw_os_error(libc::EOVERFLOW)); return Err(Error::from_raw_os_error(libc::EOVERFLOW));
} }
}; };