Skip to content

Commit 2a9712c

Browse files
ericcurtinqwencoder
andcommitted
install: Fix composefs Repository import and borrow checker errors
- Use correct path composefs::repository::Repository instead of composefs::Repository - Remove unused read_file import from composefs::fs - Remove unused Read and Write imports from std::io - Fix temporary value dropped while borrowed error in install_bootloader by using a let binding Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com> Signed-off-by: Eric Curtin <eric.curtin@docker.com>
1 parent 09b43ff commit 2a9712c

File tree

11 files changed

+74
-16
lines changed

11 files changed

+74
-16
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ clap_mangen = { version = "0.2.20" }
4444
# If adding/removing crates here, also update docs/Dockerfile.mdbook and docs/src/internals.md.
4545
#
4646
# To develop against a local composefs-rs checkout, add a [patch] section at the end of this file:
47-
# [patch."https://github.com/containers/composefs-rs"]
47+
# [patch."https://github.com/composefs/composefs-rs"]
4848
# composefs = { path = "/home/user/src/composefs-rs/crates/composefs" }
4949
# composefs-boot = { path = "/home/user/src/composefs-rs/crates/composefs-boot" }
5050
# composefs-oci = { path = "/home/user/src/composefs-rs/crates/composefs-oci" }
51+
# cfsctl = { path = "/home/user/src/composefs-rs/crates/cfsctl" }
5152
# The Justfile will auto-detect these and bind-mount them into container builds.
5253
composefs = { git = "https://github.com/composefs/composefs-rs", rev = "b928c6bd6c051e111d3efc3d25cdaf9159182ed0", package = "composefs", features = ["rhel9"] }
5354
cfsctl = { git = "https://github.com/composefs/composefs-rs", rev = "b928c6bd6c051e111d3efc3d25cdaf9159182ed0", package = "cfsctl", features = ["rhel9"] }

crates/blockdev/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,3 @@ tracing = { workspace = true }
2626

2727
[dev-dependencies]
2828
indoc = { workspace = true }
29-
30-
[lib]
31-
path = "src/blockdev.rs"

