- /* Must skip ".." since that is "/", and so we
- * would get a false positive on ".." */
- if (strcmp(entry->d_name, "..") == 0)
- continue;
-
- fileName = concat_path_file("/dev/", entry->d_name);
-
- /* Some char devices have the same dev_t as block
- * devices, so make sure this is a block device */
- if (stat(fileName, &statBuf) == 0 &&
- S_ISBLK(statBuf.st_mode)!=0 &&
- statBuf.st_rdev == rootStat.st_rdev) {
- return fileName;
+ /* Some char devices have the same dev_t as block
+ * devices, so make sure this is a block device */
+ if (stat(fileName, &statBuf) == 0 &&
+ S_ISBLK(statBuf.st_mode)!=0 &&
+ statBuf.st_rdev == dev)
+ break;
+ free(fileName);
+ fileName=NULL;
+ }
+ closedir(dir);