IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an
email to Administrator. User accounts are meant only to access repo
and report issues and/or generate pull requests.
This is a purpose-specific Git hosting for
BaseALT
projects. Thank you for your understanding!
Только зарегистрированные пользователи имеют доступ к сервису!
Для получения аккаунта, обратитесь к администратору.
Modern rules are expected to call notification and postprocessing with
the RUN key. For compatibility the current behavior can be emulated
with an external helper.
Signed-off-by: Kay Sievers <kay.sievers@suse.de>
Here's a long overdue update to the udev rules docs, based on lots of user
feedback from the last few months.
Mostly updates to keep up with the new udev features, some clarifications and
wording improvements. I added a section on rules for palm pilots due to the
excessive amount of mail I get about them. I removed the nvidia stuff because
it's out of date. Added another section about debugging using logs and
udevtest. Removed the thanks list because I haven't been updating it and there
are too many people to name now, sorry..!
SUBSYSTEM=="block", RUN="/sbin/program"
will execute the program only for block device events.
ACTION="remove", SUBSYSTEM=="block", RUN"/sbin/program"
will execute the program, if a block device is removed.
Better remove characters that are useless in a device node name.
It may be a security risk to pass any character read from e.g. a
sysfs attribute to a shell script we execute later.
Prevent the modification of the libsysfs attribute value
cache.
Clear PROGRAM result if the execution encountered an error.
Fix from: Hannes Reinecke <hare@suse.de>
namedev_parse is a bit overzealous when in comes to handling backspaces;
it always eats up backspaces regardless of anything beyond that. This
means it is impossible to enter '\t' in a rule. Quite a bit of fun when
you're trying to write regexps.
Here we move all possible options into a own key to make it possible
to have options-only rules.
The options on the NAME key are removed from the man page and will
be removed from a future version of udev.
For ignore rules, OPTIONS="ignore" should be used.
The rule:
SUBSYSTEM="block", SYSFS{removable}="1", OPTIONS="all_partitions"
will create all partitions for a block device which is known to have
removable media (a check for cdrom drives would be needed too).
Just stat() the "dev" file in the device directory instead of
opening the directory and iterating over all entries.
Make udevstart work with the settings in with udev.conf so we can
run a test program.
Add a test for udevstart.
Remove changelog stuff from code. We should never start with this
silly thing.
Events for partition devies may want to read the main block device
name to compose it's own name or read a disklabel from the main device.
SUBSYSTEM="block", KERNEL="*[1-9]", NAME="%P-p%n"
will append the partition number to the name of the main block device.
With the "permissions only rules" we can just place:
MODE="0660", OWNER="root", GROUP="root"
at the beginning of the rules file and get exactly the same behavior.
If no values are given the compiled-in defaults are used.
On Mon, 2004-12-20 at 15:03 +0100, Marco d'Itri wrote:
> +# all block devices
> > +SUBSYSTEM="block", NAME="%k", GROUP="disk"
> > +
> NAME="%k" here and in similar rules does not add any new information,
> what about making it optional, like it is for SYMLINK-only rules?
On Sun, 2004-12-19 at 18:31 +0100, Marco d'Itri wrote:
> > On Dec 19, Kay Sievers <kay.sievers@vrfy.org> wrote:
>
> > (Feature request: would it be possible to extend the rules files parser
> > to support continuation lines? I'd like it to consider lines starting
> > with white space as part of the previous line.)
>
> How about the usual backslash at the end of the line. Here is a simple
> patch.
On Sun, 2004-12-19 at 18:31 +0100, Marco d'Itri wrote:
> It may be better to use default_mode="0660", I do not think that there
> are any mode 600 devices. This would allow setting only the group for
> most of them.
A hour wrap during the test run does not work :) Just remove
all the useless date conversions as we are only interested in the
seconds it takes to process.
[root@pim udevd-test]# ./udevd-test.pl 9
...
device: /class/tty/console, action: remove
forking udev time: Sat Dec 11 18:59:57 2004
the delay time is: 3 s
device: /class/tty/ptmx, action: remove
forking udev time: Sat Dec 11 19:00:07 2004
the delay time is: 4013 s
the delay time is: 4013
udevd doesn't act properly.
Some broken ide drivers are generating high event traffic, with
add/remove events. With this attribute, it can be specified,
that the node is always available. It may be used in conjunction
with the new DRIVER= match to catch specific kernel device drivers.
This makes the udev operation completely lockless by storing a
file for every node in /dev/.udevdb/* This solved the problem
with deadlocking concurrent udev processes waiting for each other
to release the file lock under heavy load.
Here is the first patch to cleanup the internal processing of the
various stages of an udev event. It should not change any behavior,
but if your system depends on udev, please always test it before reboot :)
We pass only one generic structure around between add, remove,
namedev, db and dev_d handling and make all relevant data available
to all internal stages. All udev structures are renamed to "udev".
We replace the fake parameter by a flag in the udev structure.
We open the class device in the main binaries and not in udev_add, to
make it possible to use libsysfs for udevstart directory crawling.
The last sleep parameters are removed.
when udevstart was running we didn't set the environment and the
subsystem argument for the callouts the dev.d/ scripts.
Here is a fix, that sets that with every udevstart iteration, corrects
argv[0] to be the basename() only not the whole path and adds a test
for invoking callouts without arguments.
On Fri, Sep 10, 2004 at 01:09:07PM -0700, Greg KH wrote:
> On Tue, Sep 07, 2004 at 01:19:34PM +0200, David Zeuthen wrote:
> >
> > KERNEL="sr*", NAME="%k", SYMLINK="cdrom%e"
> > KERNEL="scd*", NAME="%k", SYMLINK="cdrom%e"
> > KERNEL="pcd*", NAME="%k", SYMLINK="cdrom%e"
> > KERNEL="hd[a-z]", PROGRAM="/bin/cat /proc/ide/%k/media", RESULT="cdrom", NAME="\%k", SYMLINK="cdrom%e"
> > KERNEL="fd[0-9]", NAME="%k", SYMLINK="floppy%e"
> > KERNEL="hd[a-z]", PROGRAM="/bin/cat /proc/ide/%k/media", RESULT="floppy", NAME=\"%k", SYMLINK="floppy%e"
> >
> > New patch is attached.
>
> Nice, I've applied this.
>
> How about sending a patch for the test/udev-test.pl script that adds a
> test for this new paramater, so we make sure to not break it in the
> future.
Here are the tests for the enumeration character %e. I've added a option
string to be able to do a whole sequence of tests without node removal,
so we can skip the "remove" event and get an increasing number to append
to the name. After the sequence test the whole directory is cleaned for
the next tests.
On Tue, Sep 14, 2004 at 02:53:12PM +0200, Loleslaw wrote:
> Hi,
> Since I started using udev-031 on my gentoo udevstart would just segfault
> (udev-030 worked). As it turned out I had a file in /etc/udev/permissions.d
> with a single space in one line. I've cleaned the file and it works all
> right, but I thought you could be interested.
> I've traced it to function namedev_init_permissions in namedev_parse.c
> I don't know C well enough to suggest a patch.
Yeah, thanks for pointing that out. It only happens if the file ends with
whitespace-only lines. Here is a fix and a test for udev-test.pl to
cover that case.
Thanks to Yin, Hu <hu.yin@intel.com>, who made a nice perl script to test the
expected behavior of the udevd sequence number handling. The test sends
different SEQNUM sequences to udevd, while analyzing the reordering and timeout
handling of udevd.
Here is a patch to change the netdev handling in the database and for
the dev.d/ calls. I applies on top of the udevd.patch, cause klibc has
no sysinfo().
o netdev's are also put into our database now. I want this for the
udevruler gui to get a list of all handled devices.
All devices in the db are stamped with the system uptime value at
the creation time. 'udevinfo -d' prints it.
o the DEVPATH value is the key for udevdb, but if we rename
a netdev, the name is replaced in the kernel, so we add
the changed name to the db to match with the remove event.
NOTE: The dev.d/ scripts still get the original name from the
hotplug call. Should we replace DEVPATH with the new name too?
o We now only add a device to the db, if we have successfully created
the main node or successfully renamed a netdev. This is the main part
of the patch, cause I needed to clean the retval passing trough all
the functions used for node creation.
o DEVNODE sounds a bit ugly for netdev's so I exported DEVNAME too.
Can we change the name?
o I've added a UDEV_NO_DEVD to possibly skip the script execution
and used it in udev-test.pl.
udevstart is the same horror now, if you have scripts with logging
statements in dev.d/ it takes minutes to finish, can we skip the
scripts here too?
o The get_device_type() function is changed to be more strict, cause
'udevinfo -a -p /block/' gets a class device for it and tries to
print the major/minor values.
o bugfix, the RESULT value has now a working newline removal and a test
for this case.
Hmm, Arndt Bergmann sent a patch like this one a few weeks ago and
I want to bring the question back, if we want to handle net device
naming with udev.
With this patch it is actually possible to specify something like this
in udev.rules:
KERNEL="dummy*", SYSFS{address}="00:00:00:00:00:00", SYSFS{features}="0x0", NAME="blind%n"
KERNEL="eth*", SYSFS{address}="00:0d:60:77:30:91", NAME="private"
and you will get:
[root@pim udev.kay]# cat /proc/net/dev
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
lo: 1500 30 0 0 0 0 0 0 1500 30 0 0 0 0 0 0
private: 278393 1114 0 0 0 0 0 0 153204 1468 0 0 0 0 0 0
sit0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
blind0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
The udevinfo program is also working:
[root@pim udev.kay]# ./udevinfo -a -p /sys/class/net/private
looking at class device '/sys/class/net/private':
SYSFS{addr_len}="6"
SYSFS{address}="00:0d:60:77:30:91"
SYSFS{broadcast}="ff:ff:ff:ff:ff:ff"
SYSFS{features}="0x3a9"
SYSFS{flags}="0x1003"
SYSFS{ifindex}="2"
SYSFS{iflink}="2"
SYSFS{mtu}="1500"
SYSFS{tx_queue_len}="1000"
SYSFS{type}="1"
follow the class device's "device"
looking at the device chain at '/sys/devices/pci0000:00/0000:00:1e.0/0000:02:01.0':
BUS="pci"
ID="0000:02:01.0"
SYSFS{class}="0x020000"
SYSFS{detach_state}="0"
SYSFS{device}="0x101e"
SYSFS{irq}="11"
SYSFS{subsystem_device}="0x0549"
SYSFS{subsystem_vendor}="0x1014"
SYSFS{vendor}="0x8086"
The matching device will be renamed to the given name. The device name
will not be put into the udev database, cause the kernel renames the
device and the sysfs name disappears.
I like it, cause it plugs in nicely. We have all the naming features
and sysfs queries and walks inside of udev. The sysfs timing races
are already solved and the management tools are working for net devices
too. nameif can only match the MAC address now. udev can match any sysfs
value of the device tree the net device is connected to.
But right, net devices do not have device nodes :)
> Nice, that's a good start. Now we need to check the major:minor values
> too somehow...
I better do it immediately, before you put it in the empty TODO :)
Patch is a bit big, cause spaces are changed to tabs to get
space for the longer names.
> Any chance on being able to add a test for this kind of stuff to the
> udev-test.pl script?
Sure, not brilliant but seems to work :)
Only numeric id's are supported so far.
Martin Schwenke <martin@meltin.net> asked for this feature and posted a
patch:
The following patch almost let's me have the following configuration:
PROGRAM="/sbin/aliaser %b %k %n %M %m", RESULT="?*", NAME="%c{1}", SYMLINK="%c{2+}"
allowing me to specify an arbitrary number of symlinks by saying
"giveme the second and later words"."
Here is the actual version with tests and a few words in the man page.
Here I change the callout fork logic.
The current cersion is unable to read a pipe which is not flushed at once,
Now we read until it's closed.
The maximum argument count is calculated by the strlen now. We have 100
chars for our result buffer so we can't have more than 50 parameters.
So it's much more clear what will happen now and not some magic boundary
where we use shell behind it.
Parameter can be combined to one by using apostrophes.
this on works now:
BUS="scsi", PROGRAM="/bin/sh -c 'echo foo3 foo4 foo5 foo6 foo7 foo8 foo9 | sed s/foo9/bar9/'", KERNEL="sda3", NAME="%c{7}"
Two new test are also added.
Hey, it may never happen, that one wants to distinguish attributes by
trailing spaces, but we should not lose the control over it, just for
being lazy :)
Here we remove the trailing spaces of the sysfs attribute only if the
configured value to match doesn't have any trailing spaces by itself.
So if you put a attribute in a rule with spaces at the end, the sysfs
attribute _must_ match exactly.
Is that cool for everyone?
As usual, 2 tests are added for it with a artificial sysfs file and
a few words to the man page.
We carried the the old callout part selector syntax for two releases
now after it was replaced by the new %c{1} syntax. So here we remove
the old syntax and use the code to possibly specify the maximum count
of chars to insert into the string. It will work with all of our format
chars.
I don't know if somebody will use it, but the code is already there :)
's%3s{vendor}' returns "IBM" now, instead of "IBM-ESXS".
Also added is a test for it and a few words in the man page.
Here we change the magic callout part number selector to the new
atribute syntax. The syntax to select the second part of the callout string:
'%2c' is now '%c{2}'
I think it's more clear and we no longer misuse the length argument.
The old syntax is still supported, but we should remove it some
time in the future.
Here we switch the configs and man pages to the new attribute syntax.
Also the 'partition trick' is mentioned in udev.8
I think it's more clear visible now, that inside the brackets are user
supplied values used and not some magic keys handled:
'SYSFS_dev' is now 'SYSFS{dev}'
The old syntax is still supported.
Here is the first try to create all partitons of a blockdevice, since
removable media devices may need to acces the expected partition to
revalidate the media.
It uses the attribute syntax introduced with the last %s{file} patch.
I'm using this with my multi-slot-flash-card-reader:
SYSFS{model}="USB Storage-SMC ", NAME{all_partitions}="smartmedia"
SYSFS{model}="USB Storage-CFC ", NAME{all_partitions}="compactflash"
SYSFS{model}="USB Storage-MSC ", NAME{all_partitions}="memorystick"
SYSFS{model}="USB Storage-MMC ", NAME{all_partitions}="multimedia"
and I get:
tree /udev/
/udev/
|-- memorystick
|-- memorystick1
|-- memorystick10
|-- memorystick11
|-- memorystick12
|-- memorystick13
|-- memorystick14
|-- memorystick15
|-- memorystick2
|-- memorystick3
|-- memorystick4
|-- memorystick5
|-- memorystick6
|-- memorystick7
|-- memorystick8
|-- memorystick9
|-- multimedia
|-- multimedia1
|-- multimedia10
|-- multimedia11
|-- multimedia12
|-- multimedia13
|-- multimedia14
|-- multimedia15
|-- multimedia2
|-- multimedia3
|-- multimedia4
|-- multimedia5
|-- multimedia6
|-- multimedia7
|-- multimedia8
|-- multimedia9
...
If needed, we can make the number of partions to create
adjustable with the attribute?
On Sun, Feb 15, 2004 at 03:36:00AM +0100, Kay Sievers wrote:
>
> Since we have %s{file} it may be nice to allow SYSFS{file}.
> This patch allows:
>
> BUS="usb", SYSFS{idProduct}="a511", NAME="video%n"
>
> compared to the current:
>
> BUS="usb", SYSFS_idProduct="a511", NAME="video%n"
>
> The curent syntax is still supported.
> Looks a bit nicer and less hackish, I think.
Better patch with infrastructure to easily implement KEY{attribute}
for every other key. The first user is the SYSFS{file} key.
Both versions, brackets or underscore is supported for the attribute.
On Thu, Feb 12, 2004 at 05:34:57PM -0800, Greg KH wrote:
> On Tue, Feb 10, 2004 at 09:14:20AM +0100, Hannes Reinecke wrote:
> > Hi all,
> >
> > this patch makes the format for NAME and SYMLINK a bit more flexible:
> > I've added a new format specifier '%s{<SYSFS_var>}', which allows for
> > the value of any sysfs entry found for this device to be inserted.
> > Example (for our S/390 fcp adapter):
> >
> > BUS="ccw", SYSFS_devtype="1732/03", NAME="%k" \
> > SYMLINK="zfcp-%s{hba_id}-%s{wwpn}:%s{fcp_lun}"
> >
> > I know this could also be done with an external program, but having this
> > incorporated into udev makes life easier, especially if run from
> > initramfs. Plus it makes the rules easier to follow, as the result is
> > directly visible and need not to be looked up in some external program.
> >
> > Comments etc. welcome.
>
> Oops, sorry I missed this for the 017 release. I'll look at it tomorrow
> and get back to you. At first glance it looks like a good thing.
>
> Oh, you forgot to update the documentation, that's important to do if
> you want this change to make it in :)
I took a part of the code and made a version that uses already implemented
attribute finding logic.
The parsing of the format length '%3x' and the '%x{attribute}' is a fuction now,
maybe there are more possible users in the future.
I've also added the test to udev-test.pl.
just put the test number on the command line:
udev-test.pl 3
will run test number 3
If no test number is specified, all of the tests will be run, just like before.