Go to file
Thomas Bertschinger 7717a439cf use upstream bindgen; fix packed and aligned types
bcachefs-tools has been using a patched bindgen to work around a
limitation of rustc that prevents compiling structs with
both #[repr(packed(N)] and #[repr(align(N)] attributes. The patch:
e8168ceda507 "codegen: Don't generate conflicting packed() and align()
representation hints." discards the "align" attribute in cases where
bindgen produces a type with both.

This may be correct for some types, but it turns out that for each
bcachefs type with this problem, keeping the "align" attribute and
discarding the "packed" attribute generates a type with the same ABI as
the original C type.

This can be tested automatically by running:
$ cargo test --manifest-path bch_bindgen/Cargo.toml
in the bcachefs-tools tree.

There has been pressure recently to start using upstream bindgen; both
externally, from distribution maintainers who want to build
bcachefs-tools with standard dependencies, and internally, in order to
enable using Rust for bcachefs in-kernel.

This patch updates bcachefs-tools to use upstream bindgen. It works
around the rustc limitation with a post-processing step in the bindgen
build that adjusts the attributes to include "#[repr(C, align(N))]" and
exclude #[repr(packed(N)] only for the 4 types that need it. It also
updates bch_bindgen to format the code with prettyplease so that this
will work even in environments with rustfmt installed.

Some types that had been manually implemented in
bch_bindgen/src/bcachefs.rs are now automatically generated by bindgen,
so that they will be covered by the ABI compatibility testing mentioned
above.

I intentionally targeted the post-processing to the exact 4 types with
the issue currently, so that any changes to bcachefs that result in this
issue appearing for a new type will require manual intervention. I
figured any such changes should require careful consideration.

Ideally, bindgen can be updated to handle situations where "align(N)"
is needed and "packed(N)" can be safely discarded. If a patch for this
is accepted into bindgen, the post-processing hack can be removed.

I update the minimum Rust version to 1.70 as this is needed to build
recent versions of some dependencies.

Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-01-23 13:08:12 -05:00
.github move Rust sources to top level, C sources into c_src 2024-01-16 01:47:05 -05:00
bch_bindgen use upstream bindgen; fix packed and aligned types 2024-01-23 13:08:12 -05:00
c_src Move c_src dirs back to toplevel 2024-01-16 17:17:23 -05:00
ccan Move c_src dirs back to toplevel 2024-01-16 17:17:23 -05:00
debian fix packaging 2023-12-10 12:16:00 -05:00
doc Add additional information about encryption 2023-07-10 16:03:30 -04:00
fsck fix fsck service location 2024-01-11 23:55:39 -08:00
include Move c_src dirs back to toplevel 2024-01-16 17:17:23 -05:00
initramfs Replaced mkdir -p with install -D in make install 2019-01-13 19:31:04 -08:00
libbcachefs Move c_src dirs back to toplevel 2024-01-16 17:17:23 -05:00
linux Move c_src dirs back to toplevel 2024-01-16 17:17:23 -05:00
packaging packaging: Update RPM spec to use %_libexecdir for libexec files 2023-12-24 09:09:56 -05:00
raid Move c_src dirs back to toplevel 2024-01-16 17:17:23 -05:00
src rust: fix docs 2024-01-23 02:38:24 -05:00
tests move Rust sources to top level, C sources into c_src 2024-01-16 01:47:05 -05:00
udev fix udev rules path 2023-12-06 15:41:05 -05:00
.bcachefs_revision Update bcachefs sources to cbb2e45634dd bcachefs: fix simulateously upgrading & downgrading 2024-01-05 20:00:08 -05:00
.editorconfig nix: overhaul build system. 2023-01-03 16:58:55 +13:00
.gitignore remove bch_bindgen/Cargo.lock from version control 2024-01-23 02:53:45 -05:00
bcachefs.8 man: Fix cmd-option format 2023-11-27 21:04:03 -05:00
build.nix use upstream bindgen; fix packed and aligned types 2024-01-23 13:08:12 -05:00
build.rs Move c_src dirs back to toplevel 2024-01-16 17:17:23 -05:00
Cargo.lock use upstream bindgen; fix packed and aligned types 2024-01-23 13:08:12 -05:00
Cargo.toml use upstream bindgen; fix packed and aligned types 2024-01-23 13:08:12 -05:00
COPYING bcache-tools are GPL 2013-07-17 13:13:31 -07:00
default.nix nix: fix build add overlay and formatter to flake 2023-11-09 22:09:33 +01:00
flake.lock nix: fix build add overlay and formatter to flake 2023-11-09 22:09:33 +01:00
flake.nix nix: add bcachefs-fuse package 2023-11-20 15:13:17 -05:00
INSTALL.md docs: add llvm-config dependency for arch, fedora 2023-12-19 19:52:37 -05:00
make-release-tarball.sh move Rust sources to top level, C sources into c_src 2024-01-16 01:47:05 -05:00
Makefile Move c_src dirs back to toplevel 2024-01-16 17:17:23 -05:00
Makefile.compiler Update bcachefs sources to f9c612bbf82d bcachefs: Fixes for building in userspace 2023-09-23 20:03:23 -04:00
mount.bcachefs.sh Add a shell script version of mount.bcachefs 2020-08-24 23:17:17 -04:00
README.md Update docs 2023-03-07 12:46:53 -05:00
rustfmt.toml move Rust sources to top level, C sources into c_src 2024-01-16 01:47:05 -05:00

bcachefs-tools

Userspace tools and docs for bcachefs

Bcachefs is an advanced new filesystem for Linux, with an emphasis on reliability and robustness and the complete set of features one would expect from a modern filesystem.

This repo primarily consists of the following:

  • bcachefs tool, the reason this repo exists.
  • {mkfs,mount,fsck}.bcachefs utils, which is just wrappers calling the corresponding subcommands in the main tool
  • docs in the form of man-pages and a user manual

Please refer to the main site for getting started An in-depth user manual is (also) found on the official website

Build and install

Refer to INSTALL.md

Bug reports and contributions