Commit graph

104 commits

Author SHA1 Message Date
Kay Sievers 85e172c9bd cdrom_id: remove unused --export switch to silent gcc 2011-05-16 18:11:50 +02:00
Martin Pitt 55eb500cc5 Avoid spinning up CD on pressing eject button
When the CD tray door is locked and the hardware eject button is pressed, newer
kernels (2.6.38+) will send out a change event with a DISK_EJECT_REQUEST==1
property. Do not run cdrom_id and blkid in this case, as the media state and
contents does not change, and this only needlessly spins up the drive again
right before ejection.
2011-04-04 11:47:54 +02:00
David Zeuthen 98ab6a3772 cdrom_id: Don't ignore profiles when there is no media available
Just because the GET CONFIGURATION MMC-2 command returns the current
profile as 0 does not mean that we can ignore the profiles describing
the capabilities of the drive - it only means that there currently is
no recognized media in the drive. Therefore, do process the returned
profiles even when cur_profile is 0.

This fixes a bug where only

 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_RAM=1

was returned when there is no media in the drive instead of

 ID_CDROM=1
 ID_CDROM_CD=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_BD=1
 ID_CDROM_BD_R=1
 ID_CDROM_BD_RE=1
 ID_CDROM_HDDVD=1

as is returned now.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-03-15 12:33:35 -04:00
Harald Hoyer 551b143e13 cdrom_id: cd_media_toc() extend toc size to 65536
Seems like an iDRAC reports a lot of toc entries.

"For cd_media_toc() will have to be modified to handle larger
tables right now it has an "unsigned char toc[2048]" but the toc
can be up to 65536 bytes long . I got a TOC length of 4610 bytes,
causing cd_media_toc() to fail."

