MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / podman_user_mounts

Function podman_user_mounts

crates/openshell-driver-podman/src/container.rs:527–626  ·  view source on GitHub ↗
(
    sandbox: &DriverSandbox,
    enable_bind_mounts: bool,
)

Source from the content-addressed store, hash-verified

525}
526
527fn podman_user_mounts(
528 sandbox: &DriverSandbox,
529 enable_bind_mounts: bool,
530) -> Result<PodmanUserMounts, String> {
531 let template = sandbox
532 .spec
533 .as_ref()
534 .and_then(|spec| spec.template.as_ref());
535 let Some(template) = template else {
536 return Ok(PodmanUserMounts::default());
537 };
538 let config = podman_driver_config(template, enable_bind_mounts)?;
539 let mut result = PodmanUserMounts::default();
540 for mount in config.mounts {
541 match mount {
542 PodmanDriverMountConfig::Bind {
543 source,
544 target,
545 read_only,
546 selinux_label,
547 } => {
548 let mut options = vec![
549 if read_only { "ro" } else { "rw" }.to_string(),
550 "rbind".to_string(),
551 ];
552 match selinux_label {
553 Some(SelinuxLabel::Shared) => options.push("z".to_string()),
554 Some(SelinuxLabel::Private) => options.push("Z".to_string()),
555 None => {}
556 }
557 driver_mounts::validate_absolute_mount_source(&source, "bind source")?;
558 driver_mounts::validate_container_mount_target(&target)?;
559 result.mounts.push(Mount {
560 kind: "bind".into(),
561 source,
562 destination: driver_mounts::normalize_mount_target(&target),
563 options,
564 });
565 }
566 PodmanDriverMountConfig::Volume {
567 source,
568 target,
569 read_only,
570 subpath,
571 } => {
572 reject_subpath(subpath.as_deref(), "podman volume mounts")?;
573 driver_mounts::validate_mount_source(&source, "volume source")?;
574 driver_mounts::validate_container_mount_target(&target)?;
575 result.volumes.push(NamedVolume {
576 name: source,
577 dest: target,
578 options: vec![if read_only { "ro" } else { "rw" }.to_string()],
579 });
580 }
581 PodmanDriverMountConfig::Tmpfs {
582 target,
583 options,
584 size_bytes,

Calls 11

podman_driver_configFunction · 0.85
normalize_mount_targetFunction · 0.85
reject_subpathFunction · 0.85
validate_mount_sourceFunction · 0.85
validate_tmpfs_optionsFunction · 0.85
pushMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected