public inbox for linux-bcachefs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH TOOLS 0/2] convert main() from C to Rust
@ 2024-01-15  5:24 Thomas Bertschinger
  2024-01-15  5:24 ` [PATCH TOOLS 1/2] " Thomas Bertschinger
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Thomas Bertschinger @ 2024-01-15  5:24 UTC (permalink / raw)
  To: kent.overstreet, linux-bcachefs, bfoster; +Cc: Thomas Bertschinger

This converts the top-level main() of the bcachefs command line tool
from C to Rust.

The first patch does all the work of implementing a new main(), updating
the build process, and making things look for the executable in its new
location which is now rust-src/target/release/bcachefs.

The second patch removes the Library crate from the Rust package. This
was needed previously to allow the C program to link in the Rust
functions, but that doesn't happen anymore.

It seems likely that a bcachefs-tools library will be needed in the
future; for example see this request [1] on GitHub. This library will
have a different external-focused API as opposed to the previous library
that provided an internal API for the bcachefs tool itself. Considering
Rust's structure of one library crate per package, removing the current
library makes room for that requested library.

I tried to update everything to account for the new location of the
bcachefs executable, but let me know if anyone sees something I missed.
I could not figure out how this is set for the Debian package so it's
possible I missed something there...

[1] https://github.com/koverstreet/bcachefs-tools/issues/188


Thomas Bertschinger (2):
  convert main() from C to Rust
  remove library from bcachefs-tools Rust package

 Makefile                                      |  21 +--
 bcachefs.c                                    | 127 +-----------------
 cmds.h                                        |   6 +-
 rust-src/Cargo.lock                           |   2 +-
 rust-src/Cargo.toml                           |   7 +-
 rust-src/bch_bindgen/build.rs                 |   6 +
 .../bch_bindgen/src/libbcachefs_wrapper.h     |   2 +
 rust-src/build.rs                             |  21 +++
 rust-src/src/bcachefs.rs                      | 120 +++++++++++++++++
 rust-src/src/cmd_main.rs                      |  34 -----
 .../src/{ => commands}/cmd_completions.rs     |   3 +-
 rust-src/src/{ => commands}/cmd_list.rs       |   3 +-
 rust-src/src/{ => commands}/cmd_mount.rs      |  11 +-
 rust-src/src/{ => commands}/logger.rs         |   0
 rust-src/src/commands/mod.rs                  |  31 +++++
 rust-src/src/lib.rs                           |  54 --------
 tests/util.py                                 |   2 +-
 17 files changed, 214 insertions(+), 236 deletions(-)
 create mode 100644 rust-src/build.rs
 create mode 100644 rust-src/src/bcachefs.rs
 delete mode 100644 rust-src/src/cmd_main.rs
 rename rust-src/src/{ => commands}/cmd_completions.rs (84%)
 rename rust-src/src/{ => commands}/cmd_list.rs (98%)
 rename rust-src/src/{ => commands}/cmd_mount.rs (94%)
 rename rust-src/src/{ => commands}/logger.rs (100%)
 create mode 100644 rust-src/src/commands/mod.rs
 delete mode 100644 rust-src/src/lib.rs

-- 
2.43.0


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2024-01-22  2:47 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-15  5:24 [PATCH TOOLS 0/2] convert main() from C to Rust Thomas Bertschinger
2024-01-15  5:24 ` [PATCH TOOLS 1/2] " Thomas Bertschinger
2024-01-15  5:24 ` [PATCH TOOLS 2/2] remove library from bcachefs-tools Rust package Thomas Bertschinger
2024-01-15 17:32 ` [PATCH TOOLS 0/2] convert main() from C to Rust Kent Overstreet
2024-01-15 17:55   ` Thomas Bertschinger
2024-01-15 18:45     ` Kent Overstreet
2024-01-15 19:10       ` Thomas Bertschinger
2024-01-15 19:22         ` Kent Overstreet
2024-01-19 19:05           ` Trevor Gross
2024-01-19 21:37             ` Kent Overstreet
2024-01-21 16:11               ` packed, aligned structs in bcachefs (was: Re: [PATCH TOOLS 0/2] convert main() from C to Rust) Thomas Bertschinger
2024-01-21 18:19                 ` Kent Overstreet
2024-01-21 19:32                   ` Thomas Bertschinger
2024-01-22  2:47                     ` Thomas Bertschinger
2024-01-15 17:48 ` [PATCH TOOLS 0/2] convert main() from C to Rust Kent Overstreet
2024-01-15 17:57   ` Thomas Bertschinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox