[PATCH] cdrom_id: Fix empty drive detection for drives with an active profile when empty.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



My CD-RW drive experiences a problem in that it automatically closes
after opening if there is media in the drive.  This only happens if
there was media in the drive when it was last closed (an empty drive
stays open).  From what I can tell, this behavior is affected by the
ID_CDROM_MEDIA variable.

This is the output of cdrom_id:

$ /lib/udev/cdrom_id -d /dev/sr1
main: probing: '/dev/sr1'
cd_media_compat: CDROM_DRIVE_STATUS != CDS_DISC_OK
cd_inquiry: INQUIRY: [LITE-ON ][LTR-52327S      ][QS58]
cd_profiles: GET CONFIGURATION: size of features buffer 0x00b4
cd_profiles: GET CONFIGURATION: feature 'profiles', with 4 entries
feature_profiles: profile 0x0a cd_rw
feature_profiles: profile 0x09 cd_r
feature_profiles: profile 0x08 cd_rom
feature_profiles: profile 0x02 <ignored>
cd_profiles: GET CONFIGURATION: feature 0x0001 <ignored>, with 0x04 bytes
cd_profiles: GET CONFIGURATION: feature 0x0002 <ignored>, with 0x04 bytes
cd_profiles: GET CONFIGURATION: feature 0x0003 <ignored>, with 0x04 bytes
cd_profiles: GET CONFIGURATION: feature 0x0010 <ignored>, with 0x08 bytes
cd_profiles: GET CONFIGURATION: feature 0x001d <ignored>, with 0x00 bytes
cd_profiles: GET CONFIGURATION: feature 0x001e <ignored>, with 0x04 bytes
cd_profiles: GET CONFIGURATION: feature 0x0020 <ignored>, with 0x0c bytes
cd_profiles: GET CONFIGURATION: feature 0x0021 <ignored>, with 0x08 bytes
cd_profiles: GET CONFIGURATION: feature 0x0023 <ignored>, with 0x00 bytes
cd_profiles: GET CONFIGURATION: feature 0x0024 <ignored>, with 0x04 bytes
cd_profiles: GET CONFIGURATION: feature 0x0026 <ignored>, with 0x00 bytes
cd_profiles: GET CONFIGURATION: feature 0x0027 <ignored>, with 0x04 bytes
cd_profiles: GET CONFIGURATION: feature 0x0028 <ignored>, with 0x04 bytes
cd_profiles: GET CONFIGURATION: feature 0x002d <ignored>, with 0x04 bytes
cd_profiles: GET CONFIGURATION: feature 0x002e <ignored>, with 0x04 bytes
cd_profiles: GET CONFIGURATION: feature 0x0100 <ignored>, with 0x00 bytes
cd_profiles: GET CONFIGURATION: feature 0x0101 <ignored>, with 0x04 bytes
cd_profiles: GET CONFIGURATION: feature 0x0103 <ignored>, with 0x04 bytes
cd_profiles: GET CONFIGURATION: feature 0x0105 <ignored>, with 0x00 bytes
cd_profiles: current profile 0x02
cd_profiles: profile 0x02 <ignored>
info_scsi_cmd_err: READ DISC INFORMATION failed with SK=2h/ASC=3Ah/ACQ=00h
ID_CDROM=1
ID_CDROM_CD=1
ID_CDROM_CD_R=1
ID_CDROM_CD_RW=1
ID_CDROM_MRW=1
ID_CDROM_MRW_W=1
ID_CDROM_MEDIA=1

I attached a patch that only sets ID_CDROM_MEDIA if the "READ DISC
INFORMATION" command is successful.  With this patch, the drive no
longer automatically closes.

I am not sure if the location that I moved it to is the best, because
I don't exactly understand this section of code:

/* exclude plain CDROM, some fake cdroms return 0 for "blank" media here */
if (!cd_media_cd_rom && (header[2] & 3) < 4)
       cd_media_state = media_status[header[2] & 3];

First of all, ((header[2] & 3) < 4) is by definition always true, so
I'm not sure what it is checking.  But if somehow this is a valid
check, perhaps we should set cd_media in here.

I have tested this patch with my cd-rw drive and dvd drive (blank
media, normal media, and no media were all tested), and all seems
well.

Mike
From c074a888f235a74c64ce5ffad1b65a00002ac287 Mon Sep 17 00:00:00 2001
From: Mike Brudevold <mike@xxxxxxxxxxxxx>
Date: Sat, 17 Apr 2010 11:00:44 -0500
Subject: [PATCH] cdrom_id: Fix empty drive detection for drives with an active profile when empty.

---
 extras/cdrom_id/cdrom_id.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/extras/cdrom_id/cdrom_id.c b/extras/cdrom_id/cdrom_id.c
index da2785e..2910378 100644
--- a/extras/cdrom_id/cdrom_id.c
+++ b/extras/cdrom_id/cdrom_id.c
@@ -401,8 +401,6 @@ static int cd_profiles(struct udev *udev, int fd)
 		return -1;
 	}
 
-	cd_media = 1;
-
 	switch (cur_profile) {
 	case 0x03:
 	case 0x04:
@@ -509,6 +507,8 @@ static int cd_media_info(struct udev *udev, int fd)
 		return -1;
 	};
 
+	cd_media = 1;
+
 	info(udev, "disk type %02x\n", header[8]);
 
 	/* exclude plain CDROM, some fake cdroms return 0 for "blank" media here */
-- 
1.7.0.4


[Index of Archives]     [Linux Kernel]     [Linux DVB]     [Asterisk Internet PBX]     [DCCP]     [Netdev]     [X.org]     [Util Linux NG]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux