Skip to content

Commit

Permalink
install-to-disk: Verify target is a block device
Browse files Browse the repository at this point in the history
I saw someone get confused and think `bootc install` could work
on a filesystem.

Signed-off-by: Colin Walters <walters@verbum.org>
  • Loading branch information
cgwalters committed Dec 15, 2023
1 parent b831efb commit ffe46d8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use cap_std_ext::prelude::CapStdExtDirExt;
use chrono::prelude::*;
use clap::ValueEnum;
use ostree_ext::oci_spec;
use rustix::fs::FileTypeExt;
use rustix::fs::MetadataExt;

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

// This is all blocking stuff
Expand Down

0 comments on commit ffe46d8

Please sign in to comment.