Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 158060

Summary: sys-fs/udev-103 creates wrong symlinks to cdrom-devices in /dev
Product: Gentoo Linux Reporter: Tobias Brink <tobias.brink>
Component: [OLD] Core systemAssignee: udev maintainers <udev-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: betelgeuse, gg.alex.weiss
Priority: High    
Version: unspecified   
Hardware: x86   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 126089    
Attachments: Using only new persistent-cd-handling

Description Tobias Brink 2006-12-13 11:36:21 UTC
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; de; rv:1.8.0.8) Gecko/20061114 Firefox/1.5.0.8
Build Identifier: 

After a recent update to sys-fs/udev-103 I found that my apps couldn't find my
dvd drive anymore. I've got two dvd drives (one dvdrw). So there are the
following devices:

/dev/sr0
/dev/sr1

and the following symlinks

/dev/cdrom
/dev/cdrom1
/dev/dvd
/dev/dvd1
/dev/cdrw
/dev/cdrw1
/dev/dvdrw
/dev/dvdrw1

but after every boot they point to either sr0 or sr1, randomly. Sometimes they
all point to sr1. After doing a little research I found the following lines in
/etc/udev/rules.d/50-udev.rules:
ENV{ID_CDROM}=="?*",            PROGRAM="seq_node.sh %r %k cdrom",
SYMLINK+="%c", GROUP="cdrom"
ENV{ID_CDROM_CD_RW}=="?*",      PROGRAM="seq_node.sh %r %k cdrw",  SYMLINK+="%c"
ENV{ID_CDROM_DVD}=="?*",        PROGRAM="seq_node.sh %r %k dvd",   SYMLINK+="%c"
ENV{ID_CDROM_DVD_R}=="?*",      PROGRAM="seq_node.sh %r %k dvdrw", SYMLINK+="%c"

The script referenced by these (/lib/udev/seq_node.sh) states that it tries to
replace the deprecated %e directive and that the author doesn't know what's
wrong with %e, so he reimplemented it. IIRC %e had problems with race
conditions, so my guess would be that this script could have the same problems.

Reproducible: Always

Steps to Reproduce:
1. take a Computer with at least two cdrom drives (or something similar like a
dvd drive)
2. install udev

Actual Results:  
The symlinks I mentioned above point to the wrong devices, randomly.

Expected Results:  
The symlink destinations should be at least consistent between reboots.

udev version 103,

