summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek BehĂșn <marek.behun@nic.cz>2017-09-03 15:00:30 (GMT)
committerTom Rini <trini@konsulko.com>2017-10-03 01:52:18 (GMT)
commit9d845509553e3c07414259ea97e4f59a3fe65904 (patch)
tree3de68025da896761c5d0e0a73cb3e003fc2c93b3
parent0c936ee3194ac5b533a18fcd08e5d285853af5fe (diff)
downloadu-boot-9d845509553e3c07414259ea97e4f59a3fe65904.tar.xz
cmd: Add the 'btrsubvol' command to list BTRFS subvolumes
Signed-off-by: Marek Behun <marek.behun@nic.cz> create mode 100644 cmd/btrfs.c
-rw-r--r--cmd/Kconfig10
-rw-r--r--cmd/Makefile1
-rw-r--r--cmd/btrfs.c28
3 files changed, 39 insertions, 0 deletions
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 3ef9b16..07ec03b 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1313,6 +1313,16 @@ config CMD_CROS_EC
endmenu
menu "Filesystem commands"
+config CMD_BTRFS
+ bool "Enable the 'btrsubvol' command"
+ select FS_BTRFS
+ help
+ This enables the 'btrsubvol' command to list subvolumes
+ of a BTRFS filesystem. There are no special commands for
+ listing BTRFS directories or loading BTRFS files - this
+ can be done by the generic 'fs' commands (see CMD_FS_GENERIC)
+ when BTRFS is enabled (see FS_BTRFS).
+
config CMD_CBFS
bool "Enable the 'cbfs' command"
depends on FS_CBFS
diff --git a/cmd/Makefile b/cmd/Makefile
index 2a5b8ce..2b0444d 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_CMD_BOOTMENU) += bootmenu.o
obj-$(CONFIG_CMD_BOOTSTAGE) += bootstage.o
obj-$(CONFIG_CMD_BOOTZ) += bootz.o
obj-$(CONFIG_CMD_BOOTI) += booti.o
+obj-$(CONFIG_CMD_BTRFS) += btrfs.o
obj-$(CONFIG_CMD_CACHE) += cache.o
obj-$(CONFIG_CMD_CBFS) += cbfs.o
obj-$(CONFIG_CMD_CLK) += clk.o
diff --git a/cmd/btrfs.c b/cmd/btrfs.c
new file mode 100644
index 0000000..3f4f1b7
--- /dev/null
+++ b/cmd/btrfs.c
@@ -0,0 +1,28 @@
+/*
+ * 2017 by Marek Behun <marek.behun@nic.cz>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <command.h>
+#include <btrfs.h>
+#include <fs.h>
+
+int do_btrsubvol(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
+{
+ if (argc != 3)
+ return CMD_RET_USAGE;
+
+ if (fs_set_blk_dev(argv[1], argv[2], FS_TYPE_BTRFS))
+ return 1;
+
+ btrfs_list_subvols();
+ return 0;
+}
+
+U_BOOT_CMD(btrsubvol, 3, 1, do_btrsubvol,
+ "list subvolumes of a BTRFS filesystem",
+ "<interface> <dev[:part]>\n"
+ " - List subvolumes of a BTRFS filesystem."
+)