[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH] Rename mdadm_ apis to md_



This change renames the following 2 apis:
* mdadm_create -> md_create
* mdadm_detail -> md_detail

This is more consistent with list_md_devices, and removes a reference to an
implementation detail from the api.
---
 daemon/md.c                          |   24 ++++++++++++------------
 generator/generator_actions.ml       |    4 ++--
 regressions/test-list-filesystems.sh |    2 +-
 regressions/test-list-md-devices.sh  |    2 +-
 regressions/test-mdadm.sh            |   26 +++++++++++++-------------
 src/inspect_fs_unix.c                |    4 ++--
 6 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/daemon/md.c b/daemon/md.c
index 82ddb82..8e4ff88 100644
--- a/daemon/md.c
+++ b/daemon/md.c
@@ -50,9 +50,9 @@ count_bits (uint64_t bitmap)
 
 /* 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];
@@ -63,10 +63,10 @@ do_mdadm_create (const char *name, char *const *devices,
   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;
@@ -75,7 +75,7 @@ do_mdadm_create (const char *name, char *const *devices,
   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;
@@ -84,7 +84,7 @@ do_mdadm_create (const char *name, char *const *devices,
   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") &&
@@ -100,7 +100,7 @@ do_mdadm_create (const char *name, char *const *devices,
   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");
@@ -131,12 +131,12 @@ do_mdadm_create (const char *name, char *const *devices,
   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);
@@ -233,7 +233,7 @@ error:
 }
 
 char **
-do_mdadm_detail(const char *md)
+do_md_detail(const char *md)
 {
   int r;
 
@@ -290,7 +290,7 @@ do_mdadm_detail(const char *md)
     } 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);
     }
   }
 
diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml
index 925640f..c0ef261 100644
--- a/generator/generator_actions.ml
+++ b/generator/generator_actions.ml
@@ -6432,7 +6432,7 @@ To get the current values of filesystem parameters, see
 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",
    "\
@@ -6496,7 +6496,7 @@ If not set, this defaults to C<raid1>.
    "\
 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",
    "\
diff --git a/regressions/test-list-filesystems.sh b/regressions/test-list-filesystems.sh
index 1144286..353cdd0 100755
--- a/regressions/test-list-filesystems.sh
+++ b/regressions/test-list-filesystems.sh
@@ -50,7 +50,7 @@ vgcreate vg0 /dev/sdb1
 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
diff --git a/regressions/test-list-md-devices.sh b/regressions/test-list-md-devices.sh
index cd12d80..0216ca9 100755
--- a/regressions/test-list-md-devices.sh
+++ b/regressions/test-list-md-devices.sh
@@ -31,7 +31,7 @@ run
 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
 )
 
diff --git a/regressions/test-mdadm.sh b/regressions/test-mdadm.sh
index 8119561..e9b0db5 100755
--- a/regressions/test-mdadm.sh
+++ b/regressions/test-mdadm.sh
@@ -16,7 +16,7 @@
 # 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
 
@@ -53,16 +53,16 @@ part-add /dev/sdd p 12288 16383
 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
@@ -100,11 +100,11 @@ eval `../fish/guestfish --listen`
 ../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
@@ -141,8 +141,8 @@ for md in `../fish/guestfish --remote list-md-devices`; do
   [ ! -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
@@ -150,4 +150,4 @@ done
 
 ../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
diff --git a/src/inspect_fs_unix.c b/src/inspect_fs_unix.c
index 3be49d5..0fa3e83 100644
--- a/src/inspect_fs_unix.c
+++ b/src/inspect_fs_unix.c
@@ -930,7 +930,7 @@ map_app_md_devices (guestfs_h *g, Hash_table **map)
   if (mds == NULL) goto error;
 
   for (char **md = mds; *md != NULL; md++) {
-    char **detail = guestfs_mdadm_detail(g, *md);
+    char **detail = guestfs_md_detail(g, *md);
     if (detail == NULL) goto error;
 
     /* Iterate over keys until we find uuid */
@@ -949,7 +949,7 @@ map_app_md_devices (guestfs_h *g, Hash_table **map)
 
       if (!parse_uuid(*i, entry->uuid)) {
         /* Invalid UUID is weird, but not fatal. */
-        debug(g, "inspect-os: guestfs_mdadm_detail returned invalid "
+        debug(g, "inspect-os: guestfs_md_detail returned invalid "
                  "uuid for %s: %s", *md, *i);
         guestfs___free_string_list(detail);
         md_uuid_free(entry);
-- 
1.7.7.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]