summaryrefslogtreecommitdiffstats
path: root/shlibs/blkid/src/probe.c
diff options
context:
space:
mode:
authorCorentin Chary2009-08-24 13:11:54 +0200
committerKarel Zak2009-09-24 15:42:48 +0200
commitc1ba7962f60672be37f41a5d01c10acf46442f2e (patch)
tree3aa18255f8bcf7f2ce0178fd73a68be62b4ff2e4 /shlibs/blkid/src/probe.c
parentblkid: allow to use -s <TAG> for low-level probing (-p mode) (diff)
downloadkernel-qcow2-util-linux-c1ba7962f60672be37f41a5d01c10acf46442f2e.tar.gz
kernel-qcow2-util-linux-c1ba7962f60672be37f41a5d01c10acf46442f2e.tar.xz
kernel-qcow2-util-linux-c1ba7962f60672be37f41a5d01c10acf46442f2e.zip
libblkid: add UBI volume support
Probe UBI volume under /dev (or /devfs, /devices). ubi_ctrl skip is hardcoded, maybe we should find a cleaner way to do that. Also change probe.c to handle char devices. [kzak@redhat.com: - rebase the patch to the current HEAD] Signed-off-by: Corentin Chary <corentincj@iksaif.net> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/blkid/src/probe.c')
-rw-r--r--shlibs/blkid/src/probe.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/shlibs/blkid/src/probe.c b/shlibs/blkid/src/probe.c
index bac49771e..89c16a201 100644
--- a/shlibs/blkid/src/probe.c
+++ b/shlibs/blkid/src/probe.c
@@ -522,12 +522,17 @@ int blkid_probe_set_device(blkid_probe pr, int fd,
pr->mode = sb.st_mode;
- if (S_ISBLK(sb.st_mode)) {
+ if (S_ISBLK(sb.st_mode))
blkdev_get_size(fd, (unsigned long long *) &pr->size);
+ else if (S_ISCHR(sb.st_mode))
+ pr->size = 1; /* UBI devices are char... */
+ else
+ pr->size = sb.st_size; /* regular file */
+
+ if (S_ISBLK(sb.st_mode) || S_ISCHR(sb.st_mode))
pr->devno = sb.st_rdev;
- } else
- pr->size = sb.st_size;
}
+
if (!pr->size)
return -1;
@@ -842,7 +847,8 @@ dev_t blkid_probe_get_devno(blkid_probe pr)
if (!pr->devno) {
struct stat sb;
- if (fstat(pr->fd, &sb) == 0 && S_ISBLK(sb.st_mode))
+ if (fstat(pr->fd, &sb) == 0 &&
+ (S_ISBLK(sb.st_mode) || S_ISCHR(sb.st_mode)))
pr->devno = sb.st_rdev;
}
return pr->devno;