emerge --info:
Portage 2.1.1-r2 (default-linux/x86/2006.1/desktop, gcc-4.1.1, glibc-2.4-r4,
2.6.18-gentoo-r2 i686)
=================================================================
System uname: 2.6.18-gentoo-r2 i686 Intel(R) Pentium(R) 4 CPU 3.00GHz
Gentoo Base System version 1.12.6
Last Sync: Wed, 13 Dec 2006 17:20:01 +0000
app-admin/eselect-compiler: [Not Present]
dev-java/java-config: 1.3.7, 2.0.30
dev-lang/python:     2.4.3-r4
dev-python/pycrypto: 2.0.1-r5
dev-util/ccache:     [Not Present]
dev-util/confcache:  [Not Present]
sys-apps/sandbox:    1.2.17
sys-devel/autoconf:  2.13, 2.60
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2
sys-devel/binutils:  2.16.1-r3
sys-devel/gcc-config: 1.3.14
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.17-r2
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O2 -march=pentium4 -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config
/usr/kde/3.5/shutdown /usr/share/X11/xkb /usr/share/config"
CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/gconf
/etc/java-config/vms/ /etc/revdep-rebuild /etc/splash /etc/terminfo
/etc/texmf/web2c"
CXXFLAGS="-O2 -march=pentium4 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig distlocks metadata-transfer parallel-fetch sandbox sfperms
strict"
GENTOO_MIRRORS="http://pandemonium.tiscali.de/pub/gentoo/
ftp://pandemonium.tiscali.de/pub/gentoo/
ftp://ftp-stud.fht-esslingen.de/pub/Mirrors/gentoo/
http://ftp-stud.fht-esslingen.de/pub/Mirrors/gentoo/"
LINGUAS="de"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress
--force --whole-file --delete --delete-after --stats --timeout=180
--exclude='/distfiles' --exclude='/local' --exclude='/packages'"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY=" "
SYNC="rsync://rsync.de.gentoo.org/gentoo-portage"
USE="x86 X a52 aac aalib acl alsa apache2 arts bash-completion berkdb
bitmap-fonts cairo cdr cjk cli cracklib crypt cups dbus divx4linux dlloader doc
dri dvb dvd dvdr elibc_glibc emacs emboss encode esd fam fame ffmpeg firefox
flac foomaticdb fortran gcj gdbm gif gimp gimpprint gnutls gpm gstreamer gtk
gtk2 hal iconv imap input_devices_joystick input_devices_keyboard
input_devices_mouse ipv6 isdnlog jpeg kde kernel_linux ldap libg++ linguas_de
lirc lirc_devices_hauppauge mad maildir mikmod mmx mng mono mozsvg mp3 mpeg
mplayer mule ncurses nls nptl nptlonly offensive ogg opengl oss pam pcre pdf
perl png postgres ppds pppd python qt3 qt4 quicktime readline real reflection
sasl sdl session socks5 spell spl sse sse2 ssl svg tcltk tcpd theora truetype
truetype-fonts type1-fonts udev unicode usb userland_GNU v4l vcd
video_cards_fbdev video_cards_radeon video_cards_v4l video_cards_vesa vorbis
xine xml xorg xscreensaver xv xvid zlib"
Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LDFLAGS,
PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 Tobias Brink 2006-12-21 08:26:55 UTC
> but after every boot they point to either sr0 or sr1, randomly. Sometimes they
> all point to sr1. After doing a little research I found the following lines in
> /etc/udev/rules.d/50-udev.rules:
> ENV{ID_CDROM}=="?*",            PROGRAM="seq_node.sh %r %k cdrom",
> SYMLINK+="%c", GROUP="cdrom"
> ENV{ID_CDROM_CD_RW}=="?*",      PROGRAM="seq_node.sh %r %k cdrw", 
> SYMLINK+="%c"
> ENV{ID_CDROM_DVD}=="?*",        PROGRAM="seq_node.sh %r %k dvd",  
> SYMLINK+="%c"
> ENV{ID_CDROM_DVD_R}=="?*",      PROGRAM="seq_node.sh %r %k dvdrw",
> SYMLINK+="%c"

