[parted-devel] [PATCH 11/14] Add mdadm specific functions.

Joel Granados Moreno jgranado at redhat.com
Fri Jun 5 12:14:18 UTC 2009


* lvm-utils.sh (mdadm_exists_) : New function.
* lvm-utils.sh (mdadm_create_linear_device_) : New function.
---
 tests/lvm-utils.sh |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
 mode change 100644 => 100755 tests/lvm-utils.sh

diff --git a/tests/lvm-utils.sh b/tests/lvm-utils.sh
old mode 100644
new mode 100755
index 2aba445..53842cb
--- a/tests/lvm-utils.sh
+++ b/tests/lvm-utils.sh
@@ -107,6 +107,31 @@ dmsetup_has_dm_devdir_support_()
        "$?:$out" = "1:Invalid DM_DEV_DIR environment variable value."
 }
 
+mdadm_exists_()
+{
+  mdadm --version > /dev/null 2>&1
+  return $(test "x$?" = "x0")
+}
+
+# Will look for an md number that is not in use and create a md device with
+# that number.  If the system has more than 9 md devices, it will fail.
+mdadm_create_linear_device_()
+{
+  lo_dev=$1
+  mdd=$G_dev_/md0
+  for i in 0 1 2 3 4 5 6 7 8 9 ; do
+    mdd=$G_dev_/md$i
+    mdadm  --create --force $mdd --level=linear --raid-devices=1 $lo_dev > /dev/null 2>&1 \
+    && break
+
+    if [ $i -eq 9 ]; then echo $mdd ; return 1 ; fi
+  done
+
+  echo $mdd
+  return 0
+}
+
+
 # set up private /dev and /etc
 init_root_dir_()
 {
-- 
1.6.0.6




More information about the parted-devel mailing list