Skip to content

Commit

Permalink
libblkid: ignore private Stratis devices
Browse files Browse the repository at this point in the history
[[email protected]: - tiny coding style changes]

References: 20e1c3d
Signed-off-by: Tony Asleson <[email protected]>
Signed-off-by: Karel Zak <[email protected]>
  • Loading branch information
tasleson authored and karelzak committed Mar 9, 2018
1 parent e34dcfb commit 80ec018
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion disk-utils/fdisk-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ char *next_proc_partition(FILE **f)
if (devno <= 0)
continue;

if (sysfs_devno_is_lvm_private(devno, NULL) ||
if (sysfs_devno_is_dm_private(devno, NULL) ||
sysfs_devno_is_wholedisk(devno) <= 0)
continue;

Expand Down
2 changes: 1 addition & 1 deletion include/sysfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ extern int sysfs_is_partition_dirent(DIR *dir, struct dirent *d,
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, char **uuid);
extern int sysfs_devno_is_dm_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,
Expand Down
24 changes: 15 additions & 9 deletions lib/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -844,10 +844,10 @@ int sysfs_devno_to_wholedisk(dev_t dev, char *diskname,
}

/*
* Returns 1 if the device is private LVM device. The @uuid (if not NULL)
* returns DM device UUID, use free() to deallocate.
* Returns 1 if the device is private device mapper device. The @uuid
* (if not NULL) returns DM device UUID, use free() to deallocate.
*/
int sysfs_devno_is_lvm_private(dev_t devno, char **uuid)
int sysfs_devno_is_dm_private(dev_t devno, char **uuid)
{
struct sysfs_cxt cxt = UL_SYSFSCXT_EMPTY;
char *id = NULL;
Expand All @@ -857,15 +857,21 @@ int sysfs_devno_is_lvm_private(dev_t devno, char **uuid)
return 0;

id = sysfs_strdup(&cxt, "dm/uuid");
if (id) {
/* Private LVM devices use "LVM-<uuid>-<name>" uuid format (important
* is the "LVM" prefix and "-<name>" postfix).
*/
if (strncmp(id, "LVM-", 4) == 0) {
char *p = strrchr(id + 4, '-');

/* Private LVM devices use "LVM-<uuid>-<name>" uuid format (important
* is the "LVM" prefix and "-<name>" postfix).
*/
if (id && strncmp(id, "LVM-", 4) == 0) {
char *p = strrchr(id + 4, '-');
if (p && *(p + 1))
rc = 1;

if (p && *(p + 1))
/* Private Stratis devices prefix the UUID with "stratis-1-private"
*/
} else if (strncmp(id, "stratis-1-private", 17) == 0) {
rc = 1;
}
}

sysfs_deinit(&cxt);
Expand Down
4 changes: 2 additions & 2 deletions libblkid/src/probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -923,8 +923,8 @@ int blkid_probe_set_device(blkid_probe pr, int fd,
pr->flags |= BLKID_FL_TINY_DEV;

if (S_ISBLK(sb.st_mode) &&
sysfs_devno_is_lvm_private(sb.st_rdev, &dm_uuid)) {
DBG(LOWPROBE, ul_debug("ignore private LVM device"));
sysfs_devno_is_dm_private(sb.st_rdev, &dm_uuid)) {
DBG(LOWPROBE, ul_debug("ignore private device mapper device"));
pr->flags |= BLKID_FL_NOSCAN_DEV;
}

Expand Down
2 changes: 1 addition & 1 deletion libblkid/src/verify.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev)
(unsigned long)diff));
#endif

if (sysfs_devno_is_lvm_private(st.st_rdev, NULL)) {
if (sysfs_devno_is_dm_private(st.st_rdev, NULL)) {
blkid_free_dev(dev);
return NULL;
}
Expand Down

0 comments on commit 80ec018

Please sign in to comment.