chiark / gitweb /
Merge branch 'docs/udev.xml' of git://github.com/mfwitten/udev
[elogind.git] / extras / rule_generator / write_cd_rules
index 8de227661db449b0273883eb033446b8656090ea..00382ada2fdbfc8c0a1414a29cc0c81736230cda 100644 (file)
@@ -4,12 +4,21 @@
 #
 # It adds symlinks for optical drives based on the device class determined
 # by cdrom_id and used ID_PATH to identify the device.
-#
+
 # (C) 2006 Marco d'Itri <md@Linux.IT>
 #
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by the
-# Free Software Foundation version 2 of the License.
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # debug, if UDEV_LOG=<debug>
 if [ -n "$UDEV_LOG" ]; then
@@ -23,7 +32,7 @@ RULES_FILE="/etc/udev/rules.d/70-persistent-cd.rules"
 . /lib/udev/rule_generator.functions
 
 find_next_available() {
-       raw_find_next_available "$(find_all_rules 'SYMLINK+=' "$1")"
+       raw_find_next_available "$(find_all_rules 'SYMLINK\+=' "$1")"
 }
 
 write_rule() {
@@ -97,7 +106,7 @@ choose_rules_file
 
 link_num=$(find_next_available 'cdrom[0-9]*')
 
-match="ENV{ID_CDROM}==\"?*\", $RULE"
+match="SUBSYSTEM==\"block\", ENV{ID_CDROM}==\"?*\", $RULE"
 
 comment="$ID_MODEL ($ID_PATH)"
 
@@ -108,6 +117,7 @@ comment="$ID_MODEL ($ID_PATH)"
        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"
+echo >> $RULES_FILE
 
 unlock_rules_file