]> git.sesse.net Git - bcachefs-tools-debian/commit
create common entry point for Rust commands
authorThomas Bertschinger <tahbertschinger@gmail.com>
Mon, 8 Jan 2024 01:36:33 +0000 (18:36 -0700)
committerKent Overstreet <kent.overstreet@linux.dev>
Mon, 8 Jan 2024 02:38:31 +0000 (21:38 -0500)
commit9a9af6e9e6560407326b37345ebe434a0839420f
treee105d7ed49fb20988e9e9c6c1a94fc2d6bb63475
parentb90031efaa4500b8ce5ffc55e9d1ed716196b814
create common entry point for Rust commands

The bcachefs sub-commands that are implemented in Rust (completions,
list, and mount) had separate entrypoints and thus had some differences
in behavior.

This introduces a common entry point for the Rust sub-commands. This
reduces duplicate boilerplate code like parsing argv and setting up
logging, and will facilitate converting more sub-commands to Rust in
the future.

An immediate benefit is that this fixes an issue with `bcachefs list`
not reporting errors:

before:

$ bcachefs list /dev/typo
$ echo $?
0

after:

$ bcachefs list /dev/typo
ERROR - bcachefs_rust::cmd_list: Fatal error: "No such file or directory"
$ echo $?
1

Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
bcachefs.c
cmds.h
rust-src/src/cmd_completions.rs
rust-src/src/cmd_list.rs
rust-src/src/cmd_main.rs [new file with mode: 0644]
rust-src/src/cmd_mount.rs
rust-src/src/lib.rs