btrfs-progs: add btrfs-find-root to btrfs.box

There's a report that btrfs-find-root does not work as built-in tool in
btrfs.box, while it's advertised in the help:

  $ ./btrfs.box help --box
  Standalone tools built-in in the busybox style:
  - mkfs.btrfs
  - btrfs-image
  - btrfs-convert
  - btrfstune
  - btrfs-find-root

Add the support as it might be useful tool sometimes. In the future the
command should be moved to e.g. inspect-internal or rescue.

Issue: #648
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2023-07-11 12:49:48 +02:00
parent 7446f2ce71
commit b3b041302e
4 changed files with 6 additions and 2 deletions

View file

@ -325,7 +325,7 @@ MAKEOPTS = --no-print-directory Q=$(Q)
# built-in sources into "busybox", all files that contain the main function and
# are not compiled standalone
progs_box_main = btrfs.o mkfs/main.o image/main.o convert/main.o \
tune/main.o
tune/main.o btrfs-find-root.o
progs_box_all_objects = $(mkfs_objects) $(image_objects) $(convert_objects) $(tune_objects)
progs_box_all_static_objects = $(static_mkfs_objects) $(static_image_objects) \

View file

@ -25,6 +25,7 @@
#include "kernel-shared/disk-io.h"
#include "kernel-shared/volumes.h"
#include "kernel-shared/extent_io.h"
#include "common/box.h"
#include "common/utils.h"
#include "common/extent-cache.h"
#include "common/help.h"
@ -329,7 +330,7 @@ static const struct cmd_struct btrfs_find_root_cmd = {
"btrfs-find-root", NULL, btrfs_find_root_usage, NULL, 0,
};
int main(int argc, char **argv)
int BOX_MAIN(find_root)(int argc, char **argv)
{
struct btrfs_fs_info *fs_info;
struct btrfs_find_root_filter filter = {0};

View file

@ -420,6 +420,8 @@ int main(int argc, char **argv)
return convert_main(argc, argv);
} else if (!strcmp(bname, "btrfstune")) {
return btrfstune_main(argc, argv);
} else if (!strcmp(bname, "btrfs-find-root")) {
return find_root_main(argc, argv);
#endif
} else {
int shift;

View file

@ -33,6 +33,7 @@ DECLARE_BOX_MAIN(mkfs);
DECLARE_BOX_MAIN(image);
DECLARE_BOX_MAIN(convert);
DECLARE_BOX_MAIN(btrfstune);
DECLARE_BOX_MAIN(find_root);
#else
#define BOX_MAIN(standalone) main