/* Takes optional arguments, consult optargs_bitmask. */
int
-do_mdadm_create (const char *name, char *const *devices,
- int64_t missingbitmap, int nrdevices, int spare,
- int64_t chunk, const char *level)
+do_md_create (const char *name, char *const *devices,
+ int64_t missingbitmap, int nrdevices, int spare,
+ int64_t chunk, const char *level)
{
char nrdevices_s[32];
char spare_s[32];
uint64_t umissingbitmap = (uint64_t) missingbitmap;
/* Check the optional parameters and set defaults where appropriate. */
- if (!(optargs_bitmask & GUESTFS_MDADM_CREATE_MISSINGBITMAP_BITMASK))
+ if (!(optargs_bitmask & GUESTFS_MD_CREATE_MISSINGBITMAP_BITMASK))
umissingbitmap = 0;
- if (optargs_bitmask & GUESTFS_MDADM_CREATE_SPARE_BITMASK) {
+ if (optargs_bitmask & GUESTFS_MD_CREATE_SPARE_BITMASK) {
if (spare < 0) {
reply_with_error ("spare must not be negative");
return -1;
else
spare = 0;
- if (optargs_bitmask & GUESTFS_MDADM_CREATE_NRDEVICES_BITMASK) {
+ if (optargs_bitmask & GUESTFS_MD_CREATE_NRDEVICES_BITMASK) {
if (nrdevices < 2) {
reply_with_error ("nrdevices is less than 2");
return -1;
else
nrdevices = count_strings (devices) + count_bits (umissingbitmap);
- if (optargs_bitmask & GUESTFS_MDADM_CREATE_LEVEL_BITMASK) {
+ if (optargs_bitmask & GUESTFS_MD_CREATE_LEVEL_BITMASK) {
if (STRNEQ (level, "linear") && STRNEQ (level, "raid0") &&
STRNEQ (level, "0") && STRNEQ (level, "stripe") &&
STRNEQ (level, "raid1") && STRNEQ (level, "1") &&
else
level = "raid1";
- if (optargs_bitmask & GUESTFS_MDADM_CREATE_CHUNK_BITMASK) {
+ if (optargs_bitmask & GUESTFS_MD_CREATE_CHUNK_BITMASK) {
/* chunk is bytes in the libguestfs API, but K when we pass it to mdadm */
if ((chunk & 1023) != 0) {
reply_with_error ("chunk size must be a multiple of 1024 bytes");
ADD_ARG (argv, i, "--raid-devices");
snprintf (nrdevices_s, sizeof nrdevices_s, "%d", nrdevices);
ADD_ARG (argv, i, nrdevices_s);
- if (optargs_bitmask & GUESTFS_MDADM_CREATE_SPARE_BITMASK) {
+ if (optargs_bitmask & GUESTFS_MD_CREATE_SPARE_BITMASK) {
ADD_ARG (argv, i, "--spare-devices");
snprintf (spare_s, sizeof spare_s, "%d", spare);
ADD_ARG (argv, i, spare_s);
}
- if (optargs_bitmask & GUESTFS_MDADM_CREATE_CHUNK_BITMASK) {
+ if (optargs_bitmask & GUESTFS_MD_CREATE_CHUNK_BITMASK) {
ADD_ARG (argv, i, "--chunk");
snprintf (chunk_s, sizeof chunk_s, "%" PRIi64, chunk / 1024);
ADD_ARG (argv, i, chunk_s);
}
char **
-do_mdadm_detail(const char *md)
+do_md_detail(const char *md)
{
int r;
} else {
/* Ignore lines with no equals sign (shouldn't happen). Log to stderr so
* it will show up in LIBGUESTFS_DEBUG. */
- fprintf(stderr, "mdadm-detail: unexpected output ignored: %s", line);
+ fprintf(stderr, "md-detail: unexpected mdadm output ignored: %s", line);
}
}
C<guestfs_tune2fs_l>. For precise details of how tune2fs
works, see the L<tune2fs(8)> man page.");
- ("mdadm_create", (RErr, [String "name"; DeviceList "devices"], [Int64 "missingbitmap"; Int "nrdevices"; Int "spare"; Int64 "chunk"; String "level"]), 299, [Optional "mdadm"],
+ ("md_create", (RErr, [String "name"; DeviceList "devices"], [Int64 "missingbitmap"; Int "nrdevices"; Int "spare"; Int64 "chunk"; String "level"]), 299, [Optional "mdadm"],
[],
"create a Linux md (RAID) device",
"\
"\
List all Linux md devices.");
- ("mdadm_detail", (RHashtable "info", [Device "md"], []), 301, [Optional "mdadm"],
+ ("md_detail", (RHashtable "info", [Device "md"], []), 301, [Optional "mdadm"],
[],
"obtain metadata for an MD device",
"\
$g->part_add("/dev/sd$_", 'p', 524288, -64);
}
- $g->mdadm_create('boot', ['/dev/sda1', '/dev/sdb1']);
- $g->mdadm_create('root', ['/dev/sda2', '/dev/sdb2']);
+ $g->md_create('boot', ['/dev/sda1', '/dev/sdb1']);
+ $g->md_create('root', ['/dev/sda2', '/dev/sdb2']);
open(my $mdadm, '>', 'mdadm.tmp') or die;
print $mdadm <<EOF;
my $i = 0;
foreach ('boot', 'root') {
- my %detail = $g->mdadm_detail("/dev/md/$_");
+ my %detail = $g->md_detail("/dev/md/$_");
print $mdadm "ARRAY /dev/md$i level=raid1 num-devices=2 UUID=",
$detail{uuid}, "\n";
$i++;
lvcreate lv0 vg0 16
# Create an md device from sda2 and sdb2
-mdadm-create test "/dev/sda2 /dev/sdb2" level:raid1
+md-create test "/dev/sda2 /dev/sdb2" level:raid1
# Create filesystems
mkfs ext3 /dev/sda1
list-md-devices
# Create a raid1 based on the 2 disks
-mdadm-create test "/dev/sda /dev/sdb" level:raid1
+md-create test "/dev/sda /dev/sdb" level:raid1
EOF
)
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-# Test guestfish mdadm-create command.
+# Test guestfish md-create and md-detail commands.
set -e
part-add /dev/sdd p 16384 20479
# RAID 1.
-mdadm-create r1t1 "/dev/sda1 /dev/sdb1"
-mdadm-create r1t2 "/dev/sdc1 /dev/sdd1" chunk:65536
+md-create r1t1 "/dev/sda1 /dev/sdb1"
+md-create r1t2 "/dev/sdc1 /dev/sdd1" chunk:65536
# RAID 5.
-mdadm-create r5t1 "/dev/sda2 /dev/sdb2 /dev/sdc2 /dev/sdd2" \
+md-create r5t1 "/dev/sda2 /dev/sdb2 /dev/sdc2 /dev/sdd2" \
missingbitmap:0x10 nrdevices:4 spare:1 level:5
-mdadm-create r5t2 "/dev/sda3 /dev/sdb3" missingbitmap:0x1 level:5
+md-create r5t2 "/dev/sda3 /dev/sdb3" missingbitmap:0x1 level:5
-mdadm-create r5t3 "/dev/sdc3 /dev/sdd3" \
+md-create r5t3 "/dev/sdc3 /dev/sdd3" \
missingbitmap:0x6 nrdevices:2 spare:2 level:5
# Make some filesystems and put some content on the
../fish/guestfish --remote run
for md in `../fish/guestfish --remote list-md-devices`; do
- ../fish/guestfish --remote mdadm-detail "${md}" > mdadm-detail.out
+ ../fish/guestfish --remote md-detail "${md}" > md-detail.out
- sed 's/:\s*/=/' mdadm-detail.out > mdadm-detail.out.sh
- . mdadm-detail.out.sh
- rm -f mdadm-detail.out.sh
+ sed 's/:\s*/=/' md-detail.out > md-detail.out.sh
+ . md-detail.out.sh
+ rm -f md-detail.out.sh
error=0
case "$name" in
[ ! -z "$metadata" ] || error=1
if [ "$error" == "1" ]; then
- echo "$0: Unexpected output from mdadm-detail for device $md"
- cat mdadm-detail.out
+ echo "$0: Unexpected output from md-detail for device $md"
+ cat md-detail.out
../fish/guestfish --remote exit
exit 1
fi
../fish/guestfish --remote exit
-rm -f mdadm-detail.out md-test1.img md-test2.img md-test3.img md-test4.img
+rm -f md-detail.out md-test1.img md-test2.img md-test3.img md-test4.img