summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-04-25 16:33:31 +0100
committerRichard W.M. Jones <rjones@redhat.com>2012-04-25 16:33:31 +0100
commit3cc9703f901e85a589692b9d0bf5ef7cbf72ed73 (patch)
tree122f50d83ccc0fd4182414ae7c7472c3ede86c86
parentbd1a699c15f8854f366abacb47152212e20675ea (diff)
downloadlibguestfs-3cc9703f901e85a589692b9d0bf5ef7cbf72ed73.tar.gz
libguestfs-3cc9703f901e85a589692b9d0bf5ef7cbf72ed73.tar.xz
libguestfs-3cc9703f901e85a589692b9d0bf5ef7cbf72ed73.zip
btrfs: Modify mkfs-btrfs API so it takes a list of devices.
btrfs filesystems can span multiple filesystems. Note this changes the API, but this API has not yet been released in a stable version of libguestfs.
-rw-r--r--daemon/btrfs.c23
-rw-r--r--generator/generator_actions.ml5
2 files changed, 20 insertions, 8 deletions
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index 64d84eda..60c863a4 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -1,5 +1,5 @@
/* libguestfs - the guestfsd daemon
- * Copyright (C) 2011 Red Hat Inc.
+ * Copyright (C) 2011-2012 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -28,8 +28,6 @@
#include "actions.h"
#include "optgroups.h"
-#define MAX_ARGS 64
-
int
optgroup_btrfs_available (void)
{
@@ -40,6 +38,7 @@ optgroup_btrfs_available (void)
int
do_btrfs_filesystem_resize (const char *filesystem, int64_t size)
{
+ const size_t MAX_ARGS = 64;
char *buf;
char *err;
int r;
@@ -87,13 +86,21 @@ do_btrfs_filesystem_resize (const char *filesystem, int64_t size)
/* Takes optional arguments, consult optargs_bitmask. */
int
-do_mkfs_btrfs (const char *device,
+do_mkfs_btrfs (char *const *devices,
int64_t allocstart, int64_t bytecount, const char *datatype,
int leafsize, const char *label, const char *metadata,
int nodesize, int sectorsize)
{
+ size_t nr_devices = count_strings (devices);
+
+ if (nr_devices == 0) {
+ reply_with_error ("list of devices must be non-empty");
+ return -1;
+ }
+
+ size_t MAX_ARGS = nr_devices + 64;
const char *argv[MAX_ARGS];
- size_t i = 0;
+ size_t i = 0, j;
int r;
char *err;
char allocstart_s[64];
@@ -180,12 +187,14 @@ do_mkfs_btrfs (const char *device,
ADD_ARG (argv, i, sectorsize_s);
}
- ADD_ARG (argv, i, device);
+ for (j = 0; j < nr_devices; ++j)
+ ADD_ARG (argv, i, devices[j]);
+
ADD_ARG (argv, i, NULL);
r = commandv (NULL, &err, argv);
if (r == -1) {
- reply_with_error ("%s: %s", device, err);
+ reply_with_error ("%s: %s", devices[0], err);
free (err);
return -1;
}
diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml
index 5bdc063d..56af327a 100644
--- a/generator/generator_actions.ml
+++ b/generator/generator_actions.ml
@@ -6929,7 +6929,7 @@ replacement
=back");
- ("mkfs_btrfs", (RErr, [Device "device"], [OInt64 "allocstart"; OInt64 "bytecount"; OString "datatype"; OInt "leafsize"; OString "label"; OString "metadata"; OInt "nodesize"; OInt "sectorsize"]), 317, [Optional "btrfs"],
+ ("mkfs_btrfs", (RErr, [DeviceList "devices"], [OInt64 "allocstart"; OInt64 "bytecount"; OString "datatype"; OInt "leafsize"; OString "label"; OString "metadata"; OInt "nodesize"; OInt "sectorsize"]), 317, [Optional "btrfs"],
[InitEmpty, Always, TestRun (
[["part_disk"; "/dev/sda"; "mbr"];
["mkfs_btrfs"; "/dev/sda1"; "0"; "268435456"; "single"; "4096"; "test"; "single"; "4096"; "512"]])],
@@ -6938,6 +6938,9 @@ replacement
Create a btrfs filesystem, allowing all configurables to be set.
For more information on the optional arguments, see L<mkfs.btrfs(8)>.
+Since btrfs filesystems can span multiple devices, this takes a
+non-empty list of devices.
+
To create general filesystems, use C<guestfs_mkfs_opts>.");
("get_e2attrs", (RString "attrs", [Pathname "file"], []), 318, [],