Commit Graph

46 Commits

Author SHA1 Message Date
Jan Drzewiecki 1ef6c9e9f0 cdrom_id: Fix detection of reblanked DVD+RW and DVD-RAM
Once formatted, DVD+RW and DVD-RAM discs are always reported "complete" by the
drive. Check the if the Volume Descriptor or Volume Descriptor Anchor sectors
are empty, and if so, set the status to blank. If the disc is unformatted the
blank status is maintained and no reads are issued. If the disc is formatted and
read command fails, the status remains set to complete to avoid accidental
blanking.

Bug-Ubuntu: https://launchpad.net/bugs/581925

Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
2010-08-08 17:47:08 +02:00
Kay Sievers 898e5d4ca5 cdrom_id: do not export ID_CDROM_MEDIA_SESSION_LAST_OFFSET= for single session media 2010-05-25 09:47:04 +02:00
Kay Sievers bc913ce478 cdrom_id: set ID_CDROM_MEDIA=1 only for known media
On Sat, Apr 17, 2010 at 18:26, Mike Brudevold <mike@brudevold.com> wrote:
> 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).
...
> cd_profiles: current profile 0x02
> cd_profiles: profile 0x02 <ignored>
...

Do not pretend to have a media, when we receive a profile like 0x02,
which just means "Removable disk".

Thanks to Mike Brudevold for the initial patch.
2010-04-17 19:31:44 +02:00
Mike Brudevold 7c07740ce7 cdrom_id: add missing profiles to feature_profiles
Signed-off-by: Mike Brudevold <mike@brudevold.com>
2010-04-16 07:39:56 +02:00
Martin Pitt 30e3b1a0d3 cdrom_id: Swap media state and TOC info probing
Blank CDs do not have a TOC, thus will fail cd_media_toc() (at least with the
"Do not ignore errors from scsi_cmd_run()" fix). Thus probe the media state
first, so that we can properly detect blank media.
2010-04-15 21:29:18 +02:00
Martin Pitt 58e178894b cdrom_id: Do not ignore errors from scsi_cmd_run()
scsi_cmd_run() can return positive error messages if we have CHECK_CONDITION
set and get the error code from the SCSI command result. So check the result
for non-zero, not for being negative.

This should fix another cause for "phantom" media in empty CD-ROM drives.

Thanks to Mike Brudevold <mike@brudevold.com> for spotting this!

https://launchpad.net/bugs/562978
2010-04-15 21:29:17 +02:00
Kay Sievers a60b077a46 cdrom_id: debug - print feature values in hex 2010-04-15 21:22:38 +02:00
Kay Sievers 140647ad1a cdrom_id: debug - print feature values in hex 2010-04-15 21:18:21 +02:00
Kay Sievers 2e9df19818 cdrom_id: print more debug messages 2010-04-15 20:48:04 +02:00
Kay Sievers 0413a47ebf cdrom_id: rework feature/profiles buffer parsing 2010-04-15 20:07:07 +02:00
Kay Sievers c1b7f60dea update NEWS 2010-04-14 17:00:57 +02:00
Martin Pitt 2b861dc927 cdrom_id: Fix uninitialized buffers
Commit 5c6954f is actually a no-op, since static variables are already zero'ed
by default anyway (but we keep it for clarity). The real difference was that a
build with -O0 wor while a build with -O2 didn't.

Turns out that some ioctls do not actually touch the result buffer in some
cases, so we need to zero the result buffers to avoid interpreting random da as
CD properties.

https://launchpad.net/bugs/559723
https://launchpad.net/bugs/561585
2010-04-13 15:25:48 +02:00
Martin Pitt 816e6bf0fb cdrom_id: Fix uninitialized variables
In cases where cdrom_id does not go through the entire code path and one of the
probing functions returns -1 or exits early, the remaining variables were never
initialized. This caused effects like "phantom" audio CDs on empty drives, or
bogus data like ID_CDROM_MEDIA_TRACK_COUNT=22528.

Initialize the variables right away to avoid that.

Bug-Ubuntu: https://launchpad.net/bugs/559723
2010-04-13 10:49:24 +02:00
Kay Sievers d45c8c8b01 cdrom_id: check mount state in retry loop
Based on a patch from Harald Hoyer.
2010-04-07 11:32:22 +02:00
Kay Sievers cccfffbe04 cdrom_id: retry to open the device, if EBUSY
We might fight about the device with polling processes, or other
users who probe the device. Retry a few times if the other one goes
away in the meantime.

Based on a patch from Harald Hoyer.
2010-04-07 09:24:25 +02:00
Harald Hoyer 36a07a8c34 cdrom_id: remove debugging code 2010-04-07 09:23:46 +02:00
Kay Sievers 38a3cde11b cdrom_id: open non-mounted optical media with O_EXCL
This should prevent confusing drives during CD burning sessions. Based
on a patch from Harald Hoyer.
2010-03-18 11:14:32 +01:00
David Zeuthen 7505831b7e cdrom_id: Still check profiles even if there is no media
Even when there is no medium in the drive, we should still check the
profiles supported by the drive. Otherwise we fail to detect things
like Blu-ray drives. See

 https://bugzilla.gnome.org/show_bug.cgi?id=600273

for more information.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2009-11-10 12:32:38 -05:00
Alan Jenkins 214a6c791c fix spelling
Fix spelling in docbook comments, code comments, and a local variable
name.  Thanks to "ispell -h" for docbook HTML and "scspell" for source
code.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
2009-08-08 15:42:05 +02:00
Kay Sievers 9060b066d9 move syslog wrapper to libudev 2009-06-09 22:47:48 +02:00
Kay Sievers e91ac78ffc cdrom_id: add error message if open() fails 2009-05-29 13:21:38 +02:00
Kay Sievers d3c8231e73 cdrom_id: suppress ID_CDROM_MEDIA_STATE=blank for plain non-writable CDROM media
Some broken fake cdrom drives return ID_CDROM_MEDIA_STATE=blank.

  $ /lib/udev/cdrom_id -d /dev/sr1
  main: probing: '/dev/sr1'
  cd_inquiry: INQUIRY: [Nokia   ][S60             ][1.0 ]
  cd_profiles: GET CONFIGURATION: number of profiles 76
  cd_profiles: current profile 0x08
  cd_media_toc: READ TOC: len: 12
  cd_media_toc: last track 1 starts at block 0
  cd_media_info: disk type 00
  ID_CDROM=1
  ID_CDROM_MRW=1
  ID_CDROM_MRW_W=1
  ID_CDROM_MEDIA=1
  ID_CDROM_MEDIA_CD=1
  ID_CDROM_MEDIA_STATE=blank

Others work fine, but ID_CDROM_MEDIA_STATE is not needed for non-writable CDROM media:

  $ /lib/udev/cdrom_id -d /dev/sr1
  main: probing: '/dev/sr1'
  cd_inquiry: INQUIRY: [SanDisk ][U3 Cruzer Micro ][8.02]
  cd_profiles: GET CONFIGURATION: number of profiles 72
  cd_profiles: current profile 0x08
  cd_media_toc: READ TOC: len: 20
  cd_media_toc: track=1 info=0x4(data) start_block=0
  cd_media_toc: last track 1 starts at block 0
  cd_media_info: disk type 00
  ID_CDROM=1
  ID_CDROM_MRW=1
  ID_CDROM_MRW_W=1
  ID_CDROM_MEDIA=1
  ID_CDROM_MEDIA_CD=1
  ID_CDROM_MEDIA_STATE=complete
  ID_CDROM_MEDIA_SESSION_COUNT=1
  ID_CDROM_MEDIA_TRACK_COUNT=1
  ID_CDROM_MEDIA_TRACK_COUNT_DATA=1
2009-05-26 00:50:45 +02:00
Kay Sievers d6f0b22d57 cdrom_id: skip media tests if CDROM_DRIVE_STATUS != CDS_DISC_OK 2009-04-23 15:04:16 +02:00
Kay Sievers f907449eee cdrom_id: add and use ID_CDROM_MEDIA to decide if we run vol_id
Some broken mobile phones offer a faked cdrom drive with a media
without any tracks.
2009-04-21 03:27:14 +02:00
Kay Sievers 55d8f5e208 cdrom_id: add Xen cdrom support 2009-04-17 00:29:56 +02:00
Kay Sievers e02d738ee4 cdrom_id: remove ARRAY_SIZE() declaration 2008-10-21 12:40:47 +02:00
Kay Sievers 033e9f8cde use no_argument, required_argument, optional_argument in longopts 2008-10-02 16:49:05 +02:00
Kay Sievers 55e9959b15 update file headers 2008-09-10 02:40:42 +02:00
Kay Sievers 7d563a17f3 use libudev code, unify logging, pass udev context around everywhere 2008-09-06 15:45:31 +02:00
Kay Sievers f46a8a98a7 vol_id: make the --offset= argument optional 2008-08-22 10:04:55 +02:00
Kay Sievers 01618658fd use autotools 2008-07-30 01:45:23 +02:00
Kay Sievers 9bbdf6eb3c cdrom_id: fix recognition of blank media
Thanks to David!
2008-06-12 07:20:14 +02:00
Kay Sievers ec404619a6 cdrom_id: export ID_CDROM_MEDIA_TRACK_COUNT_AUDIO=, ID_CDROM_MEDIA_TRACK_COUNT_DATA=
Iterate over all tracks, instead of looking only at the first
one for audio. Thanks to David!
2008-06-11 23:24:13 +02:00
Matthias Schwarzott 4cd71da560 cdrom_id: fix segfault 2008-05-14 16:03:49 +02:00
Kay Sievers 953080abd9 cdrom_id: add more help text 2008-04-21 17:41:39 +02:00
Kay Sievers c70560feef logging: add trailing newline to all strings 2008-04-20 21:07:06 +02:00
Kay Sievers fd7a285e62 cdrom_id: replace with version which also exports media properties
This is a 12 track audio CD with additional data session:
  $ extras/cdrom_id/cdrom_id /dev/dvd
  ID_CDROM=1
  ID_CDROM_CD_R=1
  ID_CDROM_CD_RW=1
  ID_CDROM_DVD=1
  ID_CDROM_DVD_R=1
  ID_CDROM_DVD_RW=1
  ID_CDROM_DVD_RAM=1
  ID_CDROM_DVD_PLUS_R=1
  ID_CDROM_DVD_PLUS_RW=1
  ID_CDROM_DVD_PLUS_R_DL=1
  ID_CDROM_MEDIA_CD=1
  ID_CDROM_MEDIA_STATE=complete
  ID_CDROM_MEDIA_HAS_AUDIO=1
  ID_CDROM_MEDIA_SESSION_COUNT=2
  ID_CDROM_MEDIA_TRACK_COUNT=13
  ID_CDROM_MEDIA_SESSION_LAST_OFFSET=444508160
2008-04-09 23:17:39 +02:00
Kay Sievers 1aa1e24848 replace libsysfs
We never used any of the libsysfs convenience features. Here we replace
it completely with 300 lines of code, which are much simpler and a bit
faster cause udev(d) does not open any syfs file for a simple event which
does not need any parent device information.

Signed-off-by: Kay Sievers <kay.sievers@suse.de>
2006-01-09 21:18:00 +01:00
Kay Sievers 2321ba6fd8 switch tools and volume_id from LGPL to GPLv2
After beeing hit by proprietary applications which statically
link the LGPL'd libusb, which needs a patch to reflect the recent
kernel changes, I decided not to provide LGPL code anymore.

Signed-off-by: Kay Sievers <kay.sievers@suse.de>
2005-09-27 16:27:35 +02:00
Kay Sievers e331c54dc5 fix typo in cdrom_id syslog
Signed-off-by: Kay Sievers <kay.sievers@suse.de>
2005-08-18 04:54:59 +02:00
Greg Kroah-Hartman a961dcbf0d cdrom_id: change err() to info() to help with debugging problems
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-08-17 16:10:32 -07:00
Greg Kroah-Hartman fc046d4d08 Always open the cdrom drive in non-blocking mode in cdrom_id
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-08-17 16:09:03 -07:00
Greg Kroah-Hartman 903a36495f added the cdrom.h #defines directly into the cdrom_id.c file
This solves the problem with building the file against old kernel header
files.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-08-12 11:37:56 -07:00
Greg KH 5a64cea1e1 fix klibc build issue in cdrom_id.c
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-08-11 14:38:33 -07:00
Greg KH 8ee99e3279 changed cdrom_id exports to be easier to understand and consistant with other _id programs.
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-08-11 14:04:24 -07:00
Greg KH 8f6919e639 Created cdrom_id program to make it easier to determine cdrom types
Based on the framework from ata_id by Kay.
Now we can drop the cdsymlinks.sh and .c files

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-08-11 13:59:21 -07:00