diff --git a/.github/workflows/cargo.yml b/.github/workflows/cargo.yml index 2fe8239d07..4bb9d3073c 100644 --- a/.github/workflows/cargo.yml +++ b/.github/workflows/cargo.yml @@ -28,8 +28,8 @@ jobs: - task: | COMPARE_FEDORA_VERSIONS=./compare_fedora_versions MANIFEST_PATH=../../stratisd_proc_macros/Cargo.toml FEDORA_RELEASE=rawhide IGNORE_ARGS="--ignore-category low" make -f ../../Makefile check-fedora-versions COMPARE_FEDORA_VERSIONS=./compare_fedora_versions MANIFEST_PATH=../../stratisd_proc_macros/Cargo.toml FEDORA_RELEASE=f35 IGNORE_ARGS="--ignore-category low" make -f ../../Makefile check-fedora-versions - COMPARE_FEDORA_VERSIONS=./compare_fedora_versions MANIFEST_PATH=../../Cargo.toml FEDORA_RELEASE=rawhide IGNORE_ARGS="--ignore-category low" make -f ../../Makefile check-fedora-versions - COMPARE_FEDORA_VERSIONS=./compare_fedora_versions MANIFEST_PATH=../../Cargo.toml FEDORA_RELEASE=f35 IGNORE_ARGS="--ignore-category low" make -f ../../Makefile check-fedora-versions + COMPARE_FEDORA_VERSIONS=./compare_fedora_versions MANIFEST_PATH=../../Cargo.toml FEDORA_RELEASE=rawhide IGNORE_ARGS="--ignore-category low --ignore-high=libcryptsetup-rs" make -f ../../Makefile check-fedora-versions + COMPARE_FEDORA_VERSIONS=./compare_fedora_versions MANIFEST_PATH=../../Cargo.toml FEDORA_RELEASE=f35 IGNORE_ARGS="--ignore-category low --ignore-high=libcryptsetup-rs" make -f ../../Makefile check-fedora-versions runs-on: ubuntu-18.04 container: image: fedora:36 # CURRENT DEVELOPMENT ENVIRONMENT diff --git a/.github/workflows/fedora.yml b/.github/workflows/fedora.yml index 1d0622f7d5..6451e7123d 100644 --- a/.github/workflows/fedora.yml +++ b/.github/workflows/fedora.yml @@ -45,6 +45,11 @@ jobs: - task: make -f Makefile test toolchain: 1.62.0 # CURRENT DEVELOPMENT RUST TOOLCHAIN components: cargo + - task: >- + TANG_URL=localhost + make -f Makefile test-clevis-loop-should-fail + toolchain: 1.62.0 # CURRENT DEVELOPMENT RUST TOOLCHAIN + components: cargo - task: make -f Makefile release toolchain: 1.62.0 # CURRENT DEVELOPMENT RUST TOOLCHAIN components: cargo diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 94e4ea534b..a0ff266915 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -53,7 +53,7 @@ jobs: components: cargo runs-on: ubuntu-18.04 container: - image: ubuntu:hirsute + image: ubuntu:jammy options: --privileged -v /dev:/dev steps: - uses: actions/checkout@v2 @@ -89,7 +89,7 @@ jobs: components: cargo runs-on: ubuntu-18.04 container: - image: ubuntu:hirsute + image: ubuntu:jammy options: --privileged -v /dev:/dev steps: - uses: actions/checkout@v2 diff --git a/CHANGES.txt b/CHANGES.txt index 0fc5154a17..7ddad87a69 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,14 @@ +stratisd 3.1.2 +============== +Recommended Rust toolchain version: 1.62.0 +Lowest supported Rust toolchain version: 1.58.1 + +Recommended development platform for Python development: Fedora 36 + +- Cherry-picked commits from 3.3.0: + https://github.com/stratis-storage/stratisd/pull/3059 + + stratisd 3.1.1 ============== Recommended Rust toolchain version: 1.62.0 diff --git a/Cargo.lock b/Cargo.lock index a607471915..de2f693c32 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,9 +96,9 @@ dependencies = [ [[package]] name = "bit-set" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e11e16035ea35e4e5997b393eacbf6f63983188f7a2ad25bfb13465f5ad59de" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" dependencies = [ "bit-vec", ] @@ -230,9 +230,9 @@ checksum = "ccaeedb56da03b09f598226e25e80088cb4cd25f316e6e4df7d695f0feeb1403" [[package]] name = "crypto-common" -version = "0.1.4" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5999502d32b9c48d492abe66392408144895020ec4709e549e840799f3bb74c0" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", "typenum", @@ -246,9 +246,9 @@ checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" [[package]] name = "dbus" -version = "0.9.5" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de0a745c25b32caa56b82a3950f5fec7893a960f4c10ca3b02060b0c38d8c2ce" +checksum = "6f8bcdd56d2e5c4ed26a529c5a9029f5db8290d433497506f958eae3be148eb6" dependencies = [ "futures-channel", "futures-util", @@ -268,24 +268,26 @@ dependencies = [ [[package]] name = "devicemapper" -version = "0.32.0" -source = "git+https://github.com/stratis-storage/devicemapper-rs?branch=crates-io-patch-0.32.0#ce34272563acd52bb2c04a91e87c450ab5f91ece" +version = "0.32.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9c5453ed77c2eea1d847d86f90727f6d3e437c15fa5452748fb0c4084cee4be" dependencies = [ "bitflags", "devicemapper-sys", - "nix 0.23.1", + "lazy_static", + "nix 0.24.2", "semver", "serde", ] [[package]] name = "devicemapper-sys" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bcbd37e4723b2221792aa84fc1a9f833657b132ae2fcfff1693a8bd3c68c1dd" +checksum = "8d2aad5bae6bc8a217f8c398c5737122966cbd35f19dd223433606225ec48285" dependencies = [ "bindgen 0.59.2", - "nix 0.22.3", + "nix 0.24.2", ] [[package]] @@ -353,9 +355,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf" +checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" dependencies = [ "instant", ] @@ -563,9 +565,9 @@ checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" [[package]] name = "libcryptsetup-rs" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a41b1f72b98b005aafcbc4c55ccf5e51e9b61c6d0855c21fe125b49d614085ea" +checksum = "0fe68061beaa409d095b8010a37cb611685a627889aa29d79a0380c93ff89c13" dependencies = [ "either", "lazy_static", @@ -574,14 +576,14 @@ dependencies = [ "pkg-config", "semver", "serde_json", - "uuid 0.8.2", + "uuid 1.1.2", ] [[package]] name = "libcryptsetup-rs-sys" -version = "0.1.6" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41ef25e923679fe233e3c109702829717404d1266c80d6f30236e82e7b2798dc" +checksum = "0c136e640bca5c6394092ee31eb55b4b6a9b307c32fa2db8a1764efac8239f9c" dependencies = [ "bindgen 0.59.2", "cc", @@ -713,9 +715,9 @@ dependencies = [ [[package]] name = "nix" -version = "0.22.3" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4916f159ed8e5de0082076562152a76b7a1f64a01fd9d1e0fea002c37624faf" +checksum = "9f866317acbd3a240710c63f065ffb1e4fd466259045ccb504130b7f668f35c6" dependencies = [ "bitflags", "cc", @@ -726,12 +728,11 @@ dependencies = [ [[package]] name = "nix" -version = "0.23.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f866317acbd3a240710c63f065ffb1e4fd466259045ccb504130b7f668f35c6" +checksum = "195cdbc1741b8134346d515b3a56a1c94b0912758009cfd53f99ea0f57b065fc" dependencies = [ "bitflags", - "cc", "cfg-if 1.0.0", "libc", "memoffset", @@ -830,9 +831,9 @@ checksum = "bc5c99d529f0d30937f6f4b8a86d988047327bb88d04d2c4afc356de74722131" [[package]] name = "proc-macro2" -version = "1.0.40" +version = "1.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" +checksum = "c278e965f1d8cf32d6e0e96de3d3e79712178ae67986d9cf9151f51e95aac89b" dependencies = [ "unicode-ident", ] @@ -919,9 +920,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.13" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ "bitflags", ] @@ -1003,15 +1004,15 @@ checksum = "a2333e6df6d6598f2b1974829f853c2b4c5f4a6e503c10af918081aa6f8564e1" [[package]] name = "serde" -version = "1.0.138" +version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1578c6245786b9d168c5447eeacfb96856573ca56c9d68fdcf394be134882a47" +checksum = "fc855a42c7967b7c369eb5860f7164ef1f6f81c20c7cc1141f2a604e18723b03" [[package]] name = "serde_derive" -version = "1.0.138" +version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "023e9b1467aef8a10fb88f25611870ada9800ef7e22afce356bb0d2387b6f27c" +checksum = "6f2122636b9fe3b81f1cb25099fcf2d3f542cdb1d45940d56c713158884a05da" dependencies = [ "proc-macro2", "quote", @@ -1057,9 +1058,12 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg", +] [[package]] name = "socket2" @@ -1073,7 +1077,7 @@ dependencies = [ [[package]] name = "stratisd" -version = "3.1.1" +version = "3.1.2" dependencies = [ "async-trait", "bindgen 0.59.2", @@ -1176,10 +1180,11 @@ dependencies = [ [[package]] name = "tokio" -version = "1.19.2" +version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c51a52ed6686dd62c320f9b89299e9dfb46f730c7a48e635c19f21d116cb1439" +checksum = "7a8325f63a7d4774dd041e363b2409ed1c5cbbd0f867795e661df066b2b0a581" dependencies = [ + "autocfg", "libc", "mio", "num_cpus", @@ -1210,9 +1215,9 @@ checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "unicode-ident" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" +checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7" [[package]] name = "unicode-width" @@ -1225,9 +1230,6 @@ name = "uuid" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" -dependencies = [ - "getrandom", -] [[package]] name = "uuid" diff --git a/Cargo.toml b/Cargo.toml index b3afcbdbe8..0cf35e7f0a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "stratisd" -version = "3.1.1" +version = "3.1.2" authors = ["Stratis Developers "] edition = "2018" build = "build.rs" @@ -46,6 +46,7 @@ byteorder = "1.2.3" clap = "2.23.0" crc = "2.0.0" data-encoding = "2.3.0" +devicemapper = "0.32.1" either = "1.5.0" env_logger="0.9.0" futures = "0.3.11" @@ -71,17 +72,12 @@ version = "0.4.16" default-features = false features = ["clock", "std"] -[dependencies.devicemapper] -version = "0.32.0" -git = "https://github.com/stratis-storage/devicemapper-rs" -branch = "crates-io-patch-0.32.0" - [dependencies.stratisd_proc_macros] version = "0.1.0" path = "./stratisd_proc_macros" [dependencies.libcryptsetup-rs] -version = "0.5.0" +version = "0.5.1" features = ["mutex"] [dependencies.tokio] diff --git a/Makefile b/Makefile index 74f9d56775..7654b0ffd6 100644 --- a/Makefile +++ b/Makefile @@ -301,10 +301,16 @@ test: RUSTFLAGS="${DENY}" RUST_BACKTRACE=1 cargo test --all-features -- --skip real_ --skip loop_ --skip clevis_ test-clevis-real: - RUSTFLAGS="${DENY}" RUST_BACKTRACE=1 RUST_TEST_THREADS=1 cargo test clevis_real_ + RUSTFLAGS="${DENY}" RUST_BACKTRACE=1 RUST_TEST_THREADS=1 cargo test clevis_real_ -- --skip clevis_real_should_fail + +test-clevis-real-should-fail: + RUSTFLAGS="${DENY}" RUST_BACKTRACE=1 RUST_TEST_THREADS=1 cargo test clevis_real_should_fail test-clevis-loop: - RUSTFLAGS="${DENY}" RUST_BACKTRACE=1 RUST_TEST_THREADS=1 cargo test clevis_loop_ + RUSTFLAGS="${DENY}" RUST_BACKTRACE=1 RUST_TEST_THREADS=1 cargo test clevis_loop_ -- --skip clevis_loop_should_fail_ + +test-clevis-loop-should-fail: + RUSTFLAGS="${DENY}" RUST_BACKTRACE=1 RUST_TEST_THREADS=1 cargo test clevis_loop_should_fail_ yamllint: yamllint --strict .github/workflows/*.yml @@ -382,7 +388,9 @@ check-fedora-versions: test-compare-fedora-versions test-loop test-real test-clevis-loop + test-clevis-loop-should-fail test-clevis-real + test-clevis-real-should-fail test-compare-fedora-versions test-set-lower-bounds verify-dependency-bounds diff --git a/src/bin/stratis-utils.rs b/src/bin/stratis-utils.rs index 5791e490f5..abf94ad4dc 100644 --- a/src/bin/stratis-utils.rs +++ b/src/bin/stratis-utils.rs @@ -196,7 +196,7 @@ fn predict_pool_usage( .transpose()?; let crypt_metadata_size = if encrypted { - Bytes(u128::from(crypt_metadata_size())) + crypt_metadata_size() } else { Bytes(0) }; diff --git a/src/dbus_api/types.rs b/src/dbus_api/types.rs index b1ab65ba50..552d4b6765 100644 --- a/src/dbus_api/types.rs +++ b/src/dbus_api/types.rs @@ -139,9 +139,6 @@ where E: Engine, { /// Convert changed properties from a pool to a series of D-Bus actions. - /// - /// Precondition: Filtering of diffs that show no change has already been - /// done in the engine. pub fn from_pool_diffs(diffs: HashMap) -> Vec { diffs .into_iter() @@ -170,9 +167,6 @@ where } /// Convert changed properties from filesystems to a series of D-Bus actions. - /// - /// Precondition: Filtering of diffs that show no change has already been - /// done in the engine. pub fn from_fs_diffs(diffs: HashMap) -> Vec { diffs .into_iter() diff --git a/src/engine/strat_engine/backstore/blockdevmgr.rs b/src/engine/strat_engine/backstore/blockdevmgr.rs index bac9d1e57a..31e2d30777 100644 --- a/src/engine/strat_engine/backstore/blockdevmgr.rs +++ b/src/engine/strat_engine/backstore/blockdevmgr.rs @@ -978,6 +978,15 @@ mod tests { ); } + #[test] + #[should_panic] + fn clevis_real_should_fail_test_initialize() { + real::test_with_spec( + &real::DeviceLimits::AtLeast(2, None, None), + test_clevis_initialize, + ); + } + #[test] fn clevis_loop_test_initialize() { loopbacked::test_with_spec( @@ -986,6 +995,15 @@ mod tests { ); } + #[test] + #[should_panic] + fn clevis_loop_should_fail_test_initialize() { + loopbacked::test_with_spec( + &loopbacked::DeviceLimits::Range(2, 4, None), + test_clevis_initialize, + ); + } + fn test_clevis_both_initialize(paths: &[&Path]) { fn test_both(paths: &[&Path], key_desc: &KeyDescription) -> Result<(), Box> { unshare_namespace()?; @@ -1078,6 +1096,15 @@ mod tests { ); } + #[test] + #[should_panic] + fn clevis_real_should_fail_test_both_initialize() { + real::test_with_spec( + &real::DeviceLimits::AtLeast(2, None, None), + test_clevis_both_initialize, + ); + } + #[test] fn clevis_loop_test_both_initialize() { loopbacked::test_with_spec( @@ -1085,4 +1112,13 @@ mod tests { test_clevis_both_initialize, ); } + + #[test] + #[should_panic] + fn clevis_loop_should_fail_test_both_initialize() { + loopbacked::test_with_spec( + &loopbacked::DeviceLimits::Range(2, 4, None), + test_clevis_both_initialize, + ); + } } diff --git a/src/engine/strat_engine/backstore/crypt/mod.rs b/src/engine/strat_engine/backstore/crypt/mod.rs index 8d07780c30..00521ac0be 100644 --- a/src/engine/strat_engine/backstore/crypt/mod.rs +++ b/src/engine/strat_engine/backstore/crypt/mod.rs @@ -384,6 +384,15 @@ mod tests { ); } + #[test] + #[should_panic] + fn clevis_real_should_fail_test_both_initialize() { + real::test_with_spec( + &real::DeviceLimits::Exactly(1, None, Some(Sectors(1024 * 1024 * 1024 / 512))), + test_both_initialize, + ); + } + #[test] fn clevis_loop_test_both_initialize() { loopbacked::test_with_spec( @@ -392,6 +401,15 @@ mod tests { ); } + #[test] + #[should_panic] + fn clevis_loop_should_fail_test_both_initialize() { + loopbacked::test_with_spec( + &loopbacked::DeviceLimits::Exactly(1, None), + test_both_initialize, + ); + } + fn test_clevis_initialize(paths: &[&Path]) { unshare_namespace().unwrap(); let _memfs = MemoryFilesystem::new().unwrap(); @@ -423,6 +441,15 @@ mod tests { ); } + #[test] + #[should_panic] + fn clevis_real_should_fail_test_initialize() { + real::test_with_spec( + &real::DeviceLimits::Exactly(1, None, Some(Sectors(1024 * 1024 * 1024 / 512))), + test_clevis_initialize, + ); + } + #[test] fn clevis_loop_test_initialize() { loopbacked::test_with_spec( @@ -430,4 +457,13 @@ mod tests { test_clevis_initialize, ); } + + #[test] + #[should_panic] + fn clevis_loop_should_fail_test_initialize() { + loopbacked::test_with_spec( + &loopbacked::DeviceLimits::Exactly(1, None), + test_clevis_initialize, + ); + } } diff --git a/src/engine/strat_engine/backstore/crypt/shared.rs b/src/engine/strat_engine/backstore/crypt/shared.rs index cf0a8e0358..0faa2a6562 100644 --- a/src/engine/strat_engine/backstore/crypt/shared.rs +++ b/src/engine/strat_engine/backstore/crypt/shared.rs @@ -10,6 +10,7 @@ use std::{ }; use data_encoding::BASE64URL_NOPAD; +use devicemapper::Bytes; use either::Either; use serde_json::{Map, Value}; use sha2::{Digest, Sha256}; @@ -749,7 +750,7 @@ pub fn wipe_fallback(path: &Path, causal_error: StratisError) -> StratisError { } } }; - let size = match convert_int!(crypt_metadata_size(), u64, usize) { + let size = match convert_int!(*crypt_metadata_size(), u128, usize) { Ok(s) => s, Err(e) => { return StratisError::NoActionRollbackError { @@ -981,8 +982,8 @@ fn identifiers_from_metadata(device: &mut CryptDevice) -> StratisResult u64 { - 2 * DEFAULT_CRYPT_METADATA_SIZE + DEFAULT_CRYPT_KEYSLOTS_SIZE +pub fn crypt_metadata_size() -> Bytes { + 2u64 * Bytes::from(DEFAULT_CRYPT_METADATA_SIZE) + Bytes::from(DEFAULT_CRYPT_KEYSLOTS_SIZE) } /// Back up the LUKS2 header to a temporary file. diff --git a/src/engine/strat_engine/engine.rs b/src/engine/strat_engine/engine.rs index 5f43929b19..600e02611f 100644 --- a/src/engine/strat_engine/engine.rs +++ b/src/engine/strat_engine/engine.rs @@ -542,7 +542,7 @@ impl Engine for StratEngine { mod test { use std::{env, error::Error, path::Path}; - use devicemapper::{Bytes, Sectors}; + use devicemapper::Sectors; use crate::engine::{ engine::Pool, @@ -740,7 +740,7 @@ mod test { Box::new(StratisError::Msg("Pool must be present".to_string())) })?; - fail_device.start_failing(*Bytes(u128::from(crypt_metadata_size())).sectors())?; + fail_device.start_failing(*crypt_metadata_size().sectors())?; if operation(&mut pool).is_ok() { return Err(Box::new(StratisError::Msg( "Clevis initialization should have failed".to_string(), diff --git a/src/engine/strat_engine/metadata/static_header.rs b/src/engine/strat_engine/metadata/static_header.rs index f17a02dea5..86a8eb7c2b 100644 --- a/src/engine/strat_engine/metadata/static_header.rs +++ b/src/engine/strat_engine/metadata/static_header.rs @@ -277,12 +277,12 @@ impl StaticHeader { f: &mut F, sh: StaticHeader, repair_location: MetadataLocation, - ) -> StratisResult> + ) -> StratisResult where F: Seek + SyncAll, { sh.write(f, repair_location)?; - Ok(Some(sh)) + Ok(sh) } /// Replacement function for write_header @@ -292,11 +292,11 @@ impl StaticHeader { _f: &mut F, sh: StaticHeader, _repair_location: MetadataLocation, - ) -> StratisResult> + ) -> StratisResult where F: Seek + SyncAll, { - Ok(Some(sh)) + Ok(sh) } /// Try to find a valid StaticHeader on a device. @@ -322,7 +322,7 @@ impl StaticHeader { ) -> StratisResult> where F: Read + Seek + SyncAll, - C: Fn(&mut F, StaticHeader, MetadataLocation) -> StratisResult>, + C: Fn(&mut F, StaticHeader, MetadataLocation) -> StratisResult, { // Action taken when one sigblock is interpreted as invalid. // @@ -337,7 +337,7 @@ impl StaticHeader { repair_location: MetadataLocation| -> StratisResult> { if let Some(sh) = maybe_sh { - closure(f, sh, repair_location) + closure(f, sh, repair_location).map(Some) } else { Err(sh_error) } @@ -362,9 +362,9 @@ impl StaticHeader { let err_str = "Appeared to be a Stratis device, but signature blocks disagree."; Err(StratisError::Msg(err_str.into())) } else if sh_1.initialization_time > sh_2.initialization_time { - closure(f, sh_1, MetadataLocation::Second) + closure(f, sh_1, MetadataLocation::Second).map(Some) } else { - closure(f, sh_2, MetadataLocation::First) + closure(f, sh_2, MetadataLocation::First).map(Some) } }; @@ -386,8 +386,8 @@ impl StaticHeader { match (maybe_sh1, maybe_sh2) { (Some(loc_1), Some(loc_2)) => compare_headers(f, loc_1, loc_2), (None, None) => Ok(None), - (Some(loc_1), None) => closure(f, loc_1, MetadataLocation::Second), - (None, Some(loc_2)) => closure(f, loc_2, MetadataLocation::First), + (Some(loc_1), None) => closure(f, loc_1, MetadataLocation::Second).map(Some), + (None, Some(loc_2)) => closure(f, loc_2, MetadataLocation::First).map(Some), } };