]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Make scanning of /dev work even if it is a symlink
authorNeil Brown <neilb@suse.de>
Mon, 27 Mar 2006 06:54:31 +0000 (06:54 +0000)
committerNeil Brown <neilb@suse.de>
Mon, 27 Mar 2006 06:54:31 +0000 (06:54 +0000)
We generally don't want to follow symlinks in /dev, but if
/dev itself is a symlink, we want to follow it.
So nftw needs a bit of help.

Signed-off-by: Neil Brown <neilb@suse.de>
util.c

diff --git a/util.c b/util.c
index ff175009ec8624a2e50fe1d8699a1590cd6e18fb..ab606ab12fa08f4861eb6fef549e89050f6f4131 100644 (file)
--- a/util.c
+++ b/util.c
@@ -384,6 +384,8 @@ int add_dev(const char *name, const struct stat *stb, int flag, struct FTW *s)
     if ((stb->st_mode&S_IFMT)== S_IFBLK) {
        char *n = strdup(name);
        struct devmap *dm = malloc(sizeof(*dm));
+       if (strncmp(n, "/dev/.", 6)==0)
+               strcpy(n+4, name+6);
        if (dm) {
            dm->major = major(stb->st_rdev);
            dm->minor = minor(stb->st_rdev);
@@ -407,7 +409,12 @@ char *map_dev(int major, int minor)
        struct devmap *p;
        char *std = NULL, *nonstd=NULL;
        if (!devlist_ready) {
-               nftw("/dev", add_dev, 10, FTW_PHYS);
+               char *dev = "/dev";
+               struct stat stb;
+               if (lstat(dev, &stb)==0 &&
+                   S_ISLNK(stb.st_mode))
+                       dev = "/dev/.";
+               nftw(dev, add_dev, 10, FTW_PHYS);
                devlist_ready=1;
        }