summaryrefslogtreecommitdiff
path: root/rust-src/bch_bindgen
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-02-28 06:15:48 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-02-28 06:15:48 -0500
commit8a7e3344fe089b3e2c6c45f00ade217e3d55a958 (patch)
tree801bec15e86816d8c87da17f0ce4f5e21299c0f6 /rust-src/bch_bindgen
parentdaebbc085d74dc7666dd704f48fa4ed5c0005f75 (diff)
rust: Filesystem options now supported
This implements opt_set!(), which works exactly the same as the C version and allows filesystem options to be specified in Rust code. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'rust-src/bch_bindgen')
-rw-r--r--rust-src/bch_bindgen/Cargo.lock7
-rw-r--r--rust-src/bch_bindgen/Cargo.toml1
-rw-r--r--rust-src/bch_bindgen/build.rs2
-rw-r--r--rust-src/bch_bindgen/src/btree.rs2
-rw-r--r--rust-src/bch_bindgen/src/lib.rs2
-rw-r--r--rust-src/bch_bindgen/src/libbcachefs_wrapper.h1
-rw-r--r--rust-src/bch_bindgen/src/opts.rs9
7 files changed, 22 insertions, 2 deletions
diff --git a/rust-src/bch_bindgen/Cargo.lock b/rust-src/bch_bindgen/Cargo.lock
index 82d211b5..b2741976 100644
--- a/rust-src/bch_bindgen/Cargo.lock
+++ b/rust-src/bch_bindgen/Cargo.lock
@@ -48,6 +48,7 @@ dependencies = [
"gag",
"libc",
"memoffset",
+ "paste",
"pkg-config",
"udev",
"uuid",
@@ -440,6 +441,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3"
[[package]]
+name = "paste"
+version = "1.0.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba"
+
+[[package]]
name = "peeking_take_while"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/rust-src/bch_bindgen/Cargo.toml b/rust-src/bch_bindgen/Cargo.toml
index 9a9b7a98..cb341eef 100644
--- a/rust-src/bch_bindgen/Cargo.toml
+++ b/rust-src/bch_bindgen/Cargo.toml
@@ -20,6 +20,7 @@ byteorder = "1.3"
libc = "0.2.69"
gag = "1.0.0"
bitflags = "1.3.2"
+paste = "1.0.11"
[build-dependencies]
pkg-config = "0.3"
diff --git a/rust-src/bch_bindgen/build.rs b/rust-src/bch_bindgen/build.rs
index 8d9986f8..f426316f 100644
--- a/rust-src/bch_bindgen/build.rs
+++ b/rust-src/bch_bindgen/build.rs
@@ -54,6 +54,8 @@ fn main() {
.allowlist_var("BTREE_ITER.*")
.blocklist_item("bch2_bkey_ops")
.allowlist_type("bch_.*")
+ .allowlist_type("fsck_err_opts")
+ .rustified_enum("fsck_err_opts")
.allowlist_type("nonce")
.no_debug("bch_replicas_padded")
.newtype_enum("bch_kdf_types")
diff --git a/rust-src/bch_bindgen/src/btree.rs b/rust-src/bch_bindgen/src/btree.rs
index 7877b6e2..8ab91aeb 100644
--- a/rust-src/bch_bindgen/src/btree.rs
+++ b/rust-src/bch_bindgen/src/btree.rs
@@ -1,5 +1,3 @@
-#![allow(non_snake_case)]
-
use crate::SPOS_MAX;
use crate::c;
use crate::bkey::BkeySC;
diff --git a/rust-src/bch_bindgen/src/lib.rs b/rust-src/bch_bindgen/src/lib.rs
index bce150a4..3bc21a18 100644
--- a/rust-src/bch_bindgen/src/lib.rs
+++ b/rust-src/bch_bindgen/src/lib.rs
@@ -6,6 +6,8 @@ pub mod keyutils;
pub mod log;
pub mod rs;
pub mod fs;
+pub mod opts;
+pub use paste::paste;
pub mod c {
pub use crate::bcachefs::*;
diff --git a/rust-src/bch_bindgen/src/libbcachefs_wrapper.h b/rust-src/bch_bindgen/src/libbcachefs_wrapper.h
index 6332d957..c8990dcc 100644
--- a/rust-src/bch_bindgen/src/libbcachefs_wrapper.h
+++ b/rust-src/bch_bindgen/src/libbcachefs_wrapper.h
@@ -3,6 +3,7 @@
#include "../libbcachefs/bcachefs_format.h"
#include "../libbcachefs/btree_iter.h"
#include "../libbcachefs/errcode.h"
+#include "../libbcachefs/error.h"
#include "../libbcachefs/opts.h"
#include "../libbcachefs.h"
#include "../crypto.h"
diff --git a/rust-src/bch_bindgen/src/opts.rs b/rust-src/bch_bindgen/src/opts.rs
new file mode 100644
index 00000000..e2261993
--- /dev/null
+++ b/rust-src/bch_bindgen/src/opts.rs
@@ -0,0 +1,9 @@
+#[macro_export]
+macro_rules! opt_set {
+ ($opts:ident, $n:ident, $v:expr) => {
+ bch_bindgen::paste! {
+ $opts.$n = $v;
+ $opts.[<set_ $n _defined>](1);
+ }
+ }
+}