diff -Naur udev-103/extras/rule_generator/write_cd_rules udev-103pk/extras/rule_generator/write_cd_rules --- udev-103/extras/rule_generator/write_cd_rules 2006-10-20 09:43:35.000000000 -0300 +++ udev-103pk/extras/rule_generator/write_cd_rules 2006-10-26 15:34:51.000000000 -0300 @@ -50,29 +50,60 @@ exit 1 fi -# Prevent concurrent processes from modifying the file at the same time. -lock_rules_file -# Check if the rules file is writeable. -choose_rules_file +if ! egrep "^ENV{ID_CDROM}==\"\?\*\", ENV{ID_PATH}==\"$ID_PATH\"" /etc/udev/rules.d/* &>/dev/null ; then + # Prevent concurrent processes from modifying the file at the same time. + lock_rules_file + + # Check if the rules file is writeable. + choose_rules_file + + link_num=$(find_next_available 'cdrom[0-9]*') + [ "$link_num" = "" ] && link_num=0 + + match="ENV{ID_CDROM}==\"?*\", ENV{ID_PATH}==\"$ID_PATH\"" + + comment="$ID_MODEL ($ID_PATH)" + + write_rule "$match" "cdrom$link_num" "$comment" + [ "x$(find_next_available 'cdrom')" = "x" ] && \ + write_rule "$match" "cdrom" + + if [ "$ID_CDROM_DVD" ]; then + write_rule "$match" "dvd$link_num" + [ "x$(find_next_available 'dvd')" = "x" ] && \ + write_rule "$match" "dvd" + if [ "$ID_CDROM_DVD_R" -o "$ID_CDROM_DVD_RW" -o "$ID_CDROM_DVD_RAM" ]; then + write_rule "$match" "dvdrw$link_num" + [ "x$(find_next_available 'dvdwriter')" = "x" ] && \ + write_rule "$match" "dvdwriter" + [ "x$(find_next_available 'writer')" = "x" ] && \ + write_rule "$match" "writer" + fi + fi + + if [ "$ID_CDROM_CD_R" ]; then + write_rule "$match" "cdr$link_num" + [ "x$(find_next_available 'cdwriter')" = "x" ] && \ + write_rule "$match" "cdwriter" + [ "x$(find_next_available 'cdr')" = "x" ] && \ + write_rule "$match" "cdr" + if [ "$ID_CDROM_CD_RW" ]; then + write_rule "$match" "cdrw$link_num" + [ "x$(find_next_available 'cdrw')" = "x" ] && \ + write_rule "$match" "cdrw" + [ "x$(find_next_available 'writer')" = "x" ] && \ + write_rule "$match" "writer" + fi + [ "x$(find_next_available 'writer')" = "x" ] && \ + write_rule "$match" "writer" + fi -link_num=$(find_next_available 'cdrom[0-9]*') -match="ENV{ID_CDROM}==\"?*\", ENV{ID_PATH}==\"$ID_PATH\"" + unlock_rules_file -comment="$ID_MODEL ($ID_PATH)" - - write_rule "$match" "cdrom$link_num" "$comment" -[ "$ID_CDROM_CD_R" -o "$ID_CDROM_CD_RW" ] && \ - write_rule "$match" "cdrw$link_num" -[ "$ID_CDROM_DVD" ] && \ - write_rule "$match" "dvd$link_num" -[ "$ID_CDROM_DVD_R" -o "$ID_CDROM_DVD_RW" -o "$ID_CDROM_DVD_RAM" ] && \ - write_rule "$match" "dvdrw$link_num" - -unlock_rules_file - -echo $SYMLINKS + echo $SYMLINKS +fi exit 0