lib/sysfs: add sysfs_devno_is_wholedisk()

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2014-06-17 12:15:01 +02:00
parent 39866431ee
commit b55e5886ea
2 changed files with 19 additions and 0 deletions

View File

@ -74,6 +74,7 @@ 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_wholedisk(dev_t devno);
extern int sysfs_scsi_get_hctl(struct sysfs_cxt *cxt, int *h,
int *c, int *t, int *l);

View File

@ -539,6 +539,10 @@ static int get_dm_wholedisk(struct sysfs_cxt *cxt, char *diskname,
return rc;
}
/*
* Returns by @diskdevno whole disk device devno and (optionaly) by
* @diskname the whole disk device name.
*/
int sysfs_devno_to_wholedisk(dev_t dev, char *diskname,
size_t len, dev_t *diskdevno)
{
@ -658,6 +662,20 @@ int sysfs_devno_is_lvm_private(dev_t devno)
return rc;
}
/*
* Return 0 or 1, or < 0 in case of error
*/
int sysfs_devno_is_wholedisk(dev_t devno)
{
dev_t disk;
int rc;
if (sysfs_devno_to_wholedisk(devno, NULL, 0, &disk) != 0)
return -1;
return devno == disk;
}
int sysfs_scsi_get_hctl(struct sysfs_cxt *cxt, int *h, int *c, int *t, int *l)
{
char buf[PATH_MAX], *hctl;