80 lines
2.1 KiB
Diff
80 lines
2.1 KiB
Diff
|
From 59596810b009744316941da8ef18b7e75b503b9f Mon Sep 17 00:00:00 2001
|
||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||
|
Date: Fri, 15 Nov 2013 09:05:43 +0000
|
||
|
Subject: [PATCH] daemon: btrfs: Upstream 'btrfs device add' command now needs
|
||
|
'--force' option to work.
|
||
|
|
||
|
However earlier versions didn't have the --force option, so we
|
||
|
have to detect it.
|
||
|
---
|
||
|
daemon/btrfs.c | 35 +++++++++++++++++++++++++++++++----
|
||
|
1 file changed, 31 insertions(+), 4 deletions(-)
|
||
|
|
||
|
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
|
||
|
index 765dec6..0b877f8 100644
|
||
|
--- a/daemon/btrfs.c
|
||
|
+++ b/daemon/btrfs.c
|
||
|
@@ -588,14 +588,29 @@ do_btrfs_filesystem_balance (const char *fs)
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
+/* Test if 'btrfs device add' needs the --force option (added
|
||
|
+ * c.2013-09) in order to work.
|
||
|
+ */
|
||
|
+static int
|
||
|
+test_btrfs_device_add_needs_force (void)
|
||
|
+{
|
||
|
+ int r;
|
||
|
+ CLEANUP_FREE char *out = NULL, *err = NULL;
|
||
|
+
|
||
|
+ r = command (&out, &err, "btrfs", "device", "add", "--help", NULL);
|
||
|
+ if (r == -1) {
|
||
|
+ reply_with_error ("%s: %s", "btrfs device add --help", err);
|
||
|
+ return -1;
|
||
|
+ }
|
||
|
+
|
||
|
+ return strstr (out, "--force") != NULL;
|
||
|
+}
|
||
|
+
|
||
|
int
|
||
|
do_btrfs_device_add (char *const *devices, const char *fs)
|
||
|
{
|
||
|
+ static int btrfs_device_add_needs_force = -1;
|
||
|
size_t nr_devices = count_strings (devices);
|
||
|
-
|
||
|
- if (nr_devices == 0)
|
||
|
- return 0;
|
||
|
-
|
||
|
size_t MAX_ARGS = nr_devices + 8;
|
||
|
const char *argv[MAX_ARGS];
|
||
|
size_t i = 0, j;
|
||
|
@@ -603,6 +618,15 @@ do_btrfs_device_add (char *const *devices, const char *fs)
|
||
|
CLEANUP_FREE char *err = NULL;
|
||
|
int r;
|
||
|
|
||
|
+ if (nr_devices == 0)
|
||
|
+ return 0;
|
||
|
+
|
||
|
+ if (btrfs_device_add_needs_force == -1) {
|
||
|
+ btrfs_device_add_needs_force = test_btrfs_device_add_needs_force ();
|
||
|
+ if (btrfs_device_add_needs_force == -1)
|
||
|
+ return -1;
|
||
|
+ }
|
||
|
+
|
||
|
fs_buf = sysroot_path (fs);
|
||
|
if (fs_buf == NULL) {
|
||
|
reply_with_perror ("malloc");
|
||
|
@@ -613,6 +637,9 @@ do_btrfs_device_add (char *const *devices, const char *fs)
|
||
|
ADD_ARG (argv, i, "device");
|
||
|
ADD_ARG (argv, i, "add");
|
||
|
|
||
|
+ if (btrfs_device_add_needs_force)
|
||
|
+ ADD_ARG (argv, i, "--force");
|
||
|
+
|
||
|
for (j = 0; j < nr_devices; ++j)
|
||
|
ADD_ARG (argv, i, devices[j]);
|
||
|
|
||
|
--
|
||
|
1.8.3.1
|
||
|
|