/* flags */
#define BLKID_PRIVATE_FD (1 << 1) /* see blkid_new_probe_from_filename() */
#define BLKID_TINY_DEV (1 << 2) /* <= 1.47MiB (floppy or so) */
+#define BLKID_CDROM_DEV (1 << 3) /* is a CD/DVD drive */
/*
* Evaluation methods (for blkid_eval_* API)
/* probe.c */
extern int blkid_probe_is_tiny(blkid_probe pr);
+extern int blkid_probe_is_cdrom(blkid_probe pr);
extern unsigned char *blkid_probe_get_buffer(blkid_probe pr,
blkid_loff_t off, blkid_loff_t len);
#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
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
pr->flags &= ~BLKID_PRIVATE_FD;
pr->flags &= ~BLKID_TINY_DEV;
+ pr->flags &= ~BLKID_CDROM_DEV;
pr->fd = fd;
pr->off = off;
pr->size = 0;
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,
blkid_probe_is_tiny(pr))
continue;
+ /* don't probe for RAIDs, swap or journal on floppies or CD/DVDs */
+ if ((id->usage & (BLKID_USAGE_RAID | BLKID_USAGE_OTHER)) &&
+ (blkid_probe_is_tiny(pr) || blkid_probe_is_cdrom(pr)))
+ continue;
+
DBG(DEBUG_LOWPROBE, printf("[%d] %s:\n", i, id->name));
/* try to detect by magic string */