Skip to content
Draft
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
39 changes: 35 additions & 4 deletions crates/lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,23 @@ fn parse_absolute_path(value: &str) -> std::result::Result<Utf8PathBuf, String>
}
}

/// Hidden, internal only options
#[derive(Debug, Parser, PartialEq, Eq)]
pub(crate) struct FsckOpts {
/// Inspect existing state without initializing storage or changing mounts.
#[clap(long)]
readonly: bool,
/// Emit a bounded JSON diagnostic report. Implies --readonly.
#[clap(long)]
report: bool,
}

impl FsckOpts {
pub(crate) fn readonly(&self) -> bool {
self.readonly || self.report
}
}

/// Hidden, internal only options
#[derive(Debug, clap::Subcommand, PartialEq, Eq)]
pub(crate) enum InternalsOpts {
Expand All @@ -781,7 +798,7 @@ pub(crate) enum InternalsOpts {
#[clap(subcommand)]
Selinux(SelinuxOpts),
/// Perform consistency checking.
Fsck,
Fsck(FsckOpts),
/// Perform cleanup actions
Cleanup,
Relabel {
Expand Down Expand Up @@ -2489,9 +2506,13 @@ async fn run_from_opt(opt: Opt) -> Result<CliExitStatus> {
}
InternalsOpts::Cfs { args } => composefs_ctl::run_from_iter(args.iter()).await,
InternalsOpts::Reboot => crate::reboot::reboot(),
InternalsOpts::Fsck => {
let storage = &get_storage().await?;
crate::fsck::fsck(&storage, std::io::stdout().lock()).await?;
InternalsOpts::Fsck(opts) => {
if opts.readonly() {
crate::fsck::fsck_readonly(root, opts.report, std::io::stdout().lock()).await?;
} else {
let storage = &get_storage().await?;
crate::fsck::fsck(&storage, std::io::stdout().lock()).await?;
}
Ok(())
}
InternalsOpts::FixupEtcFstab => crate::deploy::fixup_etc_fstab(&root),
Expand Down Expand Up @@ -3018,6 +3039,16 @@ mod tests {
}
}

#[test]
fn test_fsck_report_implies_readonly() {
let opts = match Opt::try_parse_from(["bootc", "internals", "fsck", "--report"]).unwrap() {
Opt::Internals(InternalsOpts::Fsck(opts)) => opts,
other => panic!("unexpected options: {other:?}"),
};
assert!(opts.report);
assert!(opts.readonly());
}

#[test]
fn test_image_reference_with_tag() {
// Test basic tag replacement for registry transport
Expand Down
Loading
Loading