1
0
mirror of https://github.com/containers/youki synced 2024-09-20 10:54:22 +02:00

add handling when mount_label is not present.

This commit is contained in:
utam0k 2021-08-05 23:06:14 +09:00 committed by Sascha Grunert
parent 74af5f88f4
commit 92ac22ae13
No known key found for this signature in database
GPG Key ID: 09D97D153EF94D93

View File

@ -47,10 +47,7 @@ pub fn prepare_rootfs(spec: &Spec, rootfs: &Path, bind_devices: bool) -> Result<
for m in spec.mounts.as_ref().context("no mounts in spec")?.iter() {
let (flags, data) = parse_mount(m);
let ml = linux
.mount_label
.as_ref()
.context("no mount_label in spec")?;
let ml = linux.mount_label.as_ref();
if m.typ.as_ref().context("no type in mount spec")? == "cgroup" {
// skip
log::warn!("A feature of cgroup is unimplemented.");
@ -235,14 +232,18 @@ fn mount_to_container(
rootfs: &Path,
flags: MsFlags,
data: &str,
label: &str,
label: Option<&String>,
) -> Result<()> {
let typ = m.typ.as_ref().context("no type in mount spec")?;
let d = if !label.is_empty() && typ != "proc" && typ != "sysfs" {
if data.is_empty() {
format!("context=\"{}\"", label)
let d = if let Some(l) = label {
if typ != "proc" && typ != "sysfs" {
if data.is_empty() {
format!("context=\"{}\"", l)
} else {
format!("{},context=\"{}\"", data, l)
}
} else {
format!("{},context=\"{}\"", data, label)
data.to_string()
}
} else {
data.to_string()