]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - util.c
Handles spaces in array names better.
[thirdparty/mdadm.git] / util.c
diff --git a/util.c b/util.c
index 427a8cf7724c686d00743b98937a76988ac18064..fad72cc951ecad77ce17a44f4575420452d5b4ee 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1834,3 +1834,24 @@ struct mdinfo *container_choose_spares(struct supertype *st,
        }
        return disks;
 }
+
+/* Checks if paths point to the same device
+ * Returns 0 if they do.
+ * Returns 1 if they don't.
+ * Returns -1 if something went wrong,
+ * e.g. paths are empty or the files
+ * they point to don't exist */
+int compare_paths (char* path1, char* path2)
+{
+       struct stat st1,st2;
+
+       if (path1 == NULL || path2 == NULL)
+               return -1;
+       if (stat(path1,&st1) != 0)
+               return -1;
+       if (stat(path2,&st2) != 0)
+               return -1;
+       if ((st1.st_ino == st2.st_ino) && (st1.st_dev == st2.st_dev))
+               return 0;
+       return 1;
+}