summaryrefslogtreecommitdiffstats
path: root/shlibs/blkid/src/probe.c
diff options
context:
space:
mode:
authorM.S.Colclough2010-03-31 18:11:00 +0200
committerKarel Zak2010-03-31 18:12:47 +0200
commit55113b15afe5f61fc917c22a9d8d47f89b37c757 (patch)
tree404f473df0b1b4d9150ced667334c1b0d9c19360 /shlibs/blkid/src/probe.c
parentblockdev: reduce usage text width (diff)
downloadkernel-qcow2-util-linux-55113b15afe5f61fc917c22a9d8d47f89b37c757.tar.gz
kernel-qcow2-util-linux-55113b15afe5f61fc917c22a9d8d47f89b37c757.tar.xz
kernel-qcow2-util-linux-55113b15afe5f61fc917c22a9d8d47f89b37c757.zip
libblkid: avoid probing CDs for RAID
RAID probing of CD/DVD can yield errors because of well-known problem in reading the end of the disk with some disk/drive combinations. Borrow CD detection method from udev and skip the RAID tests for these devices. [kzak@redhat.com: - check for linux/cdrom.h in ./configure - add #ifdef around the ioctl call - call the ioctl for block devices only] Signed-off-by: Mark Colclough <m.s.colclough@bham.ac.uk> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/blkid/src/probe.c')
-rw-r--r--shlibs/blkid/src/probe.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/shlibs/blkid/src/probe.c b/shlibs/blkid/src/probe.c
index ab1c8d580..3c6e6948a 100644
--- a/shlibs/blkid/src/probe.c
+++ b/shlibs/blkid/src/probe.c
@@ -77,6 +77,9 @@
#include <fcntl.h>
#include <ctype.h>
#include <sys/types.h>
+#ifdef HAVE_LINUX_CDROM_H
+#include <linux/cdrom.h>
+#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
@@ -545,6 +548,14 @@ int blkid_probe_is_tiny(blkid_probe pr)
return pr && (pr->flags & BLKID_TINY_DEV);
}
+/*
+ * CDROMs may fail when probed for RAID (last sector problem)
+ */
+int blkid_probe_is_cdrom(blkid_probe pr)
+{
+ return pr && (pr->flags & BLKID_CDROM_DEV);
+}
+
/**
* blkid_probe_set_device:
* @pr: probe
@@ -570,6 +581,7 @@ int blkid_probe_set_device(blkid_probe pr, int fd,
pr->flags &= ~BLKID_PRIVATE_FD;
pr->flags &= ~BLKID_TINY_DEV;
+ pr->flags &= ~BLKID_CDROM_DEV;
pr->fd = fd;
pr->off = off;
pr->size = 0;
@@ -619,6 +631,10 @@ int blkid_probe_set_device(blkid_probe pr, int fd,
if (pr->size <= 1440 * 1024 && !S_ISCHR(pr->mode))
pr->flags |= BLKID_TINY_DEV;
+#ifdef CDROM_GET_CAPABILITY
+ if (S_ISBLK(pr->mode) && ioctl(fd, CDROM_GET_CAPABILITY, NULL) >= 0)
+ pr->flags |= BLKID_CDROM_DEV;
+#endif
return 0;
err:
DBG(DEBUG_LOWPROBE,