From b3b041302ee38bb3631d4977baf0f2869a56f515 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Tue, 11 Jul 2023 12:49:48 +0200 Subject: [PATCH] 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 --- Makefile | 2 +- btrfs-find-root.c | 3 ++- btrfs.c | 2 ++ common/box.h | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 86c73590..cc6db02b 100644 --- a/Makefile +++ b/Makefile @@ -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) \ diff --git a/btrfs-find-root.c b/btrfs-find-root.c index e5a60c20..6e32859f 100644 --- a/btrfs-find-root.c +++ b/btrfs-find-root.c @@ -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}; diff --git a/btrfs.c b/btrfs.c index cd0ca130..b0a75f6e 100644 --- a/btrfs.c +++ b/btrfs.c @@ -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; diff --git a/common/box.h b/common/box.h index f3fd312d..27a092be 100644 --- a/common/box.h +++ b/common/box.h @@ -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