BTW, removing/commenting these lines leads to the system using the rules in /etc/udev/rules.d/75-cd-aliases-generator.rules, which are better (always the same symlinks after reboot, sr0 is cdrom, sr1 is cdrom1) but have a tiny problem:
As my DVD-burner is the second drive (sr1), its symlink is /dev/cdrw1 and not /dev/cdrw, which doesn't exist. At least this is still better than random device symlinks.
Comment 2 Tobias Brink 2006-12-22 07:47:18 UTC
(In reply to comment #1)
> BTW, removing/commenting these lines leads to the system using the rules in
> /etc/udev/rules.d/75-cd-aliases-generator.rules, which are better (always the
> same symlinks after reboot, sr0 is cdrom, sr1 is cdrom1) but have a tiny
> problem:
> As my DVD-burner is the second drive (sr1), its symlink is /dev/cdrw1 and not
> /dev/cdrw, which doesn't exist. At least this is still better than random
> device symlinks.

What I said there isn't true. Today the mentioned setup showed the same problems as the original one. Should have checked it better before reporting, sorry.
Comment 3 Francisco Lloret 2006-12-31 05:53:04 UTC
I have two internat CD drives: hdc, dvd-rom, and hdd, cdrw drive and an external DVDRW drive, conected by USB.

After power-on the system, with external drive powered off:

AthlonXP ~ $ ls -ld /dev/dv*
lrwxrwxrwx 1 root root 3 dic 31 13:48 /dev/dvd -> hdc
lrwxrwxrwx 1 root root 3 dic 31 13:48 /dev/dvd1 -> hdc
AthlonXP ~ $ ls -ld /dev/cd*
lrwxrwxrwx 1 root root 3 dic 31 13:48 /dev/cdrom -> hdc
lrwxrwxrwx 1 root root 3 dic 31 13:48 /dev/cdrom1 -> hdc
lrwxrwxrwx 1 root root 3 dic 31 13:48 /dev/cdrw -> hdd 

I power on the external dvdrw drive, and then:

AthlonXP ~ $ ls -ld /dev/cd*
lrwxrwxrwx 1 root root 3 dic 31 13:51 /dev/cdrom -> sr0
lrwxrwxrwx 1 root root 3 dic 31 13:48 /dev/cdrom1 -> hdc
lrwxrwxrwx 1 root root 3 dic 31 13:51 /dev/cdrom2 -> sr0
lrwxrwxrwx 1 root root 3 dic 31 13:51 /dev/cdrw -> sr0
lrwxrwxrwx 1 root root 3 dic 31 13:51 /dev/cdrw1 -> sr0
AthlonXP ~ $ ls -ld /dev/dv*
lrwxrwxrwx 1 root root 3 dic 31 13:51 /dev/dvd -> sr0
lrwxrwxrwx 1 root root 3 dic 31 13:48 /dev/dvd1 -> hdc
lrwxrwxrwx 1 root root 3 dic 31 13:51 /dev/dvd2 -> sr0
lrwxrwxrwx 1 root root 3 dic 31 13:51 /dev/dvdrw -> sr0 

After this, i disconnect the external drive, and then:

AthlonXP ~ $ ls -ld /dev/dv*
lrwxrwxrwx 1 root root 3 dic 31 13:48 /dev/dvd1 -> hdc
AthlonXP ~ $ ls -ld /dev/cd*
lrwxrwxrwx 1 root root 3 dic 31 13:48 /dev/cdrom1 -> hdc 

Except dvd1 and cdrom1, all other symlinks are missing.
Comment 4 J.O. Aho 2007-01-03 10:33:54 UTC
I can second this, I have two machines (x86) which has multiple cdrom/dvd, don't reboot thise so often, but noticed that half of the symlinks pointed at the wrong unit.

At least I haven't had this problem before, so thinking of masking the 10x series and go back to  98, which I think did work fine for me.
Comment 5 Matthias Schwarzott gentoo-dev 2007-01-14 16:03:21 UTC
As current udev-103 ebuild has two sets of rules for cdrom-devices:
1. in 50-udev.rules: Using perhaps broken seq_node.sh.
2. in 70-persistent-cd.rules  75-cd-aliases-generator.rules

I vote for deleting Part 1 and just keeping the calls to cdrom_id and the GROUP setting.


Even better would be version bumping to udev-104 as that seems to generate better rules based on serial-number and or similar.
Changes needed here as I suggest are:
1. Delete all cdrom-rules from 50-rules.
2. Use new 60-cdrom_id.rules.
3. Add a pure ownership rule to 60-cdrom_id.rules:
ENV{ID_CDROM}=="?*", GROUP="cdrom"
Comment 6 Matthias Schwarzott gentoo-dev 2007-01-14 16:11:37 UTC
Created attachment 106947 [details, diff]
Using only new persistent-cd-handling
Comment 7 Matthias Schwarzott gentoo-dev 2007-01-22 13:49:36 UTC
Old cdrom-handling has been removed and works correct from udev-ebuilds starting with udev-103-r3.
Comment 8 Jakub Moc (RETIRED) gentoo-dev 2007-01-26 20:39:58 UTC
(In reply to comment #7)
> Old cdrom-handling has been removed and works correct from udev-ebuilds
> starting with udev-103-r3.

Closing as FIXED. 

Comment 9 Matthias Schwarzott gentoo-dev 2007-02-04 20:42:44 UTC
*** Bug 165328 has been marked as a duplicate of this bug. ***