Ok, before you flame me for hitting this topic _again_, I understand
that there are many problems with links like /dev/cdrom and /dev/mouse.
But right now our biggest problem is users mailing the linux-xfs list
after they use our installer, complaining "Hey! There's no /dev/cdrom
or /dev/mouse!" :)
So I thought I'd embark on an experiment of making /dev/cdrom show up
automagically if that's what the user really wants. The other
constraint I've imposed upon myself is to do it from within the devfsd
package, rather than relying on initscripts, so that our installer
doesn't have to contain another modified version of a standard Red Hat
package (initscripts) that will break if they upgrade from Red Hat.
So here's what I've tried, maybe somebody can tell me where I went
wrong. It works most of the time, but after some unmounts or module
unloads, it breaks.
The plan is that if someone tries to access /dev/cdrom, it will:
1) load the necessary modules
2) create a link from /dev/cdrom to /dev/cdroms/cdromX where X is the
lowest available number.
First, I added this line to devfsd.conf, so that when a user tries to
access /dev/cdrom, appropriate action will be taken:
LOOKUP cdrom EXECUTE /etc/rc.d/rc.devfs-cdrom
and then clean up after it on unload:
UNREGISTER cdroms/.* CFUNCTION GLOBAL unlink cdrom
Then, I added this to /etc/modules.conf, so that devfsd module
autoloading will work for /dev/cdrom:
alias /dev/cdrom* /dev/cdroms
And finally, here's the script that gets EXECUTEd from devfsd.conf:
#!/bin/bash
#
# /etc/rc.devfs-cdrom - run by devfsd when something looks for
/dev/cdrom
rm -f /dev/cdrom # in case of old links
if [ -c /dev/.devfsd -a -x /sbin/devfsd ]; then
for i in /dev/cdroms/*; do
ln -sf $i /dev/
echo $i
if [ ! -x /dev/cdrom ]; then
ln -sf $i /dev/cdrom # link the first cd
fi
done
fi
# End of script
But, this doesn't always work. Any suggestions?
One more quick question - why does X in /dev/cdroms/cdromX get
incremented each time the ide-cd module is reloaded? Is that the
expected behaviour?
Thanks,
-Eric
--
Eric Sandeen XFS for Linux http://oss.sgi.com/projects/xfs
sandeen@xxxxxxx SGI, Inc.
|