summaryrefslogtreecommitdiff
path: root/bch_bindgen
AgeCommit message (Collapse)Author
2024-02-04rust: update bindgen to 0.69.4; remove custom type modificationsThomas Bertschinger
This updates rust-bindgen to version 0.69.4 which includes the patch 199bee441ad0: "try to avoid #[repr(packed)] when align is needed". With this patch, bindgen generates code that is both ABI-correct and can be compiled by rustc, for 3 bcachefs types: - bkey - bch_extent_crc32 - bch_extent_ptr This allows us to remove the custom treatment for these three types. Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-01-29printbuf_to_formatter: Lossy display of non-UTF-8 printbufsGabriel
Use to_string_lossy in printbuf_to_formatter, which tolerates non-UTF-8 strings (by using replacement characters). This is used in various Display impls, and allows something like: bcachefs list --btree dirents with non-UTF-8 paths.
2024-01-27feat(bindgen): expose `bcache_fs_(open|close)` to Rust sideRyan Lahfa
This function allows to obtain a handle to send various `ioctl`s to the underlying bcachefs filesystem. We need also its counterpart to clean up. Signed-off-by: Ryan Lahfa <bcachefs@lahfa.xyz>
2024-01-26feat(bindgen): expose `BCH_IOCTL_SUBVOLUME_*` on Rust sideRaito Bezarius
As they are functional macro, they need help from our side.
2024-01-26fix(bindgen): expand the Fix753 workaround for any type and document itRaito Bezarius
Offer documentation to the poor people who stumble on this and look for a macro generation mechanism on the Rust side.
2024-01-23use upstream bindgen; fix packed and aligned typesThomas Bertschinger
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-23remove bch_bindgen/Cargo.lock from version controlThomas Bertschinger
This is redundant with the root level Cargo.lock. Any changes made to the bch_bindgen dependencies will be duplicated in both Cargo.lock files. Removing this from version control will reduce the noise in the git diffs for such changes. Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-01-21bch_bindgen: add liburcu paths by pkgconfigxhe
Signed-off-by: xhe <xw897002528@gmail.com>
2024-01-20Remove gag usageKent Overstreet
Possibly-fixes: https://github.com/koverstreet/bcachefs-tools/issues/217 Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-01-16Move c_src dirs back to toplevelKent Overstreet
We just wanted c sourcefiles out of the top level, not c source directories. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-01-16move Rust sources to top level, C sources into c_srcThomas Bertschinger
This moves the Rust sources out of rust_src/ and into the top level. Running the bcachefs executable out of the development tree is now: $ ./target/release/bcachefs command or $ cargo run --profile release -- command instead of "./bcachefs command". Building and installing is still: $ make && make install Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>