]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - mdopen.c
Create missing /dev files where needed.
[thirdparty/mdadm.git] / mdopen.c
index 81cf725b02c8c0f3e3b9de3e52c0d781e6ac3f43..8c3eabb45d3148b99bcfb639bebb5b5367dd7af8 100644 (file)
--- a/mdopen.c
+++ b/mdopen.c
@@ -64,9 +64,12 @@ void make_parts(char *dev, int cnt)
                } else {
                        stb2 = stb;
                }
-               mknod(name, S_IFBLK | 0600, makedev(major, minor+i));
-               chown(name, stb2.st_uid, stb2.st_gid);
-               chmod(name, stb2.st_mode & 07777);
+               if (mknod(name, S_IFBLK | 0600, makedev(major, minor+i)))
+                       perror("mknod");
+               if (chown(name, stb2.st_uid, stb2.st_gid))
+                       perror("chown");
+               if (chmod(name, stb2.st_mode & 07777))
+                       perror("chmod");
                stat(name, &stb2);
                add_dev(name, &stb2, 0, NULL);
        }
@@ -158,7 +161,7 @@ int open_mddev(char *dev, int autof)
                        major = get_mdp_major();
                        break;
                case 0: /* not standard, pick an unused number */
-                       mdlist = mdstat_read(0);
+                       mdlist = mdstat_read(0, 0);
                        for (num= (autof>0)?-1:0 ; ; num+= (autof>2)?-1:1) {
                                struct mdstat_ent *me;
                                for (me=mdlist; me; me=me->next)
@@ -173,7 +176,7 @@ int open_mddev(char *dev, int autof)
                                                minor = (-1-num) << MdpMinorShift;
                                        else
                                                minor = num;
-                                       dn = map_dev(major,minor);
+                                       dn = map_dev(major,minor, 0);
                                        if (dn==NULL || is_standard(dn, NULL)) {
                                                /* this number only used by a 'standard' name,
                                                 * so it is safe to use
@@ -205,8 +208,10 @@ int open_mddev(char *dev, int autof)
                                return -1;
                        }
                        if (must_remove) {
-                               chown(dev, stb.st_uid, stb.st_gid);
-                               chmod(dev, stb.st_mode & 07777);
+                               if (chown(dev, stb.st_uid, stb.st_gid))
+                                       perror("chown");
+                               if (chmod(dev, stb.st_mode & 07777))
+                                       perror("chmod");
                        }
                        stat(dev, &stb);
                        add_dev(dev, &stb, 0, NULL);