From 9e4acfeae6a70ad700a68f894ac6d224b0314c5a Mon Sep 17 00:00:00 2001 From: John Titor <50095635+JohnRTitor@users.noreply.github.com> Date: Sat, 4 Oct 2025 13:55:53 +0530 Subject: [PATCH 1/2] crane-build: fix by github actions tests by skipping some test on aarch64 > bcachefs::bindgen_test_layout_bch_replicas_padded__bindgen_ty_1 > bcachefs::bindgen_test_layout_bch_replicas_padded__bindgen_ty_2 > bcachefs::bindgen_test_layout_bch_replicas_padded__bindgen_ty_3 > bcachefs::bindgen_test_layout_bch_replicas_padded__bindgen_ty_4 Update flake.lock --- crane-build.nix | 15 ++++++++++++++- flake.lock | 24 ++++++++++++------------ 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/crane-build.nix b/crane-build.nix index 84b16b21..6f451f60 100644 --- a/crane-build.nix +++ b/crane-build.nix @@ -1,6 +1,7 @@ { lib, pkgs, + stdenvNoCC, # build time pkg-config, @@ -65,6 +66,17 @@ let zlib zstd ]; + + checkFlags = lib.optionals (stdenvNoCC.hostPlatform.isAarch64) [ + "--skip=bcachefs::bindgen_test_layout_bch_replicas_padded__bindgen_ty_1" + "--skip=bcachefs::bindgen_test_layout_bch_replicas_padded__bindgen_ty_2" + "--skip=bcachefs::bindgen_test_layout_bch_replicas_padded__bindgen_ty_3" + "--skip=bcachefs::bindgen_test_layout_bch_replicas_padded__bindgen_ty_4" + ]; + + checkPhaseCargoCommand = '' + cargo test --profile release -- --nocapture $checkFlags + ''; }; cargoArtifacts = craneLib.buildDepsOnly args; @@ -133,9 +145,10 @@ let pnameSuffix = "-test"; buildPhaseCargoCommand = ""; + checkPhaseCargoCommand = '' make ''${enableParallelChecking:+-j''${NIX_BUILD_CORES}} $makeFlags libbcachefs.a - cargo test --profile release -- --nocapture + cargo test --profile release -- --nocapture $checkFlags ''; } ); diff --git a/flake.lock b/flake.lock index d7bd8fd6..6f7832f7 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "crane": { "locked": { - "lastModified": 1758686891, - "narHash": "sha256-Lq8JkwjSzv80T1i8KCvqAch75zwD98UKA+4atZjvfZ0=", + "lastModified": 1759511609, + "narHash": "sha256-uU6Dq5OUgI9pEiMDwZZhvsoxYD+36xKIkYyFXDr//6A=", "owner": "ipetkov", "repo": "crane", - "rev": "02063302383f43237602f5aea5a67766b08e4787", + "rev": "c5b48a59ccd5179ea626f47b05d2828c37fb31b7", "type": "github" }, "original": { @@ -36,11 +36,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1756770412, - "narHash": "sha256-+uWLQZccFHwqpGqr2Yt5VsW/PbeJVTn9Dk6SHWhNRPw=", + "lastModified": 1759362264, + "narHash": "sha256-wfG0S7pltlYyZTM+qqlhJ7GMw2fTF4mLKCIVhLii/4M=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "4524271976b625a4a605beefd893f270620fd751", + "rev": "758cf7296bee11f1706a574c77d072b8a7baa881", "type": "github" }, "original": { @@ -71,11 +71,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1758427187, - "narHash": "sha256-pHpxZ/IyCwoTQPtFIAG2QaxuSm8jWzrzBGjwQZIttJc=", + "lastModified": 1759381078, + "narHash": "sha256-gTrEEp5gEspIcCOx9PD8kMaF1iEmfBcTbO0Jag2QhQs=", "owner": "nixos", "repo": "nixpkgs", - "rev": "554be6495561ff07b6c724047bdd7e0716aa7b46", + "rev": "7df7ff7d8e00218376575f0acdcc5d66741351ee", "type": "github" }, "original": { @@ -118,11 +118,11 @@ ] }, "locked": { - "lastModified": 1758681214, - "narHash": "sha256-8cW731vev6kfr58cILO2ZsjHwaPhm88dQ8Q6nTSjP9I=", + "lastModified": 1759544920, + "narHash": "sha256-yQwP0JOHi3Icq09GG5ufGuGrq2zIijglVFj3kkF2MHA=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "b12ed88d8d33d4f3cbc842bf29fad93bb1437299", + "rev": "bd3a63bbff2c4cb3cd48e9d49f54c2ccad457f70", "type": "github" }, "original": { From 36cc57f0acd25e1d60b470999e9d1fa9cad2d9ad Mon Sep 17 00:00:00 2001 From: John Titor <50095635+JohnRTitor@users.noreply.github.com> Date: Sat, 4 Oct 2025 12:27:07 +0530 Subject: [PATCH 2/2] device-scan: instead of panicking handle when bcachefs is given directory or file as argument --- src/device_scan.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/device_scan.rs b/src/device_scan.rs index 0361739f..610674d2 100644 --- a/src/device_scan.rs +++ b/src/device_scan.rs @@ -2,6 +2,7 @@ use std::{ ffi::{CStr, CString, c_char, c_int}, collections::HashMap, env, + fs, path::{Path, PathBuf}, str, }; @@ -132,6 +133,15 @@ fn devs_str_sbs_from_device( device: &Path, opts: &bch_opts ) -> anyhow::Result> { + if let Ok(metadata) = fs::metadata(device) { + if metadata.is_dir() { + return Err(anyhow::anyhow!("'{}' is a directory, not a block device", device.display())); + } + if metadata.is_file() { + return Err(anyhow::anyhow!("'{}' is a regular file, not a block device", device.display())); + } + } + let dev_sb = read_super_silent(device, *opts)?; if dev_sb.sb().number_of_devices() == 1 { @@ -199,7 +209,11 @@ pub extern "C" fn bch2_scan_device_sbs(device: *const c_char, ret: *mut sb_names // how to initialize to default/empty? let opts = bch_bindgen::opts::parse_mount_opts(None, None, true).unwrap_or_default(); - let sbs = scan_sbs(&device, &opts).unwrap(); + let sbs = scan_sbs(&device, &opts) + .unwrap_or_else(|e| { + eprintln!("bcachefs ({}): error reading superblock: {}", device, e); + std::process::exit(-1); + }); let mut sbs = sbs.iter() .map(|(name, sb)| sb_name { @@ -225,5 +239,8 @@ pub extern "C" fn bch2_scan_devices(device: *const c_char) -> *mut c_char { // how to initialize to default/empty? let opts = bch_bindgen::opts::parse_mount_opts(None, None, true).unwrap_or_default(); - CString::new(scan_devices(&device, &opts).unwrap()).unwrap().into_raw() + CString::new(scan_devices(&device, &opts).unwrap_or_else(|e| { + eprintln!("bcachefs ({}): error reading superblock: {}", device, e); + std::process::exit(-1); + })).unwrap().into_raw() }