* Some changes in write-cd-rules script
@ 2006-10-26 19:06 Piter PUNK
2006-11-01 14:13 ` md
2006-11-01 15:44 ` Piter PUNK
0 siblings, 2 replies; 3+ messages in thread
From: Piter PUNK @ 2006-10-26 19:06 UTC (permalink / raw)
To: linux-hotplug
[-- 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Some changes in write-cd-rules script
2006-10-26 19:06 Some changes in write-cd-rules script Piter PUNK
@ 2006-11-01 14:13 ` md
2006-11-01 15:44 ` Piter PUNK
1 sibling, 0 replies; 3+ messages in thread
From: md @ 2006-11-01 14:13 UTC (permalink / raw)
To: linux-hotplug
On Oct 26, Piter PUNK <piterpk@terra.com.br> wrote:
> I got the following problems:
Your first problem is that you do not understand the locking rules used
by the script.
> +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
This creates a race.
Also, checking all files in the directory is broken because some may not
be rules files.
I think that there are other problems, but I have not examined carefully
the script.
--
ciao,
Marco
-------------------------------------------------------------------------
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\x120709&bid&3057&dat\x121642
_______________________________________________
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Some changes in write-cd-rules script
2006-10-26 19:06 Some changes in write-cd-rules script Piter PUNK
2006-11-01 14:13 ` md
@ 2006-11-01 15:44 ` Piter PUNK
1 sibling, 0 replies; 3+ messages in thread
From: Piter PUNK @ 2006-11-01 15:44 UTC (permalink / raw)
To: linux-hotplug
md wrote:
> Your first problem is that you do not understand the locking rules used
> by the script.
>
>> +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
>
> This creates a race.
You are correct. The test needs to be after the lock_rules_file.
In our script (cdrom-symlinks.sh) it is after the locking.
> Also, checking all files in the directory is broken because some may not
> be rules files.
I don't know that. I was thinking udev looks in all files under
/etc/udev/rules.d. Now i test renaming some files to DONTRUN, README,
etc.. and it really doesn't read this files. Changing the grep to
*.rules will solve it.
> I think that there are other problems, but I have not examined carefully
> the script.
Good, i will be happy with your feedback.
Piter PUNK
--
| 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
-------------------------------------------------------------------------
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\x120709&bid&3057&dat\x121642
_______________________________________________
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-11-01 15:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-26 19:06 Some changes in write-cd-rules script Piter PUNK
2006-11-01 14:13 ` md
2006-11-01 15:44 ` Piter PUNK
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).