From mboxrd@z Thu Jan 1 00:00:00 1970 From: Piter PUNK Date: Thu, 26 Oct 2006 19:06:32 +0000 Subject: Some changes in write-cd-rules script Message-Id: <45410738.9040501@terra.com.br> MIME-Version: 1 Content-Type: multipart/mixed; boundary="------------020906010903030007030108" List-Id: To: linux-hotplug@vger.kernel.org This is a multi-part message in MIME format. --------------020906010903030007030108 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, I start to make udev-103 packages to test with slackware 11.0, and i try to drop slackware's custom script to name CD and network devices (my first work is against CD script) and begin to use the provided in udev/extras/rule_generator. I got the following problems: 1. In a machine with one CD-RW and one DVD drives, the current script doesn't create the /dev/dvd symlink. It detects the CD-RW and creates: cdrom, cdr and cdrw, and to the DVD it creates: cdrom1 and dvd1. 2. The rules created by the write-cd-rules needs to be between udev.rules and cd-aliases-generator.rules. And in slackware we doesn't ship many rules files, but only one udev.rules. 3. K3B uses /dev/writer, and write-cd-rules doesn't create this link. To solve these problems i made some changes in write-cd-rules. The changes are in attached patch and does: 1. Always create numbered links, and made the without-number link to the "first one" detect. In the CD-RW and DVD drive it creates to the CD-RW: cdrom0, cdrom, cdr0, cdr, cdwriter, and to DVD it creates: cdrom1, dvd1, dvd. And the users can use /dev/dvd without problems. 2. I added one test to check if there is one rule with the same DEVPATH before create the links. If there is a rule the script only returns 0 and exits. With that i can put the cd-aliases-generator.rules inside udev.rules (i put the cdrom_id.rules in udev.rules, too) and the things still works. The ppl that use split files doesn't have any impact with that. 3. Create the /dev/writer to the most powerful writer: DVD-RW/DVD-R/DVD-RAM -> CD-RW -> CD-R, in that order. I hope it can help. The 1 and 3 can be useful to everyone, and the 2 is useful to ppl that ships only one big file. Thanks for all, Piter PUNK PS> Sugestions and fixes are welcome -;) -- | E-Mail: piterpk@terra.com.br (personal) .|. roberto.batista@ntux.com.br (professional) /V\ // \\ UIN:116043354 Homepage:http://piterpunk.info02.com.br /( )\ ^`~'^ ----> Slackware Linux - The Best One! <---- #105432 --------------020906010903030007030108 Content-Type: text/plain; name="cdrom-naming.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="cdrom-naming.patch" 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 --------------020906010903030007030108 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 --------------020906010903030007030108 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel --------------020906010903030007030108--