]> err.no Git - systemd/commitdiff
cdrom_id: skip media tests if CDROM_DRIVE_STATUS != CDS_DISC_OK
authorKay Sievers <kay.sievers@vrfy.org>
Thu, 23 Apr 2009 13:04:16 +0000 (15:04 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Thu, 23 Apr 2009 13:04:16 +0000 (15:04 +0200)
extras/cdrom_id/cdrom_id.c

index 371d6a2dbd197898c69d381d2cee4fe5267662b5..0d873ae8e5f847eaba7df3d0bc6cc846e948a75d 100644 (file)
@@ -197,6 +197,16 @@ static int cd_capability_compat(struct udev *udev, int fd)
        return 0;
 }
 
+static int cd_media_compat(struct udev *udev, int fd)
+{
+       if (ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT) != CDS_DISC_OK) {
+               info(udev, "CDROM_DRIVE_STATUS != CDS_DISC_OK\n");
+               return -1;
+       }
+       cd_media = 1;
+       return 0;
+}
+
 static int cd_inquiry(struct udev *udev, int fd) {
        struct scsi_cmd sc;
        unsigned char inq[128];
@@ -569,7 +579,11 @@ int main(int argc, char *argv[])
                goto exit;
        }
 
-       /* check drive */
+       /* check for media */
+       if (cd_media_compat(udev, fd) < 0)
+               goto print;
+
+       /* check if drive talks MMC */
        if (cd_inquiry(udev, fd) < 0)
                goto print;