Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions nvx-rs/public-api/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1275,17 +1275,14 @@ enum nvx::host::sandbox::MountAccess
variant nvx::host::sandbox::MountAccess::ReadOnly
variant nvx::host::sandbox::MountAccess::ReadWrite
method nvx::host::sandbox::MountAccess::as_str
method nvx::host::sandbox::MountAccess::from_name
enum nvx::host::sandbox::MountKind
variant nvx::host::sandbox::MountKind::Directory
variant nvx::host::sandbox::MountKind::File
method nvx::host::sandbox::MountKind::as_str
method nvx::host::sandbox::MountKind::from_name
enum nvx::host::sandbox::MountOwner
variant nvx::host::sandbox::MountOwner::Caller
variant nvx::host::sandbox::MountOwner::Vmm
method nvx::host::sandbox::MountOwner::as_str
method nvx::host::sandbox::MountOwner::from_name
struct nvx::host::sandbox::MountPolicy
field nvx::host::sandbox::MountPolicy::allowed
field nvx::host::sandbox::MountPolicy::denied
Expand All @@ -1299,16 +1296,9 @@ variant nvx::host::sandbox::PolicyKind::Writable
method nvx::host::sandbox::PolicyKind::as_str
method nvx::host::sandbox::PolicyKind::option
struct nvx::host::sandbox::SandboxMount
method nvx::host::sandbox::SandboxMount::absolute
method nvx::host::sandbox::SandboxMount::absolute_policy_paths
method nvx::host::sandbox::SandboxMount::access
method nvx::host::sandbox::SandboxMount::guest_target
method nvx::host::sandbox::SandboxMount::host_path
method nvx::host::sandbox::SandboxMount::kind
method nvx::host::sandbox::SandboxMount::new
method nvx::host::sandbox::SandboxMount::owner
method nvx::host::sandbox::SandboxMount::parse
method nvx::host::sandbox::SandboxMount::policy
method nvx::host::sandbox::SandboxMount::validated
method nvx::host::sandbox::SandboxMount::with_kind
mod nvx::host::sandbox::mount
Expand All @@ -1320,17 +1310,14 @@ enum nvx::host::sandbox::mount::MountAccess
variant nvx::host::sandbox::mount::MountAccess::ReadOnly
variant nvx::host::sandbox::mount::MountAccess::ReadWrite
method nvx::host::sandbox::mount::MountAccess::as_str
method nvx::host::sandbox::mount::MountAccess::from_name
enum nvx::host::sandbox::mount::MountKind
variant nvx::host::sandbox::mount::MountKind::Directory
variant nvx::host::sandbox::mount::MountKind::File
method nvx::host::sandbox::mount::MountKind::as_str
method nvx::host::sandbox::mount::MountKind::from_name
enum nvx::host::sandbox::mount::MountOwner
variant nvx::host::sandbox::mount::MountOwner::Caller
variant nvx::host::sandbox::mount::MountOwner::Vmm
method nvx::host::sandbox::mount::MountOwner::as_str
method nvx::host::sandbox::mount::MountOwner::from_name
struct nvx::host::sandbox::mount::MountPolicy
field nvx::host::sandbox::mount::MountPolicy::allowed
field nvx::host::sandbox::mount::MountPolicy::denied
Expand All @@ -1347,16 +1334,9 @@ method nvx::host::sandbox::mount::PolicyKind::option
const nvx::host::sandbox::mount::RESERVED_EXACT_MOUNT_TARGETS
const nvx::host::sandbox::mount::RESERVED_MOUNT_TARGETS
struct nvx::host::sandbox::mount::SandboxMount
method nvx::host::sandbox::mount::SandboxMount::absolute
method nvx::host::sandbox::mount::SandboxMount::absolute_policy_paths
method nvx::host::sandbox::mount::SandboxMount::access
method nvx::host::sandbox::mount::SandboxMount::guest_target
method nvx::host::sandbox::mount::SandboxMount::host_path
method nvx::host::sandbox::mount::SandboxMount::kind
method nvx::host::sandbox::mount::SandboxMount::new
method nvx::host::sandbox::mount::SandboxMount::owner
method nvx::host::sandbox::mount::SandboxMount::parse
method nvx::host::sandbox::mount::SandboxMount::policy
method nvx::host::sandbox::mount::SandboxMount::validated
method nvx::host::sandbox::mount::SandboxMount::with_kind
fn nvx::host::sandbox::mount::mount_kind
Expand Down Expand Up @@ -1397,7 +1377,6 @@ field nvx::host::sandbox::options::SandboxOptions::mounts
field nvx::host::sandbox::options::SandboxOptions::net
field nvx::host::sandbox::options::SandboxOptions::network_options
field nvx::host::sandbox::options::SandboxOptions::network_profile
method nvx::host::sandbox::options::SandboxOptions::new
field nvx::host::sandbox::options::SandboxOptions::operation
field nvx::host::sandbox::options::SandboxOptions::outcome_report
field nvx::host::sandbox::options::SandboxOptions::policy_paths
Expand Down
21 changes: 0 additions & 21 deletions nvx-rs/public-api/windows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -733,17 +733,14 @@ enum nvx::host::sandbox::MountAccess
variant nvx::host::sandbox::MountAccess::ReadOnly
variant nvx::host::sandbox::MountAccess::ReadWrite
method nvx::host::sandbox::MountAccess::as_str
method nvx::host::sandbox::MountAccess::from_name
enum nvx::host::sandbox::MountKind
variant nvx::host::sandbox::MountKind::Directory
variant nvx::host::sandbox::MountKind::File
method nvx::host::sandbox::MountKind::as_str
method nvx::host::sandbox::MountKind::from_name
enum nvx::host::sandbox::MountOwner
variant nvx::host::sandbox::MountOwner::Caller
variant nvx::host::sandbox::MountOwner::Vmm
method nvx::host::sandbox::MountOwner::as_str
method nvx::host::sandbox::MountOwner::from_name
struct nvx::host::sandbox::MountPolicy
field nvx::host::sandbox::MountPolicy::allowed
field nvx::host::sandbox::MountPolicy::denied
Expand All @@ -757,16 +754,9 @@ variant nvx::host::sandbox::PolicyKind::Writable
method nvx::host::sandbox::PolicyKind::as_str
method nvx::host::sandbox::PolicyKind::option
struct nvx::host::sandbox::SandboxMount
method nvx::host::sandbox::SandboxMount::absolute
method nvx::host::sandbox::SandboxMount::absolute_policy_paths
method nvx::host::sandbox::SandboxMount::access
method nvx::host::sandbox::SandboxMount::guest_target
method nvx::host::sandbox::SandboxMount::host_path
method nvx::host::sandbox::SandboxMount::kind
method nvx::host::sandbox::SandboxMount::new
method nvx::host::sandbox::SandboxMount::owner
method nvx::host::sandbox::SandboxMount::parse
method nvx::host::sandbox::SandboxMount::policy
method nvx::host::sandbox::SandboxMount::validated
method nvx::host::sandbox::SandboxMount::with_kind
mod nvx::host::sandbox::mount
Expand All @@ -778,17 +768,14 @@ enum nvx::host::sandbox::mount::MountAccess
variant nvx::host::sandbox::mount::MountAccess::ReadOnly
variant nvx::host::sandbox::mount::MountAccess::ReadWrite
method nvx::host::sandbox::mount::MountAccess::as_str
method nvx::host::sandbox::mount::MountAccess::from_name
enum nvx::host::sandbox::mount::MountKind
variant nvx::host::sandbox::mount::MountKind::Directory
variant nvx::host::sandbox::mount::MountKind::File
method nvx::host::sandbox::mount::MountKind::as_str
method nvx::host::sandbox::mount::MountKind::from_name
enum nvx::host::sandbox::mount::MountOwner
variant nvx::host::sandbox::mount::MountOwner::Caller
variant nvx::host::sandbox::mount::MountOwner::Vmm
method nvx::host::sandbox::mount::MountOwner::as_str
method nvx::host::sandbox::mount::MountOwner::from_name
struct nvx::host::sandbox::mount::MountPolicy
field nvx::host::sandbox::mount::MountPolicy::allowed
field nvx::host::sandbox::mount::MountPolicy::denied
Expand All @@ -805,16 +792,9 @@ method nvx::host::sandbox::mount::PolicyKind::option
const nvx::host::sandbox::mount::RESERVED_EXACT_MOUNT_TARGETS
const nvx::host::sandbox::mount::RESERVED_MOUNT_TARGETS
struct nvx::host::sandbox::mount::SandboxMount
method nvx::host::sandbox::mount::SandboxMount::absolute
method nvx::host::sandbox::mount::SandboxMount::absolute_policy_paths
method nvx::host::sandbox::mount::SandboxMount::access
method nvx::host::sandbox::mount::SandboxMount::guest_target
method nvx::host::sandbox::mount::SandboxMount::host_path
method nvx::host::sandbox::mount::SandboxMount::kind
method nvx::host::sandbox::mount::SandboxMount::new
method nvx::host::sandbox::mount::SandboxMount::owner
method nvx::host::sandbox::mount::SandboxMount::parse
method nvx::host::sandbox::mount::SandboxMount::policy
method nvx::host::sandbox::mount::SandboxMount::validated
method nvx::host::sandbox::mount::SandboxMount::with_kind
fn nvx::host::sandbox::mount::mount_kind
Expand Down Expand Up @@ -855,7 +835,6 @@ field nvx::host::sandbox::options::SandboxOptions::mounts
field nvx::host::sandbox::options::SandboxOptions::net
field nvx::host::sandbox::options::SandboxOptions::network_options
field nvx::host::sandbox::options::SandboxOptions::network_profile
method nvx::host::sandbox::options::SandboxOptions::new
field nvx::host::sandbox::options::SandboxOptions::operation
field nvx::host::sandbox::options::SandboxOptions::outcome_report
field nvx::host::sandbox::options::SandboxOptions::policy_paths
Expand Down
4 changes: 3 additions & 1 deletion nvx-rs/src/host/sandbox/mount/aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ use crate::host::sandbox::refused;
/// finds to be of the other kind is refused, as [`SandboxMount::validated`] refuses it. Returns
/// `None` without shares.
///
/// Fails as those checks, [`SandboxMount::absolute`], and [`filesystem::plan`] do.
/// Fails as those checks and [`filesystem::plan`] do, and with
/// [`ErrorKind::Io`](crate::ErrorKind::Io) if a relative host path meets an unreadable current
/// directory, or Windows cannot qualify a drive-relative path.
pub fn plan_mounts(mounts: &[SandboxMount]) -> Result<Option<ExportPlan>> {
validate_mounts(mounts)?;
for mount in mounts {
Expand Down
51 changes: 0 additions & 51 deletions nvx-rs/src/host/sandbox/mount/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ mod request;

use std::fmt;

use super::refused;
use crate::error::Result;

pub use crate::protocol::share::{RESERVED_EXACT_MOUNT_TARGETS, RESERVED_MOUNT_TARGETS};

pub use self::aggregate::plan_mounts;
Expand Down Expand Up @@ -74,18 +71,6 @@ impl MountAccess {
Self::ReadWrite => "rw",
}
}

/// Returns the mode that `name` names, as a recorded share gives it.
///
/// Fails with [`ErrorKind::Unsupported`](crate::ErrorKind::Unsupported) for another name.
pub fn from_name(name: &str) -> Result<Self> {
setting_from_name(
"mode",
[Self::ReadOnly, Self::ReadWrite],
Self::as_str,
name,
)
}
}

impl fmt::Display for MountAccess {
Expand All @@ -112,13 +97,6 @@ impl MountOwner {
Self::Caller => "caller",
}
}

/// Returns the owner that `name` names, as a recorded share gives it.
///
/// Fails with [`ErrorKind::Unsupported`](crate::ErrorKind::Unsupported) for another name.
pub fn from_name(name: &str) -> Result<Self> {
setting_from_name("owner", [Self::Vmm, Self::Caller], Self::as_str, name)
}
}

impl fmt::Display for MountOwner {
Expand All @@ -145,13 +123,6 @@ impl MountKind {
Self::File => "file",
}
}

/// Returns the kind that `name` names, as a recorded share gives it.
///
/// Fails with [`ErrorKind::Unsupported`](crate::ErrorKind::Unsupported) for another name.
pub fn from_name(name: &str) -> Result<Self> {
setting_from_name("kind", [Self::Directory, Self::File], Self::as_str, name)
}
}

impl fmt::Display for MountKind {
Expand All @@ -160,28 +131,6 @@ impl fmt::Display for MountKind {
}
}

/// Returns the one of `values`, the two values of a share's `setting`, whose name, as `as_str`
/// gives it, is `name`, as a recorded share gives it.
///
/// Fails with [`ErrorKind::Unsupported`](crate::ErrorKind::Unsupported) for another name, with a
/// message that names the setting and its two values.
fn setting_from_name<T: Copy>(
setting: &str,
values: [T; 2],
as_str: fn(T) -> &'static str,
name: &str,
) -> Result<T> {
values
.into_iter()
.find(|&value| as_str(value) == name)
.ok_or_else(|| {
let [first, second] = values.map(as_str);
refused(format!(
"unsupported sandbox mount {setting} {name:?}; choose {first} or {second}",
))
})
}

