This service will be undergoing maintenance at 00:00 UTC, 2016-08-01. It is expected to last about 1 hours
Bug 190037 - "eject" command opens different drive in FC5
"eject" command opens different drive in FC5
Status: CLOSED CURRENTRELEASE
Product: Fedora
Classification: Fedora
Component: udev (Show other bugs)
5
All Linux
medium Severity medium
: ---
: ---
Assigned To: Harald Hoyer
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-04-26 17:29 EDT by Steve Tyler
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version: FC6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-09-20 07:05:40 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Steve Tyler 2006-04-26 17:29:36 EDT
My system has two optical drives (hdc, hdd).
In FC4 the "eject" command opened hdc.
In FC5 the "eject" command opens hdd.
This is not what an end-user expects.

"eject" (without arguments) opens /dev/cdrom by default.
In FC5 /dev/cdrom points to /dev/hdd.
I want /dev/cdrom to point to /dev/hdc so that "eject" works as it did in FC4.
I also have xmms configured to play /dev/cdrom by default.

udev-084-13
kernel 2.6.16-1.2096_FC5

lrwxrwxrwx 1 root root 3 Apr 26 13:35 cdrom -> hdd
lrwxrwxrwx 1 root root 3 Apr 26 13:35 cdrom-hdc -> hdc
lrwxrwxrwx 1 root root 3 Apr 26 13:35 cdrom-hdd -> hdd
lrwxrwxrwx 1 root root 3 Apr 26 13:35 cdrw -> hdd
lrwxrwxrwx 1 root root 3 Apr 26 13:35 cdrw-hdd -> hdd
lrwxrwxrwx 1 root root 3 Apr 26 13:35 cdwriter -> hdd
lrwxrwxrwx 1 root root 3 Apr 26 13:35 cdwriter-hdd -> hdd

My workaround is to create the file
/etc/udev/rules.d/51-udev.rules containing these rules:
KERNEL=="hdc", BUS=="ide", SYSFS{removable}=="1", SYSFS{device/media}=="cdrom",
SYMLINK+="cdrom"
KERNEL=="hd[a-z]", BUS=="ide", SYSFS{removable}=="1",
SYSFS{device/media}=="cdrom", SYMLINK+="cdrom-%k"

According to the FC5 release notes, the assignment of /dev/cdrom
to a device in a system with more than one cdrom drive is "random",
and that assignment "usually sticks".
Are the release notes correct?
If so, it seems to me udev should ensure that /dev/cdrom
points to a definite, not a random, device,
and, preferably, that it points to the first device.
Comment 1 Steve Tyler 2006-04-26 20:09:48 EDT
$ cat /proc/sys/dev/cdrom/info
CD-ROM information, Id: cdrom.c 3.20 2003/12/17

drive name:             hdd     hdc
drive speed:            40      48
drive # of slots:       1       1
Can close tray:         1       1
Can open tray:          1       1
Can lock tray:          1       1
Can change speed:       1       1
Can select disk:        0       0
Can read multisession:  1       1
Can read MCN:           1       1
Reports media changed:  1       1
Can play audio:         1       1
Can write CD-R:         1       0
Can write CD-RW:        1       0
Can read DVD:           0       1
Can write DVD-R:        0       0
Can write DVD-RAM:      0       0
Can read MRW:           1       1
Can write MRW:          1       1
Can write RAM:          1       0
Comment 2 Harald Hoyer 2006-04-27 05:08:48 EDT
> Are the release notes correct?
yes

> If so, it seems to me udev should ensure that /dev/cdrom
> points to a definite, not a random, device,
> and, preferably, that it points to the first device.

well, tell me how
Comment 3 Harald Hoyer 2006-04-27 05:14:00 EDT
what is the first cdrom?
- sda vs. hda
Comment 4 Steve Tyler 2006-04-28 18:07:56 EDT
(In reply to comment #0)
> My workaround is to create the file
> /etc/udev/rules.d/51-udev.rules containing these rules:
> KERNEL=="hdc", BUS=="ide", SYSFS{removable}=="1", SYSFS{device/media}=="cdrom",
> SYMLINK+="cdrom"
> KERNEL=="hd[a-z]", BUS=="ide", SYSFS{removable}=="1",
> SYSFS{device/media}=="cdrom", SYMLINK+="cdrom-%k"

This didn't seem to work consistently, so I modified 50-udev.rules.
I suspect that I really can override the standard cdrom rules
by adding another rules file, but have not experimented much beyond the above.

$ rcsdiff -u 50-udev.rules
===================================================================
RCS file: RCS/50-udev.rules,v
retrieving revision 1.1
diff -u -r1.1 50-udev.rules
--- 50-udev.rules       2006/04/26 19:19:20     1.1
+++ 50-udev.rules       2006/04/27 10:27:04
@@ -237,7 +237,8 @@
        SYSFS{device/media}=="floppy", \
        SYMLINK+="floppy floppy-%k", OPTIONS+="ignore_remove, all_partitions"

-KERNEL=="hd[a-z]", BUS=="ide", SYSFS{removable}=="1",
SYSFS{device/media}=="cdrom", SYMLINK+="cdrom cdrom-%k"
+KERNEL=="hdc", BUS=="ide", SYSFS{removable}=="1", SYSFS{device/media}=="cdrom",
SYMLINK+="cdrom"
+KERNEL=="hd[a-z]", BUS=="ide", SYSFS{removable}=="1",
SYSFS{device/media}=="cdrom", SYMLINK+="cdrom-%k"

 KERNEL=="hd[a-z]", BUS=="ide", SYSFS{removable}=="1", PROGRAM=="check-cdrom.sh
%k DVD", SYMLINK+="dvd dvd-%k"
 KERNEL=="sr[0-9]*", BUS=="scsi", PROGRAM=="check-cdrom.sh %k DVD",
SYMLINK+="dvd dvd-%k"

Comment 5 Steve Tyler 2006-04-28 18:40:10 EDT
(In reply to comment #3)
> what is the first cdrom?
> - sda vs. hda

<g> Good question.
I can come up with several ways to order devices so that there is a "first" device.
1. sort by device name.
2. sort by device number (major, minor)
3. sort first by system address of device controller and
then by device number on the controller.
(I'm thinking of the PCI address of the controller as displayed by lspci.)

Any of these would be deterministic and predictable,
however none are satisfying, because
how symbolic device names are assigned to devices is really a matter of user
preference.

This makes me think a GUI or configuration tool (e.g. system-config-devices)
would provide be a better approach to setting up device names in general.

If, during system installation or booting or after a new device is hotplugged,
there is any ambiguity about which device is the user's preferred cdrom, the
user could be prompted for it.
Comment 6 Steve Tyler 2006-04-28 18:44:50 EDT
> I can come up with several ways to order devices so that there is a "first"
device.

A fourth way:
4. specify in a udev rules file what the ordering should be: hd* < sd*

Note You need to log in before you can comment on or make changes to this bug.