From: Piter PUNK <piterpk@terra.com.br>
To: linux-hotplug@vger.kernel.org
Subject: Some changes in write-cd-rules script
Date: Thu, 26 Oct 2006 19:06:32 +0000 [thread overview]
Message-ID: <45410738.9040501@terra.com.br> (raw)
[-- Attachment #1: Type: text/plain, Size: 2155 bytes --]
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
[-- Attachment #2: cdrom-naming.patch --]
[-- Type: text/plain, Size: 2678 bytes --]
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
[-- Attachment #3: Type: text/plain, Size: 373 bytes --]
-------------------------------------------------------------------------
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
[-- Attachment #4: Type: text/plain, Size: 226 bytes --]
_______________________________________________
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
next reply other threads:[~2006-10-26 19:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-26 19:06 Piter PUNK [this message]
2006-11-01 14:13 ` Some changes in write-cd-rules script md
2006-11-01 15:44 ` Piter PUNK
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=45410738.9040501@terra.com.br \
--to=piterpk@terra.com.br \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).