diff --git a/userspace/ksud/src/mount.rs b/userspace/ksud/src/mount.rs index 36aab8213e84..8eb0eb20908d 100644 --- a/userspace/ksud/src/mount.rs +++ b/userspace/ksud/src/mount.rs @@ -77,7 +77,7 @@ pub fn mount_ext4(source: impl AsRef, target: impl AsRef) -> Result< MoveMountFlags::MOVE_MOUNT_F_EMPTY_PATH, )?; } else { - bail!("mount failed"); + mount(lo, target.as_ref(), "ext4", MountFlags::empty(), "")?; } Ok(()) } @@ -139,7 +139,18 @@ pub fn mount_overlayfs( })(); if let Err(e) = result { - bail!("fsopen mount failed: {:#}", e); + warn!("fsopen mount failed: {:#}, fallback to mount", e); + let mut data = format!("lowerdir={lowerdir_config}"); + if let (Some(upperdir), Some(workdir)) = (upperdir, workdir) { + data = format!("{data},upperdir={upperdir},workdir={workdir}"); + } + mount( + KSU_OVERLAY_SOURCE, + dest.as_ref(), + "overlay", + MountFlags::empty(), + data, + )?; } Ok(()) } @@ -160,7 +171,13 @@ pub fn mount_tmpfs(dest: impl AsRef) -> Result<()> { MoveMountFlags::MOVE_MOUNT_F_EMPTY_PATH, )?; } else { - bail!("mount failed"); + mount( + KSU_OVERLAY_SOURCE, + dest.as_ref(), + "tmpfs", + MountFlags::empty(), + "", + )?; } Ok(()) } @@ -200,7 +217,13 @@ pub fn bind_mount(from: impl AsRef, to: impl AsRef) -> Result<()> { MoveMountFlags::MOVE_MOUNT_F_EMPTY_PATH, )?; } else { - bail!("mount failed"); + mount( + from.as_ref(), + to.as_ref(), + "", + MountFlags::BIND | MountFlags::REC, + "", + )?; } Ok(()) } @@ -237,7 +260,8 @@ fn mount_overlay_child( } // merge modules and stock if let Err(e) = mount_overlayfs(&lower_dirs, stock_root, None, None, mount_point) { - bail!("failed: {:#}", e); + warn!("failed: {:#}, fallback to bind mount", e); + bind_mount(stock_root, mount_point)?; } Ok(()) }