From: Dan Williams Date: Mon, 10 Nov 2008 16:30:07 +0000 (-0700) Subject: fix add_dev() handling of broken links X-Git-Tag: mdadm-3.0-devel3~71 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf68e9d9ab185121b6004fc81b531bce8348726d;p=thirdparty%2Fmdadm.git 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 --- diff --git a/util.c b/util.c index 8845a0fb..b2fbec7a 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; }