Skip to content

Commit

Permalink
Fux
Browse files Browse the repository at this point in the history
  • Loading branch information
tiann committed May 7, 2024
1 parent 9fbc487 commit 16c3eed
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions userspace/ksud/src/mount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub fn mount_ext4(source: impl AsRef<Path>, target: impl AsRef<Path>) -> Result<
MoveMountFlags::MOVE_MOUNT_F_EMPTY_PATH,
)?;
} else {
bail!("mount failed");
mount(lo, target.as_ref(), "ext4", MountFlags::empty(), "")?;
}
Ok(())
}
Expand Down Expand Up @@ -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(())
}
Expand All @@ -160,7 +171,13 @@ pub fn mount_tmpfs(dest: impl AsRef<Path>) -> Result<()> {
MoveMountFlags::MOVE_MOUNT_F_EMPTY_PATH,
)?;
} else {
bail!("mount failed");
mount(
KSU_OVERLAY_SOURCE,
dest.as_ref(),
"tmpfs",
MountFlags::empty(),
"",
)?;
}
Ok(())
}
Expand Down Expand Up @@ -200,7 +217,13 @@ pub fn bind_mount(from: impl AsRef<Path>, to: impl AsRef<Path>) -> Result<()> {
MoveMountFlags::MOVE_MOUNT_F_EMPTY_PATH,
)?;
} else {
bail!("mount failed");
mount(
from.as_ref(),
to.as_ref(),
"",
MountFlags::BIND | MountFlags::REC,
"",
)?;
}
Ok(())
}
Expand Down Expand Up @@ -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(())
}
Expand Down

0 comments on commit 16c3eed

Please sign in to comment.