]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - util.c
fix add_dev() handling of broken links
[thirdparty/mdadm.git] / util.c
diff --git a/util.c b/util.c
index 1736d70791c8ce5d145f6c01516384f4c19adb30..b2fbec7a91c7f3f2059c66b6ed0488d156b73ca7 100644 (file)
--- a/util.c
+++ b/util.c
@@ -467,8 +467,10 @@ int devlist_ready = 0;
 int add_dev(const char *name, const struct stat *stb, int flag, struct FTW *s)
 {
        struct stat st;
+
        if (S_ISLNK(stb->st_mode)) {
-               stat(name, &st);
+               if (stat(name, &st) != 0)
+                       return 0;
                stb = &st;
        }
 
@@ -842,6 +844,18 @@ int same_dev(char *one, char *two)
        return st1.st_rdev == st2.st_rdev;
 }
 
+void wait_for(char *dev)
+{
+       int i;
+
+       for (i=0 ; i<25 ; i++) {
+               struct stat stb;
+               if (stat(dev, &stb) == 0)
+                       return;
+               usleep(200000);
+       }
+}
+
 struct superswitch *superlist[] = { &super0, &super1, &super_ddf, &super_imsm, NULL };
 
 #if !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO)