diff options
author | NeilBrown <neilb@suse.de> | 2009-05-11 15:47:10 +1000 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2009-05-11 15:47:10 +1000 |
commit | 339c2d6c5e45394ff903c347d410897651c4aee1 (patch) | |
tree | bb813155df342755a7e081929a51a831c5b8f189 | |
parent | 8615dcff2865a01e17bb63cdbcc6064c3c1b424a (diff) | |
download | mdadm-339c2d6c5e45394ff903c347d410897651c4aee1.tar.gz mdadm-339c2d6c5e45394ff903c347d410897651c4aee1.tar.xz mdadm-339c2d6c5e45394ff903c347d410897651c4aee1.zip |
Incr: cope better with possibility that mp->path might be NULL
Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r-- | Incremental.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/Incremental.c b/Incremental.c index 8e711d9..ec94be4 100644 --- a/Incremental.c +++ b/Incremental.c @@ -283,16 +283,9 @@ int Incremental(char *devname, int verbose, int runstop, */ map_lock(&map); mp = map_by_uuid(&map, info.uuid); - if (mp) { - mdfd = open_mddev(mp->path, 0); - if (mdfd < 0 && mddev_busy(mp->devnum)) { - /* maybe udev hasn't created it yet. */ - char buf[50]; - sprintf(buf, "%d:%d", dev2major(mp->devnum), - dev2minor(mp->devnum)); - mdfd = dev_open(buf, O_RDWR); - } - } else + if (mp) + mdfd = open_dev(mp->devnum); + else mdfd = -1; if (mdfd < 0) { @@ -357,7 +350,10 @@ int Incremental(char *devname, int verbose, int runstop, struct supertype *st2; struct mdinfo info2, *d; - strcpy(chosen_name, mp->path); + if (mp->path) + strcpy(chosen_name, mp->path); + else + strcpy(chosen_name, devnum2devname(mp->devnum)); sra = sysfs_read(mdfd, fd2devnum(mdfd), (GET_DEVS | GET_STATE)); @@ -662,7 +658,7 @@ int IncrementalScan(int verbose) mdu_array_info_t array; mdu_bitmap_file_t bmf; struct mdinfo *sra; - int mdfd = open_mddev(me->path, 0); + int mdfd = open_dev(me->devnum); if (mdfd < 0) continue; @@ -673,8 +669,8 @@ int IncrementalScan(int verbose) } /* Ok, we can try this one. Maybe it needs a bitmap */ for (mddev = devs ; mddev ; mddev = mddev->next) - if (mddev->devname - && strcmp(mddev->devname, me->path) == 0) + if (mddev->devname && me->path + && strcmp(mddev->devname, me->path)) break; if (mddev && mddev->bitmap_file) { /* @@ -708,11 +704,12 @@ int IncrementalScan(int verbose) if (verbose >= 0) fprintf(stderr, Name ": started array %s\n", - me->path); + me->path ?: devnum2devname(me->devnum)); } else { fprintf(stderr, Name ": failed to start array %s: %s\n", - me->path, strerror(errno)); + me->path ?: devnum2devname(me->devnum), + strerror(errno)); rv = 1; } } @@ -768,7 +765,10 @@ int Incremental_container(struct supertype *st, char *devname, int verbose, if (mp) { mdfd = open_dev(mp->devnum); - strcpy(chosen_name, mp->path); + if (mp->path) + strcpy(chosen_name, mp->path); + else + strcpy(chosen_name, devnum2devname(mp->devnum)); } else { /* Check in mdadm.conf for container == devname and |