extern void blkid_debug_dump_tag(blkid_tag tag);
#endif
+/* devno.c */
+struct dir_list {
+ char *name;
+ struct dir_list *next;
+};
+extern void blkid__scan_dir(char *, dev_t, struct dir_list **, char **);
+
/* lseek.c */
extern blkid_loff_t blkid_llseek(int fd, blkid_loff_t offset, int whence);
#include "blkidP.h"
+#undef HAVE_DEVMAPPER
+
#ifdef HAVE_DEVMAPPER
#include <libdevmapper.h>
#endif
static int dm_device_is_leaf(const dev_t dev);
#endif
+/* Directories where we will try to search for device names */
+static const char *dirlist[] = { "/dev", "/devfs", "/devices", NULL };
+
/*
* Probe a single block device to add to the device cache.
*/
* the stat information doesn't check out, use blkid_devno_to_devname()
* to find it via an exhaustive search for the device major/minor.
*/
- for (dir = blkid_devdirs; *dir; dir++) {
+ for (dir = dirlist; *dir; dir++) {
struct stat st;
char device[256];
break;
}
}
+ /* Do a short-cut scan of /dev/mapper first */
+ if (!devname)
+ blkid__scan_dir("/dev/mapper", devno, 0, &devname);
if (!devname) {
devname = blkid_devno_to_devname(devno);
if (!devname)
free(devname);
set_pri:
- if (!pri && !strncmp(ptname, "md", 2))
- pri = BLKID_PRI_MD;
- if (dev)
- dev->bid_pri = pri;
+ if (dev) {
+ if (pri)
+ dev->bid_pri = pri;
+ else if (!strncmp(dev->bid_name, "/dev/mapper/", 11))
+ dev->bid_pri = BLKID_PRI_DM;
+ else if (!strncmp(ptname, "md", 2))
+ dev->bid_pri = BLKID_PRI_MD;
+ }
return;
}
#include "blkidP.h"
-struct dir_list {
- char *name;
- struct dir_list *next;
-};
-
char *blkid_strndup(const char *s, int length)
{
char *ret;
*list = NULL;
}
-static void scan_dir(char *dirname, dev_t devno, struct dir_list **list,
- char **devname)
+void blkid__scan_dir(char *dirname, dev_t devno, struct dir_list **list,
+ char **devname)
{
DIR *dir;
struct dirent *dp;
path, *devname));
break;
}
- if (S_ISDIR(st.st_mode) && !lstat(path, &st) &&
+ if (list && S_ISDIR(st.st_mode) && !lstat(path, &st) &&
S_ISDIR(st.st_mode))
add_to_dirlist(path, list);
}
list = list->next;
DBG(DEBUG_DEVNO, printf("directory %s\n", current->name));
- scan_dir(current->name, devno, &new_list, &devname);
+ blkid__scan_dir(current->name, devno, &new_list, &devname);
free(current->name);
free(current);
if (devname)