]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Start kpartx for imsm devices.
authorNeilBrown <neilb@suse.de>
Fri, 7 Nov 2008 11:22:41 +0000 (22:22 +1100)
committerNeilBrown <neilb@suse.de>
Fri, 7 Nov 2008 11:22:41 +0000 (22:22 +1100)
This probably wont get into mainline, but is need on SLES
to create partitions that the YaST partitioner has a chance
of recognising.

Signed-off-by: NeilBrown <neilb@suse.de>
Assemble.c
Create.c
Manage.c
mdadm.h
super-intel.c
util.c

index 20c4be7a4e7bc6dd5c102038e971aab4df8494fa..c597526da76ffc6ae237991fc515928d387d6bde 100644 (file)
@@ -1251,8 +1251,10 @@ int assemble_container_content(struct supertype *st, int mdfd,
                                fprintf(stderr, " (%d new)", working);
                        fprintf(stderr, "\n");
                }
-               wait_for(chosen_name);
                close(mdfd);
+               wait_for(chosen_name);
+               if (st->ss->match_metadata_desc("imsm"))
+                       run_kpartx('a', chosen_name);
                return 0;
                /* FIXME should have an O_EXCL and wait for read-auto */
        } else {
index 783ab09f974bff2c5721bbdc29c227f0597a7b63..4368107c21046df54e203306471f4da788d954be 100644 (file)
--- a/Create.c
+++ b/Create.c
@@ -780,7 +780,10 @@ int Create(struct supertype *st, char *mddev,
                        ping_monitor(devnum2devname(st->container_dev));
                        close(container_fd);
                }
+               close(mdfd);
                wait_for(chosen_name);
+               if (st->ss->match_metadata_desc("imsm"))
+                       run_kpartx('a', chosen_name);
        } else {
                fprintf(stderr, Name ": not starting array - not enough devices.\n");
        }
index 9424650301ddef0d7f44c4ccc94c78b891106f4c..06f9e05c6e0b057c6d9aadd93eee047874da5bcf 100644 (file)
--- a/Manage.c
+++ b/Manage.c
@@ -219,8 +219,12 @@ int Manage_runstop(char *devname, int fd, int runstop, int quiet)
                if (mdi &&
                    mdi->array.level > 0 &&
                    is_subarray(mdi->text_version)) {
+                       struct map_ent *me = map_by_devnum(&map, devnum);
                        /* This is mdmon managed. */
                        close(fd);
+                       
+                       /* Delete any kpartx partitions */
+                       run_kpartx('d', me->path);
                        if (sysfs_set_str(mdi, NULL,
                                          "array_state", "inactive") < 0) {
                                if (quiet == 0)
diff --git a/mdadm.h b/mdadm.h
index 2b34acffd5a0d1878d13492a4c654112b1d731cc..9d819f96257f5ff6fef807a0dc6d485814e135dc 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -833,6 +833,7 @@ extern char *devnum2devname(int num);
 extern int devname2devnum(char *name);
 extern int stat2devnum(struct stat *st);
 extern int fd2devnum(int fd);
+extern void run_kpartx(char mode, char *dev);
 
 static inline int dev2major(int d)
 {
index a2b9bd26911b1fa83c76348657dfbc2bdb399731..5f06f30e65ff51d8a847a794d0781231569f9b0b 100644 (file)
@@ -636,7 +636,7 @@ static void brief_examine_super_imsm(struct supertype *st)
                getinfo_super_imsm(st, &info);
                fname_from_uuid(st, &info, nbuf1,'-');
                printf("ARRAY /dev/md/%.16s container=%s\n"
-                      "   member=%d auto=mdp UUID=%s\n",
+                      "   member=%d auto=md UUID=%s\n",
                       dev->volume, nbuf + 5, i, nbuf1 + 5);
        }
 }
diff --git a/util.c b/util.c
index 8845a0fb09bc452d6851c15d346c00eee4a8e5dd..f21d2bb31c565e503b6e2629320f51517248f8d5 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1327,6 +1327,31 @@ void append_metadata_update(struct supertype *st, void *buf, int len)
 }
 #endif /* MDASSEMBLE */
 
+void run_kpartx(char mode, char *dev)
+{
+       char buf[1024];
+       char *cp;
+
+       sprintf(buf, "/sbin/kpartx > /dev/null 2>&1 -%c '", mode);
+
+       cp = buf + strlen(buf);
+       while (cp < buf+sizeof(buf)-10 &&
+              *dev) {
+               if (*dev == '\'') {
+                       *cp++ = '\'';
+                       *cp++ = '\\';
+                       *cp++ = '\'';
+                       /* *cp++ = '\''; */
+               }
+               *cp ++ = *dev++;
+       }
+       *cp++ = '\'';
+       *cp++ = 0;
+       system(buf);
+}
+       
+
+
 #ifdef __TINYC__
 /* tinyc doesn't optimize this check in ioctl.h out ... */
 unsigned int __invalid_size_argument_for_IOC = 0;