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
1 change: 1 addition & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Minor changes:

Internal changes:

- rootmap: Fix support for LUKS on multipath

Packaging changes:

Expand Down
14 changes: 8 additions & 6 deletions src/bin/rdcore/rootmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ use crate::cmdline::*;
const PHYSICAL_ROOT_MOUNT: &str = "sysroot";

pub fn rootmap(config: RootmapConfig) -> Result<()> {
let root_mount_path = Path::new(&config.root_mount);
// Get the mount point for the deployment root, which will have e.g. /etc which we might parse
let rootfs_mount = Mount::from_existing(&config.root_mount)?;
let rootfs_mount = Mount::from_existing(root_mount_path)?;
// get the backing device for the "physical" root
let physical_root_path = format!("{}/{PHYSICAL_ROOT_MOUNT}", config.root_mount);
let physical_mount = Mount::from_existing(&physical_root_path)?;
let physical_root_path = root_mount_path.join(PHYSICAL_ROOT_MOUNT);
let physical_mount = Mount::from_existing(physical_root_path)?;
let device = PathBuf::from(physical_mount.device());

// and from that we can collect all the parent backing devices too
Expand Down Expand Up @@ -218,7 +219,7 @@ fn get_luks_uuid(device: &Path) -> Result<String> {
match deps.as_slice() {
[] => bail!("missing parent device for {}", device.display()),
[device] => {
if Disk::new(device)?.is_dm_device() {
if Disk::new(device)?.is_luks_integrity()? {
return get_luks_uuid(device);
}
Ok(runcmd_output!("cryptsetup", "luksUUID", device)?
Expand All @@ -233,10 +234,11 @@ fn get_luks_uuid(device: &Path) -> Result<String> {
}

pub fn bind_boot(config: BindBootConfig) -> Result<()> {
let root_mount_path = Path::new(&config.root_mount);
let boot_mount = Mount::from_existing(&config.boot_mount)?;
// We always operate here on the physical root
let physical_root_path = format!("{}/{PHYSICAL_ROOT_MOUNT}", config.root_mount);
let root_mount = Mount::from_existing(&physical_root_path)?;
let physical_root_path = root_mount_path.join(PHYSICAL_ROOT_MOUNT);
let root_mount = Mount::from_existing(physical_root_path)?;
let boot_uuid = boot_mount.get_filesystem_uuid()?;
let root_uuid = root_mount.get_filesystem_uuid()?;

Expand Down
8 changes: 4 additions & 4 deletions src/blockdev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,23 +447,23 @@ impl Mount {
})
}

pub fn from_existing(path: &str) -> Result<Mount> {
pub fn from_existing<P: AsRef<Path>>(path: P) -> Result<Mount> {
let mounts = read_to_string("/proc/self/mounts").context("reading mount table")?;
for line in mounts.lines() {
let mount: Vec<&str> = line.split_whitespace().collect();
// see https://man7.org/linux/man-pages/man5/fstab.5.html
if mount.len() != 6 {
bail!("invalid line in /proc/self/mounts: {}", line);
}
if mount[1] == path {
if Path::new(mount[1]) == path.as_ref() {
return Ok(Mount {
device: mount[0].to_string(),
mountpoint: path.into(),
mountpoint: path.as_ref().into(),
owned: false,
});
}
}
bail!("mountpoint {} not found", path);
bail!("mountpoint {} not found", path.as_ref().display());
}

pub fn device(&self) -> &str {
Expand Down