1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-28 20:25:38 +03:00
Commit Graph

56 Commits

Author SHA1 Message Date
kay.sievers@vrfy.org
882af735ec [PATCH] remove PLACE key match
ID should do the same, cause we walk up the chain of devices on the
physical device and can match for the name of every device there with
the ID key.
2005-04-26 23:51:00 -07:00
kay.sievers@vrfy.org
138068d690 [PATCH] fix ia64 compile 2005-04-26 23:51:00 -07:00
kay.sievers@vrfy.org
63f61c5cf6 [PATCH] replace strncpy()/strncat() by strlcpy()/strlcat() 2005-04-26 23:51:00 -07:00
kay.sievers@vrfy.org
f0308095c7 [PATCH] remove typedef for call_foreach_file() handler function 2005-04-26 23:39:48 -07:00
kay.sievers@vrfy.org
c98cb35eb5 [PATCH] rename attributes to options 2005-04-26 23:39:48 -07:00
kay.sievers@vrfy.org
77313cd0d1 [PATCH] namedev: skip backslashes only if followed by newline
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.
2005-04-26 23:39:48 -07:00
kay.sievers@vrfy.org
69f57c6a2b [PATCH] detect NAME="" as ignore_device rule 2005-04-26 23:36:13 -07:00
kay.sievers@vrfy.org
5e39f90b14 [PATCH] trivial namedev cleanup 2005-04-26 23:36:13 -07:00
kay.sievers@vrfy.org
fd9efc00a2 [PATCH] introduce OPTIONS=ignore_device, ignore_remove, all_partitions" key
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).
2005-04-26 23:36:12 -07:00
kay.sievers@vrfy.org
6d56416665 [PATCH] create /block/*/range count of partitons for all_partitions 2005-04-26 23:27:41 -07:00
kay.sievers@vrfy.org
1134a81b98 [PATCH] fix -Wsign-compare warnings 2005-04-26 23:24:19 -07:00
kay.sievers@vrfy.org
9f8dfa19cf [PATCH] allow multiline rules by backslash at the end of the line
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.
2005-04-26 23:19:09 -07:00
kay.sievers@vrfy.org
8b36cc0f17 [PATCH] complete removal of explicit udev permissions config file 2005-04-26 23:17:47 -07:00
kay.sievers@vrfy.org
5f72c470ad [PATCH] simplify permission handling
Initialize the defaults in udev_config.c instead of namedev.c.
Replace macro by expanded code. Switch to mode_t instead
of string value. Add and clarify some comments.
2005-04-26 23:00:29 -07:00
kay.sievers@vrfy.org
9af5bb2f8f [PATCH] rename udev_lib to udev_utils and dev_d to udev_multiplex 2005-04-26 22:44:02 -07:00
kay.sievers@vrfy.org
7efa217db0 [PATCH] add NAME{ignore_remove} attribute
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.
2005-04-26 22:27:34 -07:00
kay.sievers@vrfy.org
d4a32aa2e4 [PATCH] remove historical SYSFS_attr="value" format
This is long ago replaced by the unified key attribute
format SYSFS{attr}="value".
2005-04-26 22:27:34 -07:00
kay.sievers@vrfy.org
2092fbcdeb [PATCH] support DRIVER as a rule key
Match with a rule against a device with a specific kernel driver.
2005-04-26 22:26:25 -07:00
kay.sievers@vrfy.org
6818c51d7a [PATCH] support SUBSYSTEM as a rule key
This should make it easier to catch e.g all block or net devices with
a single rule.
2005-04-26 22:25:38 -07:00
kay.sievers@vrfy.org
af4b05d491 [PATCH] make the udev object available to more processing stages
Remove the overwriting of main_argv[] hack and use the values
from the udev object.
  
Pass the udev object to call_foreach_file().
  
In the udevstart case, export SUBSYSTEM and UDEVSTART to the
environment.
2005-04-26 22:24:38 -07:00
greg@kroah.com
1ceba9360b [PATCH] sparse cleanups on the tree 2005-04-26 22:06:44 -07:00
kay.sievers@vrfy.org
3db7fa2702 [PATCH] fix udev segfaults with bad permissions file
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.
2005-04-26 21:37:01 -07:00
arun@codemovers.org
3e4414508b [PATCH] udev - read long lines from config files overflow fix
Hi Kay,

On 23:12 Sat 04 Sep     , Kay Sievers wrote:
> Cool, a real bug :)
> Thanks, for the patch. I think it would be better to skip lenghth exceeding
> lines instead of cutting it and continue. While looking at it I restructured
> the buffer reading logic a bit and fixed another stupid bug.
Thanks for the cleanup.

You may have overlooked the fix for udev_config.c(parsing udev.conf) in
your patch.  So, I've adapted the fixes you applied to namedev_parse.c
to this file also.

Also, while 'eating' the whitespace the 'count' doesn't get decremented.
This leads strncpy to copy the number of whitespace minus 1 characters
from the next line. Minus 1 because it copies '\n' from the current
line.

		while (isspace(bufline[0])) {
			bufline++;
+			count--;
		}
		.
		.
		.
		strncpy(line, bufline, count);

Included patch(against udev-030) contains the above fixes as well as
your fixes.


Signed-off-by: Arun Bhanu <arun@codemovers.org>
2005-04-26 21:37:00 -07:00
kay.sievers@vrfy.org
4a539daf1e [PATCH] dev_d.c file sorting and cleanup
On Thu, Mar 25, 2004 at 02:52:13AM +0100, Kay Sievers wrote:
> Please have look if it still works for you, I only did a very quick
> test.

Here is a unified version, with all the functions moved to udev_lib.c.
We have a generic function now, to call a given fnct(char *) for every
file ending with a specific suffix, sorted in lexical order. We use it
to execute the dev.d/ files and read our rules.d/ files. The binary
should be a bit smaller now.

I've also changed it, to not do the dev.d/ exec for net devices.
2005-04-26 21:35:12 -07:00
kay.sievers@vrfy.org
c81b35c08b [PATCH] replace fgets() with mmap() and introduce udev_lib.[hc]
Here we replace the various fgets() with a mmap() call for the config
file reading, due to the reported performance problems with klibc.

Thanks to Patrick's testing, it makes a very small, close to nothing
speed gain for libc users, but a 6 times speed increase for klibc users
with a 1000 line config file.

I've created a udev_lib.[hc] for this and also moved all the generic
stuff from udev.h in there and uninlined the functions.
2005-04-26 21:35:10 -07:00
greg@kroah.com
2731fd98c6 [PATCH] remove extra ; in namedev_parse.c
Thanks to Olaf Hering <olh@suse.de> for pointing this out.
2005-04-26 21:35:09 -07:00
kay.sievers@vrfy.org
e41016d354 [PATCH] allow to specify node permissions in the rule
This allows to set the permissions along with the rule.

This is not a general replacement for the permissions config, but it
may be easier sometimes for the user to specify the permissions along
with the rule, cause the permissions config file wants the final node
name to match, which seems sometimes a bit difficult to guess, if
format % chars are used in the NAME field.

Any value not given in the rule is still be read from the permissions
file or set to the default. This one will also work:

  BUS="usb", KERNEL="video*", NAME="my-%k", OWNER="$local"

A few words to man page are also added and add_perm_dev() is moved into
namedev_parse.c where it belongs to.
2005-04-26 21:35:09 -07:00
kay.sievers@vrfy.org
d00bd1724b [PATCH] overall trivial trivial cleanup
Here I try to make the style a bit more consistant in the different
files, so that new patches just copy the 'right' one :)

Some "magic" numbers are replaced and udevtest.c is catched up with udev.
2005-04-26 21:35:08 -07:00
kay.sievers@vrfy.org
bd5f8e7cd1 [PATCH] udev - fix debug info for multiple rule file config
On Sat, Feb 28, 2004 at 09:56:32PM +0100, Kay Sievers wrote:
> Andrey pointed out that we don't print the right filename in the debug
> output. Here is a fix for that. It applies on top of Andrey's symlink
> patch, cause we are touching the same part of the code.

The copy/paste devil catched me :)
Here is a fixed one.
2005-04-26 21:34:29 -07:00
kay.sievers@vrfy.org
c472e3c89b [PATCH] udev - safer string handling all over the place
On Tue, Feb 24, 2004 at 11:50:52PM +0100, Kay Sievers wrote:
> Here is the first step towards a safer string handling.
> More will follow, but for now only the easy ones :)
>
> Thanks to all who pointed this out. strncat() isn't a nice function. We
> all should remember that the destination string is not terminated if the
> given lenght is shorter than the strlen of the source string.
>
> And shame on the various implementers of strfieldcat() I found in the
> unapplied patches on this list, it's not really better than strncpy()
> and hides the real problem.

Hmm, bk didn't checked in one file, maybe I edited it again as root.
Nevermind, here is the more complete version.
2005-04-26 21:32:30 -07:00
kay.sievers@vrfy.org
e41245cb25 [PATCH] udev - allow all files in a directory as the config
I was on the train for 5 hours today and the TODO is almost empty :)
So, at least four people wanted this feature, then here is a actual
working patch.

We may specify now in udev.conf:

  udev_rules="/etc/udev/"

and udev will scan the whole directory for files ending with *.rules,
sort it in lexical order and create our rule list from all of the files.
A plain given file will still work and the same applies to the *.permissions.

I sort the files in our usual linked list, cause klibc has no scandir().
2005-04-26 21:32:30 -07:00
kay.sievers@vrfy.org
50e5de03d1 [PATCH] udev - create all partitions of blockdevice
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?
2005-04-26 21:32:28 -07:00
kay.sievers@vrfy.org
bb73864724 [PATCH] allow SYSFS{file}
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.
2005-04-26 21:32:28 -07:00
greg@kroah.com
274812b502 [PATCH] move get_pair to udev_config.c because udevinfo doesn't need all of namedev.o 2005-04-26 21:13:19 -07:00
greg@kroah.com
267f534d1c [PATCH] misc code cleanups. 2005-04-26 21:13:17 -07:00
hannal@us.ibm.com
eb7a964a7c [PATCH] small cut n paste error fix 2005-04-26 21:13:17 -07:00
kay.sievers@vrfy.org
54988802b7 [PATCH] add udev logging to info log
On Thu, Jan 15, 2004 at 05:14:16AM +0100, Kay Sievers wrote:
> On Wed, Jan 14, 2004 at 01:10:43PM -0800, Greg KH wrote:
> > On Wed, Jan 14, 2004 at 02:34:26PM -0600, Clay Haapala wrote:
> > > On Wed, 14 Jan 2004, Chris Friesen spake thusly:
> > > >
> > > > Maybe for ones with a matching rule, you could print something like:
> > > >
> > > >
> > > Is the act of printing/syslogging a rule in an of itself?
> >
> > No, as currently the only way stuff ends up in the syslog is if
> > DEBUG=true is used on the build line.
> >
> > But it's sounding like we might want to change that... :)
>
> How about this in the syslog after connect/disconnect?
>
>   Jan 15 05:07:45 pim udev[28007]: configured rule in '/etc/udev/udev.rules' at line 17 applied, 'video*' becomes 'video/webcam%n'
>   Jan 15 05:07:45 pim udev[28007]: creating device node '/udev/video/webcam0'
>   Jan 15 05:07:47 pim udev[28015]: removing device node '/udev/video/webcam0'

Here is a slightly better version. I've created a logging.h file and
moved the debug macros from udev.h in there.

If you type:

  'make'            - you will get a binary that prints one or two lines to syslog
                      if a device node is created or deleted

  'make LOG=false'  - you get a binary that prints asolutely nothing

  'make DEBUG=true' - the same as today, it will print all debug lines
2005-04-26 21:13:17 -07:00
greg@kroah.com
851cd18d81 [PATCH] Add some helpful messages if the user uses the older config file format
Also fail a rule that we can not parse, as we can easily create incorrect rules
if we do not do this.
2005-04-26 21:13:15 -07:00
kay.sievers@vrfy.org
ac28b86d63 [PATCH] udev - drop all methods :)
> Hi,
> as promised yesterday, here is a patch that drops the explicit methods
> given in the udev config and implement only one type of rule.
>
> A rule now consists only of a number of keys to match. All known keys
> are valid in any combination. The former configs should work with a few
> changes:
>
>   o the "<METHOD>, " at the beginning of the line should be removed
>
>   o the result of the externel program is matched with RESULT= instead if ID=
>     the PROGRAM= key is only valid if the program exits with zero
>     (just exit with nozero in a script if the rule should not match)
>
>   o rules are processed in order they appear in the file, no priority
>
>   o if NAME="" is given, udev is instructed to ignore this device,
>     no node will be created
>
>
>   EXAMPLE:
>
>   # combined BUS, SYSFS and KERNEL
>   BUS="usb", KERNEL="video*", SYSFS_model="Creative Labs WebCam*", NAME="test/webcam%n"
>
>   # exec script only for the first ide drive (hda), all other will be skipped
>   BUS="ide", KERNEL="hda*", PROGRAM="/home/kay/src/udev.kay/extras/ide-devfs.sh %k %b %n", RESULT="hd*", NAME="%1c", SYMLINK="%2c %3c"
>
>
> The udev-test.pl and test.block works fine here.
> Please adapt your config and give it a try.
>


Here is a slightly better version of the patch.
After a conversation with Patrick, we are now able to execute the PROGRAM
and also match in all following rules with the RESULT value from this exec.


EXAMPLE:
  We have 7 rules with RESULT and 2 with PROGRAM.
  Only the 5th rule matches with the callout result from the exec in the 4th rule.

RULES:
  PROGRAM="/bin/echo abc", RESULT="no_match", NAME="web-no-2"
  KERNEL="video*", RESULT="123", NAME="web-no-3"
  KERNEL="video*", RESULT="123", NAME="web-no-4"
  PROGRAM="/bin/echo 123", RESULT="no_match", NAME="web-no-5"
  KERNEL="video*", RESULT="123", NAME="web-yes"


RESULT:
  Jan 11 23:36:52 pim udev[26050]: namedev_name_device: process rule
  Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check PROGRAM
  Jan 11 23:36:52 pim udev[26050]: execute_program: executing '/bin/echo abc'
  Jan 11 23:36:52 pim udev[26050]: execute_program: result is 'abc'
  Jan 11 23:36:52 pim udev[26050]: namedev_name_device: PROGRAM returned successful
  Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check for RESULT dev->result='no_match', udev->program_result='abc'
  Jan 11 23:36:52 pim udev[26050]: namedev_name_device: RESULT is not matching
  Jan 11 23:36:52 pim udev[26050]: namedev_name_device: process rule
  Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check for KERNEL dev->kernel='video*' class_dev->name='video0'
  Jan 11 23:36:52 pim udev[26050]: namedev_name_device: KERNEL matches
  Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check for RESULT dev->result='123', udev->program_result='abc'
  Jan 11 23:36:52 pim udev[26050]: namedev_name_device: RESULT is not matching
  Jan 11 23:36:52 pim udev[26050]: namedev_name_device: process rule
  Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check for KERNEL dev->kernel='video*' class_dev->name='video0'
  Jan 11 23:36:52 pim udev[26050]: namedev_name_device: KERNEL matches
  Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check for RESULT dev->result='123', udev->program_result='abc'
  Jan 11 23:36:52 pim udev[26050]: namedev_name_device: RESULT is not matching
  Jan 11 23:36:52 pim udev[26050]: namedev_name_device: process rule
  Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check PROGRAM
  Jan 11 23:36:52 pim udev[26050]: execute_program: executing '/bin/echo 123'
  Jan 11 23:36:52 pim udev[26050]: execute_program: result is '123'
  Jan 11 23:36:52 pim udev[26050]: namedev_name_device: PROGRAM returned successful
  Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check for RESULT dev->result='no_match', udev->program_result='123'
  Jan 11 23:36:52 pim udev[26050]: namedev_name_device: RESULT is not matching
  Jan 11 23:36:52 pim udev[26050]: namedev_name_device: process rule
  Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check for KERNEL dev->kernel='video*' class_dev->name='video0'
  Jan 11 23:36:52 pim udev[26050]: namedev_name_device: KERNEL matches
  Jan 11 23:36:52 pim udev[26050]: namedev_name_device: check for RESULT dev->result='123', udev->program_result='123'
  Jan 11 23:36:52 pim udev[26050]: namedev_name_device: RESULT matches
  Jan 11 23:36:52 pim udev[26050]: namedev_name_device: found matching rule, 'video*' becomes ''
  Jan 11 23:36:52 pim udev[26050]: namedev_name_device: name, 'web-yes' is going to have owner='', group='', mode = 0600
2005-04-26 21:13:15 -07:00
christophe@saout.de
f1db055ab2 [PATCH] add IGNORE rule type
On Wed, Dec 31, 2003 at 11:24:53AM -0800, Greg KH wrote:

> > There should be a possibility to tell udev not to create a device node.
> >
> > device-mapper: Usually set up by libdevmapper (or EVMS tools) which
> > creates the device node on its own under /dev/mapper/<name>.
> >
> > With udev a second device is created named /dev/dm-<minor> which is not
> > really needed.
>
> Good point.  Ok, I'll agree with you.  Care to make up a patch for this
> kind of feature?

Yes, I can try.

There was no way to tell not to do anything so I created one. Errors
are signalled via negative return values, so I thought that a positive,
non-zero one could mean to ignore the device. I don't like it but
perhaps you have a better solution.
2005-04-26 21:13:14 -07:00
christophe@saout.de
c53735efc9 [PATCH] small cleanup
This one is nothing important, just add some quotes to be more consistent
with the rest and make sure that the return value is positive (since the
error return values are negative). Hmm?
2005-04-26 21:13:14 -07:00
greg@kroah.com
843d1a84b9 [PATCH] replace list_for_each with list_for_each_entry, saving a few lines of code. 2005-04-26 21:13:14 -07:00
kay.sievers@vrfy.org
13148857cb [PATCH] cleanup namedev_parse debug text
I missed a few spaces with my recent change.
2005-04-26 21:13:12 -07:00
kay.sievers@vrfy.org
e15b5ed5de [PATCH] small trivial cleanup of latest changes
here is a patch for a typo in the man page, a whitespace cleanup
and a replace for the magic hex ASCII in char operations.
2005-04-26 21:13:11 -07:00
greg@kroah.com
2ae1a0c6f3 [PATCH] Don't require the BUS value for the LABEL rule. 2005-04-26 21:13:11 -07:00
greg@kroah.com
47b3f983da [PATCH] Don't require the BUS value for the CALLOUT rule. 2005-04-26 21:13:11 -07:00
greg@kroah.com
bc64a25fd2 [PATCH] check for empty line a bit better in the parser.
Thanks to Mitch <mitch@0bits.com> for pointing this out.
2005-04-26 21:13:10 -07:00
greg@kroah.com
a8b01705c6 [PATCH] add ability to have up to 5 SYSFS_ file/value pairs for the LABEL rule. 2005-04-26 21:13:10 -07:00
Roman.Kagan@itep.ru
093bf8f4d2 [PATCH] fix comment and whitespace handling in config files.
This chunk broke parsing of blank lines and comments with blanks before
'#'.  Please revert it with the patch below.

  Roman.
2005-04-26 21:13:09 -07:00
kay.sievers@vrfy.org
4868e8fba7 [PATCH] trivial cleanup parser changes
o use defines in debug strings
  o replace my 'xxx' debug :)
  o shorten line in man page example to not to exceed 80 chars when printed
2005-04-26 21:13:09 -07:00