crates/blockdev/src/blockdev.rs

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
//! Block device utilities for bootc.
2+
//!
3+
//! This module provides utilities for querying and managing block devices,
4+
//! partitions, and filesystems during bootc installation and operation.
5+
16
use std::env;
27
use std::path::Path;
38
use std::process::{Command, Stdio};
@@ -26,27 +31,41 @@ struct DevicesOutput {
2631

2732
#[allow(dead_code)]
2833
#[derive(Debug, Clone, Deserialize)]
34+
/// Information about a block device.
2935
pub struct Device {
36+
/// Device name (e.g., "sda", "sda1").
3037
pub name: String,
38+
/// Device serial number.
3139
pub serial: Option<String>,
40+
/// Device model.
3241
pub model: Option<String>,
42+
/// Partition label.
3343
pub partlabel: Option<String>,
44+
/// Partition type.
3445
pub parttype: Option<String>,
46+
/// Partition UUID.
3547
pub partuuid: Option<String>,
3648
/// Partition number (1-indexed). None for whole disk devices.
3749
pub partn: Option<u32>,
50+
/// Child devices (partitions for a disk).
3851
pub children: Option<Vec<Device>>,
52+
/// Device size in bytes.
3953
pub size: u64,
54+
/// Major:minor device numbers.
4055
#[serde(rename = "maj:min")]
4156
pub maj_min: Option<String>,
4257
// NOTE this one is not available on older util-linux, and
4358
// will also not exist for whole blockdevs (as opposed to partitions).
4459
pub start: Option<u64>,
4560

4661
// Filesystem-related properties
62+
/// Filesystem label.
4763
pub label: Option<String>,
64+
/// Filesystem type.
4865
pub fstype: Option<String>,
66+
/// Filesystem UUID.
4967
pub uuid: Option<String>,
68+
/// Device path.
5069
pub path: Option<String>,
5170
/// Partition table type (e.g., "gpt", "dos"). Only present on whole disk devices.
5271
pub pttype: Option<String>,
@@ -234,6 +253,7 @@ impl Device {
234253
}
235254
}
236255

256+
/// List information about a block device.
237257
#[context("Listing device {dev}")]
238258
pub fn list_dev(dev: &Utf8Path) -> Result<Device> {
239259
let mut devs: DevicesOutput = Command::new("lsblk")
@@ -256,7 +276,9 @@ pub fn list_dev_by_dir(dir: &Dir) -> Result<Device> {
256276
list_dev(&Utf8PathBuf::from(&fsinfo.source))
257277
}
258278

279+
/// A loopback block device backed by a file.
259280
pub struct LoopbackDevice {
281+
/// The loopback device path (e.g., "/dev/loop0").
260282
pub dev: Option<Utf8PathBuf>,
261283
// Handle to the cleanup helper process
262284
cleanup_handle: Option<LoopbackCleanupHandle>,
@@ -384,8 +406,10 @@ impl Drop for LoopbackDevice {
384406
}
385407
}
386408

387-
/// Main function for the loopback cleanup helper process
388-
/// This function does not return - it either exits normally or via signal
409+
/// Run the loopback cleanup helper process.
410+
///
411+
/// This function does not return - it either exits normally or via signal.
412+
/// It is used to clean up loopback devices when the parent process dies.
389413
pub async fn run_loopback_cleanup_helper(device_path: &str) -> Result<()> {
390414
// Check if we're running as a cleanup helper
391415
if std::env::var("BOOTC_LOOPBACK_CLEANUP_HELPER").is_err() {
@@ -434,7 +458,9 @@ pub async fn run_loopback_cleanup_helper(device_path: &str) -> Result<()> {
434458
}
435459
}
436460

437-
/// Parse a string into mibibytes
461+
/// Parse a size string into mebibytes.
462+
///
463+
/// Supports suffixes: MiB/M, GiB/G, TiB/T.
438464
pub fn parse_size_mib(mut s: &str) -> Result<u64> {
439465
let suffixes = [
440466
("MiB", 1u64),

crates/blockdev/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//! Internal block device handling utilities for bootc.
2+
//!
3+
//! This crate provides utilities for querying and managing block devices,
4+
//! partitions, and filesystems during bootc installation and operation.
5+
6+
mod blockdev;
7+
pub use blockdev::*;

crates/lib/src/install.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ use cap_std_ext::cap_tempfile::TempDir;
173173
use cap_std_ext::cmdext::CapStdExtCommandExt;
174174
use cap_std_ext::prelude::CapStdExtDirExt;
175175
use clap::ValueEnum;
176-
use composefs::fs::{read_file, write_to_path};
176+
use composefs::fs::write_to_path;
177177
use composefs_boot::bootloader::{BootEntry, get_boot_resources};
178178
use composefs_boot::selabel;
179179
use composefs_oci::image::create_filesystem as create_composefs_filesystem;
@@ -1912,11 +1912,12 @@ fn install_bootloader(
19121912
deployment_path: Option<&str>,
19131913
bootloader_override: Option<&Bootloader>,
19141914
) -> Result<()> {
1915+
let default_bootloader = Bootloader::default();
19151916
let bootloader = bootloader_override.unwrap_or(
19161917
&config_opts
19171918
.bootloader
1918-
.clone()
1919-
.unwrap_or(Bootloader::default()),
1919+
.as_ref()
1920+
.unwrap_or(&default_bootloader),
19201921
);
19211922

19221923
match bootloader {
@@ -2028,12 +2029,11 @@ fn create_flat_bls_entry(
20282029
#[context("Copying regular file to {dest_path}")]
20292030
fn copy_regular_file<ObjectID: FsVerityHashValue>(
20302031
file: &composefs::tree::RegularFile<ObjectID>,
2031-
repo: &composefs::Repository<ObjectID>,
2032+
repo: &composefs::repository::Repository<ObjectID>,
20322033
dest_dir: &Dir,
20332034
dest_path: &str,
20342035
) -> Result<()> {
20352036
use composefs::tree::RegularFile;
2036-
use std::io::{Read, Write};
20372037

20382038
match file {
20392039
RegularFile::Inline(data) => {

crates/mount/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,3 @@ cap-std-ext = { workspace = true }
2525

2626
[dev-dependencies]
2727
indoc = { workspace = true }
28-
29-
[lib]
30-
path = "src/mount.rs"

crates/mount/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//! Internal mount utilities for bootc.
2+
//!
3+
//! This crate provides utilities for mounting and managing filesystem mounts
4+
//! during bootc installation and operation.
5+
6+
mod mount;
7+
pub use mount::*;
8+
9+
mod tempmount;
10+
pub use tempmount::*;

crates/mount/src/tempmount.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
//! Temporary mount management utilities.
2+
//!
3+
//! This module provides the [`TempMount`] type for creating temporary mounts
4+
//! that are automatically unmounted when dropped.
5+
16
use std::os::fd::AsFd;
27

38
use anyhow::{Context, Result};
@@ -7,8 +12,11 @@ use cap_std_ext::cap_std::{ambient_authority, fs::Dir};
712
use fn_error_context::context;
813
use rustix::mount::{MountFlags, MoveMountFlags, UnmountFlags, move_mount, unmount};
914

15+
/// A temporary mount that is automatically unmounted when dropped.
1016
pub struct TempMount {
17+
/// The temporary directory used as the mount point.
1118
pub dir: tempfile::TempDir,
19+
/// The directory file descriptor for the mount.
1220
pub fd: Dir,
1321
}
1422

docs/Dockerfile.mdbook

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ set -xeuo pipefail
2323
# Build rustdoc for internal crates
2424
cargo doc --workspace --no-deps --document-private-items
2525
# Also build docs for key external git dependencies (not on docs.rs)
26-
cargo doc --no-deps --document-private-items -p composefs -p composefs-boot -p composefs-oci
26+
cargo doc --no-deps --document-private-items -p composefs -p composefs-boot -p composefs-oci -p cfsctl
2727
# Build mdbook
2828
cd docs
2929
mdbook-mermaid install .

docs/src/SUMMARY.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@
2323
- [Logically bound images](logically-bound-images.md)
2424
- [Booting local builds](booting-local-builds.md)
2525
- [`man bootc`](man/bootc.8.md)
26+
- [`man bootc-config`](man/bootc-config.5.md)
2627
- [`man bootc-status`](man/bootc-status.8.md)
2728
- [`man bootc-upgrade`](man/bootc-upgrade.8.md)
2829
- [`man bootc-switch`](man/bootc-switch.8.md)
2930
- [`man bootc-rollback`](man/bootc-rollback.8.md)
31+
- [`man bootc-edit`](man/bootc-edit.8.md)
32+
- [`man bootc-config-diff`](man/bootc-config-diff.8.md)
3033
- [`man bootc-usr-overlay`](man/bootc-usr-overlay.8.md)
3134
- [`man bootc-fetch-apply-updates.service`](man/bootc-fetch-apply-updates.service.5.md)
3235
- [`man bootc-status-updated.path`](man/bootc-status-updated.path.5.md)
@@ -41,12 +44,19 @@
4144
- [`man bootc-install-to-disk`](man/bootc-install-to-disk.8.md)
4245
- [`man bootc-install-to-filesystem`](man/bootc-install-to-filesystem.8.md)
4346
- [`man bootc-install-to-existing-root`](man/bootc-install-to-existing-root.8.md)
47+
- [`man bootc-install-finalize`](man/bootc-install-finalize.8.md)
48+
- [`man bootc-install-print-configuration`](man/bootc-install-print-configuration.8.md)
49+
- [`man bootc-install-ensure-completion`](man/bootc-install-ensure-completion.8.md)
50+
- [`man system-reinstall-bootc`](man/system-reinstall-bootc.8.md)
4451
- [`man bootc-destructive-cleanup.service`](man/bootc-destructive-cleanup.service.5.md)
4552

4653
# Bootc usage in containers
4754

4855
- [Read-only when in a default container](bootc-in-container.md)
56+
- [`man bootc-container`](man/bootc-container.8.md)
4957
- [`man bootc-container-lint`](man/bootc-container-lint.8.md)
58+
- [`man bootc-container-inspect`](man/bootc-container-inspect.8.md)
59+
- [`man bootc-container-ukify`](man/bootc-container-ukify.8.md)
5060

5161
# Architecture
5262

@@ -62,6 +72,7 @@
6272
- [composefs backend](experimental-composefs.md)
6373
- [unified storage](experimental-unified-storage.md)
6474
- [`man bootc-root-setup.service`](man/bootc-root-setup.service.5.md)
75+
- [`man bootc-composefs-finalize-staged`](man/bootc-composefs-finalize-staged.8.md)
6576
- [fsck](experimental-fsck.md)
6677
- [install reset](experimental-install-reset.md)
6778
- [--progress-fd](experimental-progress-fd.md)

0 commit comments

Comments
 (0)