]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - util.c
Remvoe blank line from '--examine --brief' output.
[thirdparty/mdadm.git] / util.c
diff --git a/util.c b/util.c
index db4fbf38520e499067ce9fa5f44d77b5b3655001..e702b8d24020486ae992dad5bf2e425354e41862 100644 (file)
--- a/util.c
+++ b/util.c
@@ -118,10 +118,31 @@ int get_linux_version()
        return (a*1000000)+(b*1000)+c;
 }
 
-int enough(int level, int raid_disks, int avail_disks)
+int enough(int level, int raid_disks, int layout,
+          char *avail, int avail_disks)
 {
+       int copies, first;
        switch (level) {
-       case 10: return 1; /* a lie, but it is hard to tell */
+       case 10:
+               /* This is the tricky one - we need to check
+                * which actual disks are present.
+                */
+               copies = (layout&255)* (layout>>8);
+               first=0;
+               do {
+                       /* there must be one of the 'copies' form 'first' */
+                       int n = copies;
+                       int cnt=0;
+                       while (n--) {
+                               if (avail[first])
+                                       cnt++;
+                               first = (first+1) % raid_disks;
+                       }
+                       if (cnt == 0)
+                               return 0;
+
+               } while (first != 0);
+               return 1;
 
        case -4:
                return avail_disks>= 1;