Skip to content

Commit ffe46d8

Browse files
committed
install-to-disk: Verify target is a block device
I saw someone get confused and think `bootc install` could work on a filesystem. Signed-off-by: Colin Walters <[email protected]>
1 parent b831efb commit ffe46d8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/src/install.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use cap_std_ext::prelude::CapStdExtDirExt;
2626
use chrono::prelude::*;
2727
use clap::ValueEnum;
2828
use ostree_ext::oci_spec;
29+
use rustix::fs::FileTypeExt;
2930
use rustix::fs::MetadataExt;
3031

3132
use fn_error_context::context;
@@ -1024,6 +1025,13 @@ fn installation_complete() {
10241025
/// Implementation of the `bootc install to-disk` CLI command.
10251026
pub(crate) async fn install_to_disk(opts: InstallToDiskOpts) -> Result<()> {
10261027
let block_opts = opts.block_opts;
1028+
let target_blockdev_meta = block_opts
1029+
.device
1030+
.metadata()
1031+
.with_context(|| format!("Querying {}", &block_opts.device))?;
1032+
if !target_blockdev_meta.file_type().is_block_device() {
1033+
anyhow::bail!("Not a block device: {}", block_opts.device);
1034+
}
10271035
let state = prepare_install(opts.config_opts, opts.target_opts).await?;
10281036

10291037
// This is all blocking stuff

0 commit comments

Comments
 (0)