if (devno <= 0)
continue;
- if (sysfs_devno_is_lvm_private(devno) ||
+ if (sysfs_devno_is_lvm_private(devno, NULL) ||
sysfs_devno_is_wholedisk(devno) <= 0)
continue;
extern int sysfs_devno_to_wholedisk(dev_t dev, char *diskname,
size_t len, dev_t *diskdevno);
-extern int sysfs_devno_is_lvm_private(dev_t devno);
+extern int sysfs_devno_is_lvm_private(dev_t devno, char **uuid);
extern int sysfs_devno_is_wholedisk(dev_t devno);
extern int sysfs_scsi_get_hctl(struct sysfs_cxt *cxt, int *h,
}
/*
- * Returns 1 if the device is private LVM device.
+ * Returns 1 if the device is private LVM device. The @uuid (if not NULL)
+ * returns DM device UUID, use free() to deallocate.
*/
-int sysfs_devno_is_lvm_private(dev_t devno)
+int sysfs_devno_is_lvm_private(dev_t devno, char **uuid)
{
struct sysfs_cxt cxt = UL_SYSFSCXT_EMPTY;
- char *uuid = NULL;
+ char *id = NULL;
int rc = 0;
if (sysfs_init(&cxt, devno, NULL) != 0)
return 0;
- uuid = sysfs_strdup(&cxt, "dm/uuid");
+ id = sysfs_strdup(&cxt, "dm/uuid");
/* Private LVM devices use "LVM-<uuid>-<name>" uuid format (important
* is the "LVM" prefix and "-<name>" postfix).
*/
- if (uuid && strncmp(uuid, "LVM-", 4) == 0) {
- char *p = strrchr(uuid + 4, '-');
+ if (id && strncmp(id, "LVM-", 4) == 0) {
+ char *p = strrchr(id + 4, '-');
if (p && *(p + 1))
rc = 1;
}
sysfs_deinit(&cxt);
- free(uuid);
+ if (uuid)
+ *uuid = id;
+ else
+ free(id);
return rc;
}
{
struct stat sb;
uint64_t devsiz = 0;
+ char *dm_uuid = NULL;
blkid_reset_probe(pr);
blkid_probe_reset_buffers(pr);
if (pr->size <= 1440 * 1024 && !S_ISCHR(sb.st_mode))
pr->flags |= BLKID_FL_TINY_DEV;
- if (S_ISBLK(sb.st_mode) && sysfs_devno_is_lvm_private(sb.st_rdev)) {
+ if (S_ISBLK(sb.st_mode) &&
+ sysfs_devno_is_lvm_private(sb.st_rdev, &dm_uuid)) {
DBG(LOWPROBE, ul_debug("ignore private LVM device"));
pr->flags |= BLKID_FL_NOSCAN_DEV;
}
#ifdef CDROM_GET_CAPABILITY
else if (S_ISBLK(sb.st_mode) &&
!blkid_probe_is_tiny(pr) &&
+ !dm_uuid &&
blkid_probe_is_wholedisk(pr) &&
ioctl(fd, CDROM_GET_CAPABILITY, NULL) >= 0) {
cdrom_size_correction(pr);
}
#endif
+ free(dm_uuid);
DBG(LOWPROBE, ul_debug("ready for low-probing, offset=%"PRIu64", size=%"PRIu64"",
pr->off, pr->size));
(unsigned long)diff));
#endif
- if (sysfs_devno_is_lvm_private(st.st_rdev)) {
+ if (sysfs_devno_is_lvm_private(st.st_rdev, NULL)) {
blkid_free_dev(dev);
return NULL;
}