Whamcloud - gitweb
blkid_devno_to_devname(): Avoid recursive loops due to symlinks in /dev
authorTheodore Ts'o <tytso@mit.edu>
Mon, 25 Sep 2006 02:33:38 +0000 (22:33 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 25 Sep 2006 02:33:38 +0000 (22:33 -0400)
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/blkid/ChangeLog
lib/blkid/devno.c

index e4939e0..b0a8098 100644 (file)
@@ -1,3 +1,8 @@
+2006-09-24  Theodore Tso  <tytso@mit.edu>
+
+       * devno.c (scan_dir): Don't follow symlinks when recursively
+               searching directories under /dev.
+
 2006-09-17  Karel Zak  <kzak@redhat.com> 
 
        * probe.c (probe_fat): Fix problem with empty FAT label.
index bd9fc12..61b34bf 100644 (file)
@@ -120,15 +120,16 @@ static void scan_dir(char *dirname, dev_t devno, struct dir_list **list,
                if (stat(path, &st) < 0)
                        continue;
 
-               if (S_ISDIR(st.st_mode))
-                       add_to_dirlist(path, list);
-               else if (S_ISBLK(st.st_mode) && st.st_rdev == devno) {
+               if (S_ISBLK(st.st_mode) && st.st_rdev == devno) {
                        *devname = blkid_strdup(path);
                        DBG(DEBUG_DEVNO,
                            printf("found 0x%llx at %s (%p)\n", (long long)devno,
                                   path, *devname));
                        break;
                }
+               if (S_ISDIR(st.st_mode) && !lstat(path, &st) && 
+                   S_ISDIR(st.st_mode))
+                       add_to_dirlist(path, list);
        }
        closedir(dir);
        return;