Skip to content

Commit 31608bf

Browse files
committed
install: Rename rootfs -> physical_root
In the install flow we juggle *three* file systems in general: - The container/host root - The physical root - The deployment root "rootfs" in theory could be any of those three. In the install code it's the physical (target) root, so rename the variable to clarify. Signed-off-by: Colin Walters <[email protected]>
1 parent f6c9f4e commit 31608bf

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

lib/src/install.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ async fn initialize_ostree_root(state: &State, root_setup: &RootSetup) -> Result
580580
let sepolicy = state.load_policy()?;
581581
let sepolicy = sepolicy.as_ref();
582582
// Load a fd for the mounted target physical root
583-
let rootfs_dir = &root_setup.rootfs_fd;
583+
let rootfs_dir = &root_setup.physical_root;
584584
let cancellable = gio::Cancellable::NONE;
585585

586586
let stateroot = state.stateroot();
@@ -779,7 +779,7 @@ async fn install_container(
779779
// SAFETY: There must be a path
780780
let path = sysroot.deployment_dirpath(&deployment);
781781
let root = root_setup
782-
.rootfs_fd
782+
.physical_root
783783
.open_dir(path.as_str())
784784
.context("Opening deployment dir")?;
785785

@@ -792,7 +792,7 @@ async fn install_container(
792792
for d in ["ostree", "boot"] {
793793
let mut pathbuf = Utf8PathBuf::from(d);
794794
crate::lsm::ensure_dir_labeled_recurse(
795-
&root_setup.rootfs_fd,
795+
&root_setup.physical_root,
796796
&mut pathbuf,
797797
policy,
798798
Some(deployment_root_devino),
@@ -902,8 +902,11 @@ fn require_skopeo_with_containers_storage() -> Result<()> {
902902
pub(crate) struct RootSetup {
903903
luks_device: Option<String>,
904904
device_info: crate::blockdev::PartitionTable,
905-
rootfs: Utf8PathBuf,
906-
rootfs_fd: Dir,
905+
/// Absolute path to the location where we've mounted the physical
906+
/// root filesystem for the system we're installing.
907+
physical_root_path: Utf8PathBuf,
908+
/// Directory file descriptor for the above physical root.
909+
physical_root: Dir,
907910
rootfs_uuid: Option<String>,
908911
/// True if we should skip finalizing
909912
skip_finalize: bool,
@@ -925,7 +928,7 @@ impl RootSetup {
925928

926929
// Drop any open file descriptors and return just the mount path and backing luks device, if any
927930
fn into_storage(self) -> (Utf8PathBuf, Option<String>) {
928-
(self.rootfs, self.luks_device)
931+
(self.physical_root_path, self.luks_device)
929932
}
930933
}
931934

@@ -1323,7 +1326,7 @@ async fn install_with_sysroot(
13231326
let (_deployment, aleph) = install_container(state, rootfs, &sysroot, has_ostree).await?;
13241327
// Write the aleph data that captures the system state at the time of provisioning for aid in future debugging.
13251328
rootfs
1326-
.rootfs_fd
1329+
.physical_root
13271330
.atomic_replace_with(BOOTC_ALEPH_PATH, |f| {
13281331
serde_json::to_writer(f, &aleph)?;
13291332
anyhow::Ok(())
@@ -1336,7 +1339,7 @@ async fn install_with_sysroot(
13361339
} else {
13371340
crate::bootloader::install_via_bootupd(
13381341
&rootfs.device_info,
1339-
&rootfs.rootfs,
1342+
&rootfs.physical_root_path,
13401343
&state.config_opts,
13411344
)?;
13421345
}
@@ -1425,7 +1428,7 @@ async fn install_to_filesystem_impl(state: &State, rootfs: &mut RootSetup) -> Re
14251428
if !rootfs.skip_finalize {
14261429
let bootfs = rootfs.boot.as_ref().map(|_| ("boot", "boot"));
14271430
for (fsname, fs) in std::iter::once(("root", ".")).chain(bootfs) {
1428-
finalize_filesystem(fsname, &rootfs.rootfs_fd, fs)?;
1431+
finalize_filesystem(fsname, &rootfs.physical_root, fs)?;
14291432
}
14301433
}
14311434

@@ -1819,8 +1822,8 @@ pub(crate) async fn install_to_filesystem(
18191822
let mut rootfs = RootSetup {
18201823
luks_device: None,
18211824
device_info,
1822-
rootfs: fsopts.root_path,
1823-
rootfs_fd,
1825+
physical_root_path: fsopts.root_path,
1826+
physical_root: rootfs_fd,
18241827
rootfs_uuid: inspect.uuid.clone(),
18251828
boot,
18261829
kargs,

lib/src/install/baseline.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ pub(crate) fn install_create_rootfs(
223223

224224
// Create a temporary directory to use for mount points. Note that we're
225225
// in a mount namespace, so these should not be visible on the host.
226-
let rootfs = mntdir.join("rootfs");
227-
std::fs::create_dir_all(&rootfs)?;
226+
let physical_root_path = mntdir.join("rootfs");
227+
std::fs::create_dir_all(&physical_root_path)?;
228228
let bootfs = mntdir.join("boot");
229229
std::fs::create_dir_all(bootfs)?;
230230

@@ -389,11 +389,11 @@ pub(crate) fn install_create_rootfs(
389389
.chain(bootarg)
390390
.collect::<Vec<_>>();
391391

392-
mount::mount(&rootdev, &rootfs)?;
393-
let target_rootfs = Dir::open_ambient_dir(&rootfs, cap_std::ambient_authority())?;
392+
mount::mount(&rootdev, &physical_root_path)?;
393+
let target_rootfs = Dir::open_ambient_dir(&physical_root_path, cap_std::ambient_authority())?;
394394
crate::lsm::ensure_dir_labeled(&target_rootfs, "", Some("/".into()), 0o755.into(), sepolicy)?;
395-
let rootfs_fd = Dir::open_ambient_dir(&rootfs, cap_std::ambient_authority())?;
396-
let bootfs = rootfs.join("boot");
395+
let physical_root = Dir::open_ambient_dir(&physical_root_path, cap_std::ambient_authority())?;
396+
let bootfs = physical_root_path.join("boot");
397397
// Create the underlying mount point directory, which should be labeled
398398
crate::lsm::ensure_dir_labeled(&target_rootfs, "boot", None, 0o755.into(), sepolicy)?;
399399
if let Some(bootdev) = bootdev {
@@ -422,8 +422,8 @@ pub(crate) fn install_create_rootfs(
422422
Ok(RootSetup {
423423
luks_device,
424424
device_info,
425-
rootfs,
426-
rootfs_fd,
425+
physical_root_path,
426+
physical_root,
427427
rootfs_uuid: Some(root_uuid.to_string()),
428428
boot,
429429
kargs,

0 commit comments

Comments
 (0)