@@ -193,8 +193,12 @@ ifeq ($(CONFIG_EXT_FILESYSTEM),y)
LDLIBS += ext2fs uuid blkid
endif
+ifeq ($(CONFIG_BTRFS_FILESYSTEM_USELIBMKFS),y)
+LDLIBS += mkfsbtrfs
+endif
+
ifeq ($(CONFIG_BTRFS_FILESYSTEM),y)
-LDLIBS += mkfsbtrfs btrfs btrfsutil udev
+LDLIBS += btrfs btrfsutil udev
endif
ifeq ($(CONFIG_UNIQUEUUID),y)
@@ -28,4 +28,16 @@ config BTRFS_FILESYSTEM
comment "BTRFS file system creation support needs libbtrfs libbtrfsutil"
depends on !HAVE_LIBBTRFS
+
+config BTRFS_FILESYSTEM_USELIBMKFS
+ bool "Use modified source from btrfs tool to be linked as lib"
+ depends on HAVE_LIBBTRFS
+ default n
+ help
+ This requires at the moment a patched version of btrfs-tool to export
+ mkfs.btrf as library.
+
+comment "BTRFS file system creation support needs libbtrfs libbtrfsutil"
+ depends on !HAVE_LIBBTRFS
+
endif
@@ -28,7 +28,6 @@ extern int mkfs_main(int argc, const char **argv);
int btrfs_mkfs(const char *device_name, const char __attribute__ ((__unused__)) *fstype)
{
int fd, ret;
- int argc;
const char *argv[3] = { "mkfs.btrfs", "-f", NULL };
if (!device_name)
@@ -44,9 +43,21 @@ int btrfs_mkfs(const char *device_name, const char __attribute__ ((__unused__))
optind = 1;
argv[2] = device_name;
- argc = 3;
+#if defined(CONFIG_BTRFS_FILESYSTEM_USELIBMKFS)
+ int argc;
+ argc = 3;
ret = run_function_background(mkfs_main, argc, (char **)argv);
+#else
+ char *cmd;
+
+ if (asprintf(&cmd, "%s %s %s\n", argv[0], argv[1], argv[2]) == -1) {
+ ERROR("Error allocating memory");
+ return -ENOMEM;
+ }
+
+ ret = run_system_cmd(cmd);
+#endif
return ret;
}
It is planned and desired that libbtrfsutil will add the mkfs feature, and this can get rid of patching btrfs-util. This remains an option, but also add the (temporary) way to exec mkfs.btrfs in context of the diskpart handler. Signed-off-by: Stefano Babic <sbabic@denx.de> --- Makefile.flags | 6 +++++- fs/Config.in | 12 ++++++++++++ fs/btrfs.c | 15 +++++++++++++-- 3 files changed, 30 insertions(+), 3 deletions(-)