Skip to content

Commit 11cba84

Browse files
Johan-Liebert1cgwalters
authored andcommitted
install-to-fs: Move ostree target check before prepare_install
We need to know the underlying filesystem for the install to filesystem target, which we can't get just by `findmnt` if `/` is mounted as overlay, which is the case for ostree systems (and composefs systems) in the future. We already had code checking for this, move it around so we have that info BEFORE we call `prepare_install` Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
1 parent ea2cf3e commit 11cba84

1 file changed

Lines changed: 24 additions & 25 deletions

File tree

crates/lib/src/install.rs

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ use crate::store::Storage;
201201
use crate::task::Task;
202202
use crate::utils::sigpolicy_from_opt;
203203
use bootc_kernel_cmdline::{INITRD_ARG_PREFIX, ROOTFLAGS, bytes, utf8};
204-
use bootc_mount::{Filesystem, inspect_filesystem};
204+
use bootc_mount::Filesystem;
205205
use composefs::fsverity::FsVerityHashValue;
206206

207207
/// The toplevel boot directory
@@ -2353,22 +2353,6 @@ pub(crate) async fn install_to_filesystem(
23532353
target_path
23542354
);
23552355

2356-
let fs_inspect = inspect_filesystem(&opts.filesystem_opts.root_path)?;
2357-
2358-
// Gather global state, destructuring the provided options.
2359-
// IMPORTANT: We might re-execute the current process in this function (for SELinux among other things)
2360-
// IMPORTANT: and hence anything that is done before MUST BE IDEMPOTENT.
2361-
// IMPORTANT: In practice, we should only be gathering information before this point,
2362-
// IMPORTANT: and not performing any mutations at all.
2363-
let state = prepare_install(
2364-
opts.config_opts,
2365-
opts.source_opts,
2366-
opts.target_opts,
2367-
opts.composefs_opts,
2368-
Some(fs_inspect.fstype.as_str().try_into()?),
2369-
)
2370-
.await?;
2371-
23722356
// And the last bit of state here is the fsopts, which we also destructure now.
23732357
let mut fsopts = opts.filesystem_opts;
23742358

@@ -2390,6 +2374,7 @@ pub(crate) async fn install_to_filesystem(
23902374
}
23912375

23922376
let target_root_path = fsopts.root_path.clone();
2377+
23932378
// Get a file descriptor for the root path /target
23942379
let target_rootfs_fd =
23952380
Dir::open_ambient_dir(&target_root_path, cap_std::ambient_authority())
@@ -2412,11 +2397,6 @@ pub(crate) async fn install_to_filesystem(
24122397
}
24132398
}
24142399

2415-
// Check to see if this happens to be the real host root
2416-
if !fsopts.acknowledge_destructive {
2417-
warn_on_host_root(&target_rootfs_fd)?;
2418-
}
2419-
24202400
// If we're installing to an ostree root, then find the physical root from
24212401
// the deployment root.
24222402
let possible_physical_root = fsopts.root_path.join("sysroot");
@@ -2446,6 +2426,28 @@ pub(crate) async fn install_to_filesystem(
24462426
target_rootfs_fd.try_clone()?
24472427
};
24482428

2429+
// Gather data about the root filesystem
2430+
let inspect = bootc_mount::inspect_filesystem(&fsopts.root_path)?;
2431+
2432+
// Gather global state, destructuring the provided options.
2433+
// IMPORTANT: We might re-execute the current process in this function (for SELinux among other things)
2434+
// IMPORTANT: and hence anything that is done before MUST BE IDEMPOTENT.
2435+
// IMPORTANT: In practice, we should only be gathering information before this point,
2436+
// IMPORTANT: and not performing any mutations at all.
2437+
let state = prepare_install(
2438+
opts.config_opts,
2439+
opts.source_opts,
2440+
opts.target_opts,
2441+
opts.composefs_opts,
2442+
Some(inspect.fstype.as_str().try_into()?),
2443+
)
2444+
.await?;
2445+
2446+
// Check to see if this happens to be the real host root
2447+
if !fsopts.acknowledge_destructive {
2448+
warn_on_host_root(&target_rootfs_fd)?;
2449+
}
2450+
24492451
match fsopts.replace {
24502452
Some(ReplaceMode::Wipe) => {
24512453
let rootfs_fd = rootfs_fd.try_clone()?;
@@ -2459,9 +2461,6 @@ pub(crate) async fn install_to_filesystem(
24592461
None => require_empty_rootdir(&rootfs_fd)?,
24602462
}
24612463

2462-
// Gather data about the root filesystem
2463-
let inspect = bootc_mount::inspect_filesystem(&fsopts.root_path)?;
2464-
24652464
// We support overriding the mount specification for root (i.e. LABEL vs UUID versus
24662465
// raw paths).
24672466
// We also support an empty specification as a signal to omit any mountspec kargs.

0 commit comments

Comments
 (0)