mirror of
https://github.com/systemd/systemd.git
synced 2026-07-25 08:45:56 +00:00
33db4b8da001242b8b3b0ce8a746ef46d4416d6d
Here is the next round of udevd/udevsend:
udevsend - If the IPC message we send is not catched by a receiver we fork
the udevd daemon to process this and the following events
udevd - We reorder the events we receive and execute our current udev for
every event. If one or more events are missing, we wait
10 seconds and then go ahead in the queue.
If the queue is empty and we don't receive any event for the next
30 seconds, the daemon exits.
The next incoming event will fork the daemon again.
config - The path's to the executable are specified in udevd.h
Now they are pointing to the current directory only.
I don't like daemons hiding secrets (and mem leaks :)) inside,
so I want to try this model. It should be enough logic to get all possible
hotplug events executed in the right order.
If no event, then no daemon! So everybody should be happy :)
Here we see:
1. the daemon fork,
2. the udev work,
3. the 10 sec timeout and the skipped events,
4. the udev work,
...,
5. and the 30 sec timeout and exit.
EVENTS:
pim:/home/kay/src/udev.kay# test/udevd_test.sh
pim:/home/kay/src/udev.kay# SEQNUM=15 ./udevsend block
pim:/home/kay/src/udev.kay# SEQNUM=16 ./udevsend block
pim:/home/kay/src/udev.kay# SEQNUM=17 ./udevsend block
pim:/home/kay/src/udev.kay# SEQNUM=18 ./udevsend block
pim:/home/kay/src/udev.kay# SEQNUM=20 ./udevsend block
pim:/home/kay/src/udev.kay# SEQNUM=21 ./udevsend block
LOG:
Jan 23 15:35:35 pim udev[11795]: message is still in the ipc queue, starting daemon...
Jan 23 15:35:35 pim udev[11799]: configured rule in '/etc/udev/udev.rules' at line 19 applied, 'sda' becomes '%k-flash'
Jan 23 15:35:35 pim udev[11799]: creating device node '/udev/sda-flash'
Jan 23 15:35:35 pim udev[11800]: creating device node '/udev/sdb'
Jan 23 15:35:35 pim udev[11804]: creating device node '/udev/sdc'
Jan 23 15:35:35 pim udev[11805]: removing device node '/udev/sda-flash'
Jan 23 15:35:35 pim udev[11808]: removing device node '/udev/sdb'
Jan 23 15:35:35 pim udev[11809]: removing device node '/udev/sdc'
Jan 23 15:35:45 pim udev[11797]: timeout reached, skip events 7 - 7
Jan 23 15:35:45 pim udev[11811]: creating device node '/udev/sdb'
Jan 23 15:35:45 pim udev[11812]: creating device node '/udev/sdc'
Jan 23 15:36:01 pim udev[11797]: timeout reached, skip events 10 - 14
Jan 23 15:36:01 pim udev[11814]: creating device node '/udev/sdc'
Jan 23 15:36:04 pim udev[11816]: creating device node '/udev/sdc'
Jan 23 15:36:12 pim udev[11818]: creating device node '/udev/sdc'
Jan 23 15:36:16 pim udev[11820]: creating device node '/udev/sdc'
Jan 23 15:36:38 pim udev[11797]: timeout reached, skip events 19 - 19
Jan 23 15:36:38 pim udev[11823]: creating device node '/udev/sdc'
Jan 23 15:36:38 pim udev[11824]: creating device node '/udev/sdc'
Jan 23 15:37:08 pim udev[11797]: we have nothing to do, so daemon exits...
udev - a userspace implementation of devfs
For more information on the design, and structure of this project, see the
files in the docs/ directory.
To use:
- You must be running a 2.6 version of the Linux kernel.
- Your 2.6 kernel must have had CONFIG_HOTPLUG enabled when it was built.
- Make sure sysfs is mounted. udev will figure out where sysfs is mounted, but
the traditional place for it is at /sys. You can mount it by hand by running:
mount -t sysfs none /sys
- Make sure you have the latest version of the linux-hotplug scripts. They are
available at linux-hotplug.sf.net or from your local kernel.org mirror at:
kernel.org/pub/linux/utils/kernel/hotplug/
They are required in order for udev to work properly.
If for some reason you do not install the hotplug scripts, you must tell the
kernel to point the hotplug binary at wherever you install udev at. This can
be done by:
echo "/sbin/udev" > /proc/sys/kernel/hotplug
- Build the project:
make
Note:
There are a number of different flags that you can use when building
udev. They are as follows:
prefix
set this to the default root that you want udev to be
installed into. This works just like the 'configure --prefix'
script does. Default value is ''. Only override this if you
really know what you are doing.
USE_KLIBC
if set to 'true', udev is built and linked against the
included version of klibc. Default value is 'false'.
USE_LOG
if set to 'true', udev will emit messages to the syslog when
it creates or removes device nodes. This is helpful to see
what udev is doing. This is enabled by default. Note, if you
are building udev against klibc it is recommended that you
disable this option (due to klibc's syslog implementation.)
USE_DBUS
if set to 'true', DBUS messages will be sent everytime udev
creates or removes a device node. This requires that DBUS
development headers and libraries be present on your system to
build properly. Default value is 'false'.
DEBUG
if set to 'true', debugging messages will be sent to the syslog
as udev is run. Default value is 'false'.
So, if you want to build udev using klibc with debugging messages, you
would do:
make USE_KLIBC=true DEBUG=true
Note: If you want to use klibc, you will have to set up the "linux"
symlink properly. See the file klibc/klibc/README and pay
attention to step "a)" there.
- Install the project:
make install
This will put the udev binary in /sbin, create the /udev and /etc/udev
directories, and place the udev configuration files in /etc/udev. You
will probably want to edit the namedev.* files to create custom naming
rules. More info on how the config files are set up are contained in
comments in the files, and is located in the documentation.
- Add and remove devices from the system and marvel as nodes are created
and removed in /udev/ based on the device types.
- If you later get sick of it, uninstall it:
make uninstall
Things are still quite rough, but it should work properly. If nothing
seems to happen, make sure your build worked properly by running the
udev-test.pl script as root in the test/ subdirectory of the udev source
tree.
Development and documentation help is very much appreciated, see the TODO
file for a list of things left to be done.
Any comment/questions/concerns please let me and the other udev developers
know by sending a message to the linux-hotplug-devel mailing list at:
linux-hotplug-devel@lists.sourceforge.net
greg k-h
greg@kroah.com
Languages
C
88.8%
Shell
5.3%
Python
4.7%
Meson
1.1%