i've never had to mess with hotplug a lot, so these will be simple
questions, i just want to verify that i'm seeing this the right way.
a friend asked me to tweak his embedded linux system so that an
inserted USB key would be automounted. the system is based on busybox
so initial solutions proposed before i was brought in were both mdev
and udev. except that the system has a *static* /dev directory which
makes mdev and udev sort of inappropriate.
after some advice on another mailing list, and based on the fact
that /dev is static, it looks like the solution is to avoid udev and
mdev entirely and just use a custom /sbin/hotplug script. and after
the reading the source of the 2.6.23 kernel (which is what the system
has), this is how i see things.
there are two snippets of kernel source that look relevant.
kernel/sysctl.c:
===============
#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
{
.ctl_name = KERN_HOTPLUG,
.procname = "hotplug",
.data = &uevent_helper,
.maxlen = UEVENT_HELPER_PATH_LEN,
.mode = 0644,
.proc_handler = &proc_dostring,
.strategy = &sysctl_string,
},
#endif
lib/kobject_uevent.c:
====================
...
#if defined(CONFIG_HOTPLUG)
u64 uevent_seqnum;
char uevent_helper[UEVENT_HELPER_PATH_LEN] = "/sbin/hotplug";
...
so here's how i understand it. first, the default script executed
on events is /sbin/hotplug, clearly hardcoded above. so even if i
have no /proc/sys/kernel/hotplug file, hotplugging will still work and
i just need to write and install /sbin/hotplug to get it to do what i
want.
on the other hand, if i *additionally* configure CONFIG_NET, i will
now have the file /proc/sys/kernel/hotplug, with which i can customize
which script is invoked on events. but if i do that, the default
value for that file is empty, so i *must* set it to something;
otherwise, no hotplugging script is invoked. in short, if all i want
is invocation of /sbin/hotplug for all events, i have no need for
/proc/sys/kernel/hotplug to exist. correct?
finally, given that /sbin/hotplug is going to be a shell script in
my case, i was told that i can get all of the info i need just by
examining all of the environment passed in when it's invoked. in
fact, i wrote and installed the following /sbin/hotplug:
=====
#!/bin/sh
env > /tmp/hotplug.env
=====
and what was produced upon insertion of a USB/serial adapter was:
=====
SUBSYSTEM=tty
DEVPATH=/devices/pci0000:00/0000:00:12.0/usb3/3-1/3-1:1.0/ttyUSB0/tty/ttyUSB0
MINOR=0
PATH=/sbin:/bin:/usr/sbin:/usr/bin
ACTION=add
PWD=/
MAJOR=188
DEVNAME=ttyUSB0
SHLVL=1
HOME=/
SEQNUM=1736
_=/usr/bin/env
=====
so it looks good. i just need to add code to the script to handle the
mounting of the USB key.
does all that sound reasonable? have i missed anything?
rday
--
========================================================================
Robert P. J. Day Waterloo, Ontario, CANADA
Linux Consulting, Training and Kernel Pedantry.
Web page: http://crashcourse.ca
Twitter: http://twitter.com/rpjday
========================================================================
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to [email protected]
Please read the FAQ at http://kernelnewbies.org/FAQ