]> err.no Git - util-linux/commitdiff
libblkid: export functions to get whole-disk devno
authorKarel Zak <kzak@redhat.com>
Mon, 19 Apr 2010 08:51:37 +0000 (10:51 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 19 Apr 2010 08:51:37 +0000 (10:51 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
shlibs/blkid/src/blkid.h.in
shlibs/blkid/src/blkid.sym
shlibs/blkid/src/blkidP.h
shlibs/blkid/src/partitions/partitions.c
shlibs/blkid/src/probe.c

index 07001a3a5888f1ad5643509c77ca432df9d2060c..fc744b13a5c2b8ce361092627795a6e0896f94f7 100644 (file)
@@ -197,6 +197,9 @@ extern int blkid_probe_set_device(blkid_probe pr, int fd,
                        blkid_loff_t off, blkid_loff_t size);
 
 extern dev_t blkid_probe_get_devno(blkid_probe pr);
+extern dev_t blkid_probe_get_wholedisk_devno(blkid_probe pr);
+extern int blkid_probe_is_wholedisk(blkid_probe pr);
+
 extern blkid_loff_t blkid_probe_get_size(blkid_probe pr);
 extern blkid_loff_t blkid_probe_get_offset(blkid_probe pr);
 extern unsigned int blkid_probe_get_sectorsize(blkid_probe pr);
index a80e87399c0a1ebc70617b78acfc729ed00533de..e6a1e36e075d0a6444f7a971085eedea733b5c9b 100644 (file)
@@ -125,4 +125,6 @@ global:
        blkid_probe_all_removable;
        blkid_probe_get_fd;
        blkid_probe_get_offset;
+       blkid_probe_get_wholedisk_devno;
+       blkid_probe_is_wholedisk;
 } BLKID_2.17;
index b15c7f9b731af7647730bebd558ffe9db1d36555..c37f73062f573d91d9927897f4aa2455415f274a 100644 (file)
@@ -191,6 +191,7 @@ struct blkid_struct_probe
        blkid_loff_t            size;           /* end of data on the device */
 
        dev_t                   devno;          /* device number (st.st_rdev) */
+       dev_t                   disk_devno;     /* devno of the whole-disk or 0 */
        unsigned int            blkssz;         /* sector size (BLKSSZGET ioctl) */
        mode_t                  mode;           /* struct stat.sb_mode */
 
index ad0c2f8cf2ab2e41ce4f520ca684f734b6bc399f..293ee86aa12771de85906d9246ca2b297d510831 100644 (file)
@@ -694,7 +694,8 @@ static int blkid_partitions_probe_partition(blkid_probe pr)
        if (!devno)
                goto nothing;
 
-       if (blkid_devno_to_wholedisk(devno, NULL, 0, &disk_devno))
+       disk_devno = blkid_probe_get_wholedisk_devno(pr);
+       if (!disk_devno)
                goto nothing;
 
        if (devno == disk_devno)
index 3c6e6948a4ee1e11f65c00388312df7e393c774e..6d58d5ae5f9b91abe0a9b6a5bc872f107ef2c57a 100644 (file)
@@ -993,6 +993,48 @@ dev_t blkid_probe_get_devno(blkid_probe pr)
        return pr->devno;
 }
 
+/**
+ * blkid_probe_get_wholedisk_devno:
+ * @pr: probe
+ *
+ * Returns: device number of the wholedisk, or 0 for regilar files.
+ */
+dev_t blkid_probe_get_wholedisk_devno(blkid_probe pr)
+{
+       if (!pr->disk_devno) {
+               dev_t devno, disk_devno = 0;
+
+               devno = blkid_probe_get_devno(pr);
+               if (!devno)
+                       return 0;
+
+                if (blkid_devno_to_wholedisk(devno, NULL, 0, &disk_devno) == 0)
+                       pr->disk_devno = disk_devno;
+       }
+       return pr->disk_devno;
+}
+
+/**
+ * blkid_probe_is_wholedisk:
+ * @pr: probe
+ *
+ * Returns: 1 if the device is whole-disk or 0.
+ */
+int blkid_probe_is_wholedisk(blkid_probe pr)
+{
+       dev_t devno, disk_devno;
+
+       devno = blkid_probe_get_devno(pr);
+       if (!devno)
+               return 0;
+
+       disk_devno = blkid_probe_get_wholedisk_devno(pr);
+       if (!disk_devno)
+               return 0;
+
+       return devno == disk_devno;
+}
+
 /**
  * blkid_probe_get_size:
  * @pr: probe