Two patches fixing issues with device naming. commit bf68e9d9ab185121b6004fc81b531bce8348726d Author: Dan Williams Date: Mon Nov 10 09:30:07 2008 -0700 fix add_dev() handling of broken links Resolves issues like: mdadm -Ss mdadm: unable to open /dev/md/r1: No such file or directory ...where /dev/md/r1 points to a removed device. Signed-off-by: Dan Williams commit ef70b9f4ef7a3a9f70b3a09b3a55b1cc675c0a37 Author: Dan Williams Date: Sat Nov 8 16:03:07 2008 -0700 fix remove_devices() Don't write to 'pe' if 'path' was not specified Signed-off-by: Dan Williams diff --git a/Manage.c b/Manage.c index 06f9e05..85bb2c8 100644 --- a/Manage.c +++ b/Manage.c @@ -150,10 +150,12 @@ static void remove_devices(int devnum, char *path) for (part = 0; part < 16; part++) { if (part) { sprintf(be, "p%d", part); - if (isdigit(pe[-1])) - sprintf(pe, "p%d", part); - else - sprintf(pe, "%d", part); + if (path) { + if (isdigit(pe[-1])) + sprintf(pe, "p%d", part); + else + sprintf(pe, "%d", part); + } } /* FIXME test if really is md device ?? */ unlink(base); diff --git a/util.c b/util.c index f21d2bb..2b4f902 100644 --- a/util.c +++ b/util.c @@ -467,8 +467,10 @@ int devlist_ready = 0; int add_dev(const char *name, const struct stat *stb, int flag, struct FTW *s) { struct stat st; + if (S_ISLNK(stb->st_mode)) { - stat(name, &st); + if (stat(name, &st) != 0) + return 0; stb = &st; }