]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Monitor.c
mdadm/util: unify stat checking blkdev into function
[thirdparty/mdadm.git] / Monitor.c
index 036a561c6f99684ec809c4da0fb0804296eba01f..e2b36fff295a998d13b4415dd52c667e1b9fac6d 100644 (file)
--- a/Monitor.c
+++ b/Monitor.c
@@ -993,23 +993,13 @@ static void link_containers_with_subarrays(struct state *list)
 /* Not really Monitor but ... */
 int Wait(char *dev)
 {
-       struct stat stb;
        char devnm[32];
-       char *tmp;
        int rv = 1;
        int frozen_remaining = 3;
 
-       if (stat(dev, &stb) != 0) {
-               pr_err("Cannot find %s: %s\n", dev,
-                       strerror(errno));
+       if (!stat_is_blkdev(dev, NULL))
                return 2;
-       }
-       tmp = stat2devnm(&stb);
-       if (!tmp) {
-               pr_err("%s is not a block device.\n", dev);
-               return 2;
-       }
-       strcpy(devnm, tmp);
+       strcpy(devnm, dev);
 
        while(1) {
                struct mdstat_ent *ms = mdstat_read(1, 0);
@@ -1058,8 +1048,6 @@ int Wait(char *dev)
        }
 }
 
-#ifndef MDASSEMBLE
-
 static char *clean_states[] = {
        "clear", "inactive", "readonly", "read-auto", "clean", NULL };
 
@@ -1070,6 +1058,8 @@ int WaitClean(char *dev, int sock, int verbose)
        int rv = 1;
        char devnm[32];
 
+       if (!stat_is_blkdev(dev, NULL))
+               return 2;
        fd = open(dev, O_RDONLY);
        if (fd < 0) {
                if (verbose)
@@ -1151,4 +1141,3 @@ int WaitClean(char *dev, int sock, int verbose)
 
        return rv;
 }
-#endif /* MDASSEMBLE */