https://bugzilla.redhat.com/show_bug.cgi?id=660367

Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
2011-02-24 16:59:21 +01:00
Jan Drzewiecki d43e5e5b5a cdrom_id: Fix media state for unreadable DVDs
If the disc is unreadable and reading of the first 32 blocks fails set the
cd_media status to 0 (not present). This will prevent udev from executing blkid
next that tries to determine fs on the disc and which in this case may seem to
hang forever locking the drive.

Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
2010-10-26 12:10:57 -04:00
Harald Hoyer d7cd2b1611 cdrom_id: request the drive profile features with a dynamic length
Some drives don't like huge feature buffers, so we query twice. First
run for the current profile and to get the length.
Second time we query the whole profile feature set.
2010-10-07 17:43:05 +02:00
Martin Pitt 1ebd2a5620 cdrom_id: Don't read beyond "last track" in TOC
Read the first and last track from the TOC header, and do not go beyond that
stated number of tracks when reading the TOC. Otherwise we interpret random
data which leads to bogus tracks. (Reported on an IronKey, which reported 1
data track, and 4 audio tracks which weren't actually present.)
2010-10-05 17:56:19 +02:00
Martin Pitt 678df8a461 cdrom_id: Fall back to CDROM_DRIVE_STATUS if all MMC commands fail
Reportedly, some "when I'm grown up I want to be a CD drive" fake USB CD sticks
like the IronKey neither support the SCSI "GET CONFIGURATION" nor the older
(pre-MMC2) "READ DISC INFORMATION" command. In that case, check if
cd_media_compat() detected that there is a disc present, and assume that we
have a CD-ROM medium.
2010-10-05 14:59:51 +02:00
Martin Pitt 13e0fca5df Revert "cdrom_id: Try reading the medium if all MMC commands fail"
Turns out we can do this much simpler by assuming that cd_media_compat() works,
which seems to be the case for the IronKey.

This reverts commit ea88774a92.
2010-10-05 14:57:04 +02:00
Martin Pitt ea88774a92 cdrom_id: Try reading the medium if all MMC commands fail
Reportedly, some "when I'm grown up I want to be a CD drive" fake USB CD sticks
like the IronKey neither support the SCSI "GET CONFIGURATION" nor the older
(pre-MMC2) "READ DISC INFORMATION" command. In that case, check if we can read
data from the drive, and assume that we have a CD-ROM medium if it succeeds.
2010-10-05 14:34:55 +02:00
Jan Drzewiecki 5e267ea5a3 cdrom_id: Fix DVD blank detection for sloppy firmware
Reportedly, many CD drive firmwares will only consider the MSB in a READ
command, thus if we request 17 blocks to be read, we'll actually only get 16 in
many cases, and thus miss out the interesting sector #17. This would lead to
falsely considering nonempty DVDs as blank.

Fetch 32 blocks now, which should work everywhere.

Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
2010-08-31 00:41:35 +02:00
Martin Pitt 2458db3edd cdrom_id: Fix DVD-RW media detection
Commit cf2205a19 applied the "restricted overwrite" vs. "sequential" DVD-RW
test to feature_profiles() (which reads the drive capabilities), which caused
every DVD medium to be detected as ID_CDROM_MEDIA_DVD_RW. Now apply it to
cd_profiles() instead, to just check the current profile.
2010-08-30 15:33:26 +02:00
Jan Drzewiecki b367a1c9d8 cdrom_id: Drop MEDIA_SESSION_NEXT for DVD-RW-RO
Commit cf2205a fixed the media status for fresh DVD-RW in restricted overwrite
mode, but missed a detail: We should not report the ID_CDROM_MEDIA_SESSION_NEXT
property either, since in that mode you can never append tracks/sessions; this
just works in sequential mode.

Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
2010-08-13 07:27:30 +02:00
Martin Pitt 24af530a54 cdrom_id: Add media status debugging
Show which media status the hardware originally reports, since we mangle it in
some cases.
2010-08-12 07:10:12 +02:00
Kay Sievers 4f7f02b7ba cdrom_id: do not bail out when we can not read the TOC like for empty CDRW 2010-08-11 15:38:48 +02:00
Harald Hoyer 1b3b6c2df7 cdrom_id: READ TOC before READ DISC INFORMATION fixes qemu 2010-08-11 15:21:33 +02:00
Kay Sievers 36b6aca5c1 cdrom_id: whitespace fix 2010-08-11 15:04:05 +02:00
Jan Drzewiecki cf2205a198 cdrom_id: Fix state for fresh DVD-RW
Fresh DVD-RW in restricted overwite mode reports itself as "appendable"; change
it to "blank" to make it consistent with what gets reported after blanking, and
what userspace expects.

For the exotic case where some uses multi-track recording on a DVD-RW in
sequential mode, we need to tell apart sequential and restricted overwrite
modes, so keep separate states for them internally.

Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
2010-08-10 23:37:14 +02:00
Jan Drzewiecki 45b1d780b9 cdrom_id: No "next session" for "other" media state
"other" is known to apply to DVD-RAMs, where sessions can't be appended.

Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
2010-08-08 19:22:13 +02:00
Jan Drzewiecki a6b03c0961 cdrom_id: Also apply format check to DVD-RW
Extend the DVD+RW/DVD-RAM check in commit 1ef6c9e to also cover DVD-RW, since
in "restricted overwrite" mode they behave similar to DVD+RW.

Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
2010-08-08 19:19:07 +02:00
Jan Drzewiecki d83dfabe0d cdrom_id: Handle pre-MMC2 drives
Those do not yet support the 0x46 "GET CONFIGURATION" support. If we have
those, fall back to the 0x51 "READ DISC INFORMATION" call. This can only
differentiate between CD-RW and CD-R, but first that's better than a complete
detection failure, and second, those old drives likely don't support more
modern media in the first place.

https://launchpad.net/bugs/502143

Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
2010-08-08 17:57:47 +02:00
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
Harald Hoyer 2d01980f1a cdrom_id: only mark sr[0-9]* as ID_CDROM
we cannot be sure for xvd*
2010-05-04 09:09:32 +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 4b06c40935 replace "add|change" with "!remove" 2010-04-12 16:52:41 +02:00
Kay Sievers 5c5ebde711 cdrom_id: always set ID_CDROM regardless if we can run cdrom_id 2010-04-12 01:12:23 +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
Kay Sievers 63480d01aa cdrom_id: remove deprecated device matches 2009-12-15 16:15:33 +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
Diego Elio 'Flameeyes' Pettenò 59d93adb29 Merge libudev, udev, and the unconditional extras in a single Makefile.am.
Instead of using multiple recursive Makefile.am files, use a single
Makefile.am that sets and builds all the basic suite of libraries and
binaries for udev. This reduces the number of files in the source tree, and
also reduces drastically the build time when using parallel-make.

With this setup, all the compile steps will be executed in parallel, and
just the linking stage will be (partially) serialised on the libraries
creation.
2009-08-07 19:15:28 +02:00
Kay Sievers 2a827c959a make: build internal tools against libudev-private.la 2009-07-25 20:37:45 +02:00
Kay Sievers bcee964977 extras: delete man pages for private udev tools
These are mostly dummy man pages, without real content, some even
outdated. None of these tools are part of any offered public interface,
and they should not pretend to be by offering a man page.
2009-06-17 21:57:40 +02:00
Kay Sievers 6133f3432f cleanup ./configure installation directory options 2009-06-17 02:25:07 +02:00
Kay Sievers 9060b066d9 move syslog wrapper to libudev 2009-06-09 22:47:48 +02:00
Kay Sievers 48a9b173e8 libudev: move to top-level directory 2009-06-08 21:36:06 +02:00