]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - Manage.c
Make sure --auto=mdp is honoured properly
[thirdparty/mdadm.git] / Manage.c
index 3deb8ead690d8a2af899e1fc366626192f1a529a..7a96d4509a513e9ecda638b93bb04f6baada1b0c 100644 (file)
--- a/Manage.c
+++ b/Manage.c
@@ -384,9 +384,9 @@ int Manage_subdevs(char *devname, int fd,
                                else if (osuper) {
                                        st->ss->uuid_from_super(ouuid, osuper);
                                        if (memcmp(duuid, ouuid, sizeof(ouuid))==0) {
-                                               /* look close enough for now.  Kernel
-                                                * will worry about where a bitmap
-                                                * based reconstruct is possible
+                                               /* looks close enough for now.  Kernel
+                                                * will worry about whether a bitmap
+                                                * based reconstruction is possible.
                                                 */
                                                struct mdinfo mdi;
                                                st->ss->getinfo_super(&mdi, osuper);
@@ -395,6 +395,8 @@ int Manage_subdevs(char *devname, int fd,
                                                disc.number = mdi.disk.number;
                                                disc.raid_disk = mdi.disk.raid_disk;
                                                disc.state = mdi.disk.state;
+                                               if (dv->writemostly)
+                                                       disc.state |= 1 << MD_DISK_WRITEMOSTLY;
                                                if (ioctl(fd, ADD_NEW_DISK, &disc) == 0) {
                                                        if (verbose >= 0)
                                                                fprintf(stderr, Name ": re-added %s\n", dv->devname);
@@ -507,4 +509,17 @@ int Manage_subdevs(char *devname, int fd,
        return 0;
        
 }
+
+int autodetect(void)
+{
+       /* Open any md device, and issue the RAID_AUTORUN ioctl */
+       int rv = 1;
+       int fd = dev_open("9:0", O_RDONLY);
+       if (fd >= 0) {
+               if (ioctl(fd, RAID_AUTORUN, 0) == 0)
+                       rv = 0;
+               close(fd);
+       }
+       return rv;
+}
 #endif