/// A kind of access-policy path.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum PolicyKind {
Expand Down
51 changes: 8 additions & 43 deletions nvx-rs/src/host/sandbox/mount/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,36 +272,11 @@ impl SandboxMount {
})
}

/// Returns the guest target.
pub fn guest_target(&self) -> &str {
&self.guest_target
}

/// Returns the host directory or file.
pub fn host_path(&self) -> &Path {
&self.host_path
}

/// Returns the access mode.
pub fn access(&self) -> MountAccess {
self.access
}

/// Returns the access-policy paths.
pub fn policy(&self) -> &MountPolicy {
&self.policy
}

/// Returns the identity of the share's file operations.
pub fn owner(&self) -> MountOwner {
self.owner
}

/// Returns whether the share binds a directory or a file.
pub fn kind(&self) -> MountKind {
self.kind
}

/// Checks the share against the host: its owner must be one that the host supports, its
/// host path must be a regular file or a plain directory, as its kind requires, without
/// being a symbolic link, which on Windows includes a junction, as [`Path::is_symlink`] tells
Expand Down Expand Up @@ -352,18 +327,14 @@ impl SandboxMount {
}

/// Returns the share with its host path made absolute, as the one function of NVX that makes
/// host paths absolute makes it: joined to the current directory if it is relative, without
/// resolving it, so OpenVMM still sees, and refuses, every symbolic-link component of the
/// path that was requested. On Windows, a path with another drive and no root, such as
/// `D:relative`, is below the current directory of its drive.
/// host paths absolute makes it, with `cwd` as the current directory: joined to the current
/// directory if it is relative, without resolving it, so OpenVMM still sees, and refuses,
/// every symbolic-link component of the path that was requested. On Windows, a path with
/// another drive and no root, such as `D:relative`, is below the current directory of its
/// drive.
///
/// Fails with [`ErrorKind::Io`](crate::ErrorKind::Io) if a relative host path meets an
/// unreadable current directory, or Windows cannot qualify a drive-relative path.
pub fn absolute(&self) -> Result<Self> {
self.absolute_with(&paths::current_dir)
}

/// Implements [`absolute`](Self::absolute) with `cwd` as the current directory.
pub(crate) fn absolute_with(&self, cwd: &dyn Fn() -> io::Result<PathBuf>) -> Result<Self> {
if self.host_path.is_absolute() {
return Ok(self.clone());
Expand All @@ -376,16 +347,10 @@ impl SandboxMount {
}

/// Returns each kind of access-policy path with its requested paths, relative paths joined
/// to the absolute host path of the share, as OpenVMM attributes them to the children of an
/// aggregate.
/// to the absolute host path of the share, with `cwd` as the current directory, as OpenVMM
/// attributes them to the children of an aggregate.
///
/// Fails as [`absolute`](Self::absolute) does.
pub fn absolute_policy_paths(&self) -> Result<Vec<(PolicyKind, Vec<String>)>> {
self.absolute_policy_paths_with(&paths::current_dir)
}

/// Implements [`absolute_policy_paths`](Self::absolute_policy_paths) with `cwd` as the
/// current directory.
/// Fails as [`absolute_with`](Self::absolute_with) does.
pub(crate) fn absolute_policy_paths_with(
&self,
cwd: &dyn Fn() -> io::Result<PathBuf>,
Expand Down
Loading
Loading