]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/sysfs: add sysfs_devno_is_wholedisk()
authorKarel Zak <kzak@redhat.com>
Tue, 17 Jun 2014 10:15:01 +0000 (12:15 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 17 Jun 2014 10:15:01 +0000 (12:15 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
include/sysfs.h
lib/sysfs.c

index 2b77bf6daba2cb087c74afd6dbbaf545ced66522..85a8910c642dab389f142c83124237b891be89e2 100644 (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);
index fe85f34cfec778f3737688f3932e9f2fcab3d203..0d8afa56069449383c43ac441527debaaf8578ff 100644 (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;