2003-12-03 09:38:30 +07:00
|
|
|
/*
|
2005-03-13 04:36:32 +07:00
|
|
|
* udev_rules_parse.c
|
2003-12-03 09:38:30 +07:00
|
|
|
*
|
|
|
|
* Userspace devfs
|
|
|
|
*
|
2004-01-27 10:21:58 +07:00
|
|
|
* Copyright (C) 2003,2004 Greg Kroah-Hartman <greg@kroah.com>
|
2005-02-14 12:03:06 +07:00
|
|
|
* Copyright (C) 2003-2005 Kay Sievers <kay.sievers@vrfy.org>
|
2003-12-03 09:38:30 +07:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation version 2 of the License.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <unistd.h>
|
2004-02-24 10:31:14 +07:00
|
|
|
#include <sys/stat.h>
|
2003-12-03 09:38:30 +07:00
|
|
|
#include <errno.h>
|
|
|
|
|
2005-03-07 10:29:43 +07:00
|
|
|
#include "udev_libc_wrapper.h"
|
2003-12-03 09:38:30 +07:00
|
|
|
#include "udev.h"
|
2004-11-25 08:44:38 +07:00
|
|
|
#include "udev_utils.h"
|
[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
2004-01-16 12:53:20 +07:00
|
|
|
#include "logging.h"
|
2005-03-13 04:36:32 +07:00
|
|
|
#include "udev_rules.h"
|
2003-12-03 09:38:30 +07:00
|
|
|
|
2005-03-13 04:36:32 +07:00
|
|
|
LIST_HEAD(udev_rule_list);
|
2004-03-11 13:35:37 +07:00
|
|
|
|
2005-03-13 13:14:49 +07:00
|
|
|
static int add_config_dev(struct udev_rule *rule)
|
2003-12-23 13:31:35 +07:00
|
|
|
{
|
2005-03-13 04:36:32 +07:00
|
|
|
struct udev_rule *tmp_rule;
|
2003-12-23 13:31:35 +07:00
|
|
|
|
2005-03-13 04:36:32 +07:00
|
|
|
tmp_rule = malloc(sizeof(*tmp_rule));
|
|
|
|
if (tmp_rule == NULL)
|
2003-12-23 13:31:35 +07:00
|
|
|
return -ENOMEM;
|
2005-03-13 13:14:49 +07:00
|
|
|
memcpy(tmp_rule, rule, sizeof(struct udev_rule));
|
2005-03-13 04:36:32 +07:00
|
|
|
list_add_tail(&tmp_rule->node, &udev_rule_list);
|
|
|
|
|
|
|
|
dbg("name='%s', symlink='%s', bus='%s', id='%s', "
|
|
|
|
"sysfs_file[0]='%s', sysfs_value[0]='%s', "
|
2005-03-13 13:14:49 +07:00
|
|
|
"kernel='%s', program='%s', result='%s', "
|
|
|
|
"owner='%s', group='%s', mode=%#o, "
|
|
|
|
"all_partions=%u, ignore_remove=%u, ignore_device=%u, last_rule=%u",
|
2005-03-13 04:36:32 +07:00
|
|
|
rule->name, rule->symlink, rule->bus, rule->id,
|
|
|
|
rule->sysfs_pair[0].file, rule->sysfs_pair[0].value,
|
2005-03-13 13:14:49 +07:00
|
|
|
rule->kernel, rule->program, rule->result, rule->owner, rule->group, rule->mode,
|
|
|
|
rule->partitions, rule->ignore_remove, rule->ignore_device, rule->last_rule);
|
2003-12-03 09:38:30 +07:00
|
|
|
|
2005-03-13 13:14:49 +07:00
|
|
|
return 0;
|
2003-12-03 09:38:30 +07:00
|
|
|
}
|
2003-12-04 09:33:58 +07:00
|
|
|
|
2005-03-13 11:46:31 +07:00
|
|
|
static int get_key(char **line, char **key, enum key_operation *operation, char **value)
|
|
|
|
{
|
|
|
|
char *linepos;
|
|
|
|
char *temp;
|
|
|
|
|
|
|
|
linepos = *line;
|
|
|
|
if (!linepos)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* skip whitespace */
|
|
|
|
while (isspace(linepos[0]) || linepos[0] == ',')
|
|
|
|
linepos++;
|
|
|
|
|
|
|
|
/* get the key */
|
|
|
|
*key = linepos;
|
|
|
|
while (1) {
|
|
|
|
linepos++;
|
|
|
|
if (linepos[0] == '\0')
|
|
|
|
return -1;
|
|
|
|
if (isspace(linepos[0]))
|
|
|
|
break;
|
|
|
|
if (linepos[0] == '=')
|
|
|
|
break;
|
|
|
|
if (linepos[0] == '+')
|
|
|
|
break;
|
|
|
|
if (linepos[0] == '!')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* remember end of key */
|
|
|
|
temp = linepos;
|
|
|
|
|
|
|
|
/* skip whitespace after key */
|
|
|
|
while (isspace(linepos[0]))
|
|
|
|
linepos++;
|
|
|
|
|
|
|
|
/* get operation type */
|
|
|
|
if (linepos[0] == '=' && linepos[1] == '=') {
|
|
|
|
*operation = KEY_OP_MATCH;
|
|
|
|
linepos += 2;
|
|
|
|
dbg("operator=match");
|
|
|
|
} else if (linepos[0] == '!' && linepos[1] == '=') {
|
|
|
|
*operation = KEY_OP_NOMATCH;
|
|
|
|
linepos += 2;
|
|
|
|
dbg("operator=nomatch");
|
|
|
|
} else if (linepos[0] == '+' && linepos[1] == '=') {
|
|
|
|
*operation = KEY_OP_ADD;
|
|
|
|
linepos += 2;
|
|
|
|
dbg("operator=add");
|
|
|
|
} else if (linepos[0] == '=') {
|
|
|
|
*operation = KEY_OP_ASSIGN;
|
|
|
|
linepos++;
|
|
|
|
dbg("operator=assign");
|
|
|
|
} else
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* terminate key */
|
|
|
|
temp[0] = '\0';
|
|
|
|
dbg("key='%s'", *key);
|
|
|
|
|
|
|
|
/* skip whitespace after operator */
|
|
|
|
while (isspace(linepos[0]))
|
|
|
|
linepos++;
|
|
|
|
|
|
|
|
/* get the value*/
|
|
|
|
if (linepos[0] == '"')
|
|
|
|
linepos++;
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
*value = linepos;
|
|
|
|
|
|
|
|
temp = strchr(linepos, '"');
|
|
|
|
if (!temp)
|
|
|
|
return -1;
|
|
|
|
temp[0] = '\0';
|
|
|
|
temp++;
|
|
|
|
dbg("value='%s'", *value);
|
|
|
|
|
|
|
|
/* move line to next key */
|
|
|
|
*line = temp;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-11-13 18:50:44 +07:00
|
|
|
/* extract possible KEY{attr} */
|
2004-02-17 12:39:40 +07:00
|
|
|
static char *get_key_attribute(char *str)
|
|
|
|
{
|
|
|
|
char *pos;
|
|
|
|
char *attr;
|
|
|
|
|
|
|
|
attr = strchr(str, '{');
|
|
|
|
if (attr != NULL) {
|
|
|
|
attr++;
|
|
|
|
pos = strchr(attr, '}');
|
|
|
|
if (pos == NULL) {
|
|
|
|
dbg("missing closing brace for format");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
pos[0] = '\0';
|
|
|
|
dbg("attribute='%s'", attr);
|
|
|
|
return attr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-03-13 04:36:32 +07:00
|
|
|
static int rules_parse(struct udevice *udev, const char *filename)
|
2003-12-03 09:38:30 +07:00
|
|
|
{
|
2004-09-11 10:54:04 +07:00
|
|
|
char line[LINE_SIZE];
|
|
|
|
char *bufline;
|
2003-12-03 09:38:30 +07:00
|
|
|
int lineno;
|
2005-03-13 11:46:31 +07:00
|
|
|
char *linepos;
|
2004-02-17 12:39:40 +07:00
|
|
|
char *attr;
|
2004-03-23 13:22:20 +07:00
|
|
|
char *buf;
|
|
|
|
size_t bufsize;
|
|
|
|
size_t cur;
|
|
|
|
size_t count;
|
[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
2004-01-13 12:39:05 +07:00
|
|
|
int program_given = 0;
|
2004-09-11 10:54:04 +07:00
|
|
|
int valid;
|
2003-12-03 09:38:30 +07:00
|
|
|
int retval = 0;
|
2005-03-13 04:36:32 +07:00
|
|
|
struct udev_rule rule;
|
2003-12-03 09:38:30 +07:00
|
|
|
|
2005-03-13 11:46:31 +07:00
|
|
|
if (file_map(filename, &buf, &bufsize) != 0) {
|
2004-03-23 13:22:20 +07:00
|
|
|
dbg("can't open '%s' as rules file", filename);
|
|
|
|
return -1;
|
2003-12-03 09:38:30 +07:00
|
|
|
}
|
2005-03-13 11:46:31 +07:00
|
|
|
dbg("reading '%s' as rules file", filename);
|
2003-12-03 09:38:30 +07:00
|
|
|
|
|
|
|
/* loop through the whole file */
|
2004-03-23 13:22:20 +07:00
|
|
|
cur = 0;
|
2003-12-03 09:38:30 +07:00
|
|
|
lineno = 0;
|
2004-09-11 10:54:04 +07:00
|
|
|
while (cur < bufsize) {
|
2005-02-05 08:38:56 +07:00
|
|
|
unsigned int i, j;
|
2004-12-20 13:38:33 +07:00
|
|
|
|
2004-03-23 13:22:20 +07:00
|
|
|
count = buf_get_line(buf, bufsize, cur);
|
2004-09-11 10:54:04 +07:00
|
|
|
bufline = &buf[cur];
|
2004-03-23 13:22:20 +07:00
|
|
|
cur += count+1;
|
2004-09-11 10:54:04 +07:00
|
|
|
lineno++;
|
2003-12-03 09:38:30 +07:00
|
|
|
|
2005-03-07 10:29:43 +07:00
|
|
|
if (count >= sizeof(line)) {
|
2004-12-20 13:38:33 +07:00
|
|
|
info("line too long, rule skipped %s, line %d", filename, lineno);
|
2004-09-11 10:54:04 +07:00
|
|
|
continue;
|
|
|
|
}
|
2003-12-18 09:24:05 +07:00
|
|
|
|
2004-09-11 10:54:04 +07:00
|
|
|
/* eat the whitespace */
|
2004-09-15 07:45:48 +07:00
|
|
|
while ((count > 0) && isspace(bufline[0])) {
|
2004-09-11 10:54:04 +07:00
|
|
|
bufline++;
|
|
|
|
count--;
|
|
|
|
}
|
2004-09-15 07:45:48 +07:00
|
|
|
if (count == 0)
|
|
|
|
continue;
|
2004-09-11 10:54:04 +07:00
|
|
|
|
2003-12-03 09:38:30 +07:00
|
|
|
/* see if this is a comment */
|
2004-09-11 10:54:04 +07:00
|
|
|
if (bufline[0] == COMMENT_CHARACTER)
|
2003-12-03 09:38:30 +07:00
|
|
|
continue;
|
|
|
|
|
2004-12-20 13:38:33 +07:00
|
|
|
/* skip backslash and newline from multi line rules */
|
|
|
|
for (i = j = 0; i < count; i++) {
|
2005-02-26 08:52:04 +07:00
|
|
|
if (bufline[i] == '\\' && bufline[i+1] == '\n')
|
2004-12-20 13:38:33 +07:00
|
|
|
continue;
|
|
|
|
|
|
|
|
line[j++] = bufline[i];
|
|
|
|
}
|
|
|
|
line[j] = '\0';
|
2005-03-13 04:36:32 +07:00
|
|
|
dbg("read '%s'", line);
|
2003-12-03 09:38:30 +07:00
|
|
|
|
2003-12-17 14:36:19 +07:00
|
|
|
/* get all known keys */
|
2005-03-13 04:36:32 +07:00
|
|
|
memset(&rule, 0x00, sizeof(struct udev_rule));
|
2005-03-13 11:46:31 +07:00
|
|
|
linepos = line;
|
2004-09-11 10:54:04 +07:00
|
|
|
valid = 0;
|
|
|
|
|
2003-12-17 14:36:19 +07:00
|
|
|
while (1) {
|
2005-03-13 11:46:31 +07:00
|
|
|
char *key;
|
|
|
|
char *value;
|
|
|
|
enum key_operation operation = KEY_OP_UNKNOWN;
|
|
|
|
|
|
|
|
retval = get_key(&linepos, &key, &operation, &value);
|
2003-12-03 09:38:30 +07:00
|
|
|
if (retval)
|
|
|
|
break;
|
2003-12-08 00:12:07 +07:00
|
|
|
|
2005-03-13 11:46:31 +07:00
|
|
|
if (strcasecmp(key, KEY_KERNEL) == 0) {
|
|
|
|
strlcpy(rule.kernel, value, sizeof(rule.kernel));
|
|
|
|
rule.kernel_operation = operation;
|
2005-02-21 20:01:23 +07:00
|
|
|
valid = 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2005-03-13 11:46:31 +07:00
|
|
|
if (strcasecmp(key, KEY_SUBSYSTEM) == 0) {
|
|
|
|
strlcpy(rule.subsystem, value, sizeof(rule.subsystem));
|
|
|
|
rule.subsystem_operation = operation;
|
2005-02-21 20:01:23 +07:00
|
|
|
valid = 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2005-03-13 11:46:31 +07:00
|
|
|
if (strcasecmp(key, KEY_BUS) == 0) {
|
|
|
|
strlcpy(rule.bus, value, sizeof(rule.bus));
|
|
|
|
rule.bus_operation = operation;
|
2004-09-11 10:54:04 +07:00
|
|
|
valid = 1;
|
2003-12-17 14:36:19 +07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2005-03-13 11:46:31 +07:00
|
|
|
if (strcasecmp(key, KEY_ID) == 0) {
|
|
|
|
strlcpy(rule.id, value, sizeof(rule.id));
|
|
|
|
rule.id_operation = operation;
|
2004-09-11 10:54:04 +07:00
|
|
|
valid = 1;
|
2003-12-17 14:36:19 +07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2005-03-13 11:46:31 +07:00
|
|
|
if (strncasecmp(key, KEY_SYSFS, sizeof(KEY_SYSFS)-1) == 0) {
|
2005-03-13 04:36:32 +07:00
|
|
|
struct sysfs_pair *pair = &rule.sysfs_pair[0];
|
2003-12-23 13:31:35 +07:00
|
|
|
int sysfs_pair_num = 0;
|
|
|
|
|
|
|
|
/* find first unused pair */
|
|
|
|
while (pair->file[0] != '\0') {
|
|
|
|
++sysfs_pair_num;
|
|
|
|
if (sysfs_pair_num >= MAX_SYSFS_PAIRS) {
|
|
|
|
pair = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
++pair;
|
|
|
|
}
|
|
|
|
if (pair) {
|
2005-03-13 11:46:31 +07:00
|
|
|
attr = get_key_attribute(key + sizeof(KEY_SYSFS)-1);
|
2004-02-17 12:39:40 +07:00
|
|
|
if (attr == NULL) {
|
2005-03-13 11:46:31 +07:00
|
|
|
dbg("error parsing " KEY_SYSFS " attribute");
|
2004-02-17 12:39:40 +07:00
|
|
|
continue;
|
|
|
|
}
|
2005-03-07 10:29:43 +07:00
|
|
|
strlcpy(pair->file, attr, sizeof(pair->file));
|
2005-03-13 11:46:31 +07:00
|
|
|
strlcpy(pair->value, value, sizeof(pair->value));
|
|
|
|
pair->operation = operation;
|
2004-09-11 10:54:04 +07:00
|
|
|
valid = 1;
|
2003-12-23 13:31:35 +07:00
|
|
|
}
|
2003-12-17 14:36:19 +07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2005-03-13 11:46:31 +07:00
|
|
|
if (strcasecmp(key, KEY_DRIVER) == 0) {
|
|
|
|
strlcpy(rule.driver, value, sizeof(rule.driver));
|
|
|
|
rule.driver_operation = operation;
|
2004-11-13 11:21:12 +07:00
|
|
|
valid = 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2005-03-13 11:46:31 +07:00
|
|
|
if (strcasecmp(key, KEY_RESULT) == 0) {
|
|
|
|
strlcpy(rule.result, value, sizeof(rule.result));
|
|
|
|
rule.result_operation = operation;
|
2004-09-11 10:54:04 +07:00
|
|
|
valid = 1;
|
[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
2004-01-13 12:39:05 +07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2005-03-13 11:46:31 +07:00
|
|
|
if (strcasecmp(key, KEY_PROGRAM) == 0) {
|
|
|
|
strlcpy(rule.program, value, sizeof(rule.program));
|
|
|
|
rule.program_operation = operation;
|
|
|
|
program_given = 1;
|
2004-09-11 10:54:04 +07:00
|
|
|
valid = 1;
|
2003-12-17 14:36:19 +07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2005-03-13 11:46:31 +07:00
|
|
|
if (strncasecmp(key, KEY_NAME, sizeof(KEY_NAME)-1) == 0) {
|
|
|
|
attr = get_key_attribute(key + sizeof(KEY_NAME)-1);
|
2005-02-14 12:03:06 +07:00
|
|
|
/* FIXME: remove old style options and make OPTIONS= mandatory */
|
2004-11-13 20:43:24 +07:00
|
|
|
if (attr != NULL) {
|
2005-03-05 03:00:43 +07:00
|
|
|
if (strstr(attr, OPTION_PARTITIONS) != NULL) {
|
2005-03-13 04:36:32 +07:00
|
|
|
dbg("creation of partition nodes requested");
|
|
|
|
rule.partitions = DEFAULT_PARTITIONS_COUNT;
|
2004-02-17 12:44:28 +07:00
|
|
|
}
|
2005-03-05 03:00:43 +07:00
|
|
|
if (strstr(attr, OPTION_IGNORE_REMOVE) != NULL) {
|
2005-03-13 04:36:32 +07:00
|
|
|
dbg("remove event should be ignored");
|
|
|
|
rule.ignore_remove = 1;
|
2004-11-13 20:43:24 +07:00
|
|
|
}
|
|
|
|
}
|
2005-03-13 11:46:31 +07:00
|
|
|
if (value[0] != '\0')
|
|
|
|
strlcpy(rule.name, value, sizeof(rule.name));
|
2005-02-21 20:05:52 +07:00
|
|
|
else
|
2005-03-13 04:36:32 +07:00
|
|
|
rule.ignore_device = 1;
|
2004-09-11 10:54:04 +07:00
|
|
|
valid = 1;
|
2003-12-17 14:36:19 +07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2005-03-13 11:46:31 +07:00
|
|
|
if (strcasecmp(key, KEY_SYMLINK) == 0) {
|
|
|
|
strlcpy(rule.symlink, value, sizeof(rule.symlink));
|
2004-09-11 10:54:04 +07:00
|
|
|
valid = 1;
|
2003-12-17 14:36:19 +07:00
|
|
|
continue;
|
|
|
|
}
|
2003-12-08 00:12:07 +07:00
|
|
|
|
2005-03-13 11:46:31 +07:00
|
|
|
if (strcasecmp(key, KEY_OWNER) == 0) {
|
|
|
|
strlcpy(rule.owner, value, sizeof(rule.owner));
|
2004-09-11 10:54:04 +07:00
|
|
|
valid = 1;
|
2004-03-11 13:35:37 +07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2005-03-13 11:46:31 +07:00
|
|
|
if (strcasecmp(key, KEY_GROUP) == 0) {
|
|
|
|
strlcpy(rule.group, value, sizeof(rule.group));
|
2004-09-11 10:54:04 +07:00
|
|
|
valid = 1;
|
2004-03-11 13:35:37 +07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2005-03-13 11:46:31 +07:00
|
|
|
if (strcasecmp(key, KEY_MODE) == 0) {
|
|
|
|
rule.mode = strtol(value, NULL, 8);
|
2004-09-11 10:54:04 +07:00
|
|
|
valid = 1;
|
2004-03-11 13:35:37 +07:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2005-03-13 11:46:31 +07:00
|
|
|
if (strcasecmp(key, KEY_OPTIONS) == 0) {
|
|
|
|
if (strstr(value, OPTION_LAST_RULE) != NULL) {
|
2005-03-13 04:55:08 +07:00
|
|
|
dbg("last rule to be applied");
|
|
|
|
rule.last_rule = 1;
|
|
|
|
}
|
2005-03-13 11:46:31 +07:00
|
|
|
if (strstr(value, OPTION_IGNORE_DEVICE) != NULL) {
|
2005-03-13 04:36:32 +07:00
|
|
|
dbg("device should be ignored");
|
|
|
|
rule.ignore_device = 1;
|
2005-02-14 12:03:06 +07:00
|
|
|
}
|
2005-03-13 11:46:31 +07:00
|
|
|
if (strstr(value, OPTION_IGNORE_REMOVE) != NULL) {
|
2005-03-13 04:36:32 +07:00
|
|
|
dbg("remove event should be ignored");
|
|
|
|
rule.ignore_remove = 1;
|
2005-02-14 12:03:06 +07:00
|
|
|
}
|
2005-03-13 11:46:31 +07:00
|
|
|
if (strstr(value, OPTION_PARTITIONS) != NULL) {
|
2005-03-13 04:36:32 +07:00
|
|
|
dbg("creation of partition nodes requested");
|
|
|
|
rule.partitions = DEFAULT_PARTITIONS_COUNT;
|
2005-02-14 12:03:06 +07:00
|
|
|
}
|
|
|
|
valid = 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2005-03-13 11:46:31 +07:00
|
|
|
dbg("unknown key '%s'", key);
|
2004-01-13 14:08:43 +07:00
|
|
|
goto error;
|
2003-12-17 14:36:19 +07:00
|
|
|
}
|
|
|
|
|
2004-09-11 10:54:04 +07:00
|
|
|
/* skip line if not any valid key was found */
|
|
|
|
if (!valid)
|
|
|
|
goto error;
|
|
|
|
|
2004-03-11 13:35:37 +07:00
|
|
|
/* simple plausibility checks for given keys */
|
2005-03-13 04:36:32 +07:00
|
|
|
if ((rule.sysfs_pair[0].file[0] == '\0') ^
|
|
|
|
(rule.sysfs_pair[0].value[0] == '\0')) {
|
2005-03-13 11:46:31 +07:00
|
|
|
info("inconsistency in " KEY_SYSFS " key");
|
[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
2004-01-13 12:39:05 +07:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2005-03-13 04:36:32 +07:00
|
|
|
if ((rule.result[0] != '\0') && (program_given == 0)) {
|
2005-03-13 11:46:31 +07:00
|
|
|
info(KEY_RESULT " is only useful when "
|
|
|
|
KEY_PROGRAM " is called in any rule before");
|
2003-12-17 14:36:19 +07:00
|
|
|
goto error;
|
2003-12-03 09:38:30 +07:00
|
|
|
}
|
|
|
|
|
2005-03-13 04:36:32 +07:00
|
|
|
rule.config_line = lineno;
|
|
|
|
strlcpy(rule.config_file, filename, sizeof(rule.config_file));
|
|
|
|
retval = add_config_dev(&rule);
|
2003-12-03 09:38:30 +07:00
|
|
|
if (retval) {
|
|
|
|
dbg("add_config_dev returned with error %d", retval);
|
2003-12-17 14:36:19 +07:00
|
|
|
continue;
|
[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
2004-01-13 12:39:05 +07:00
|
|
|
error:
|
2004-09-11 10:54:04 +07:00
|
|
|
info("parse error %s, line %d:%d, rule skipped",
|
2005-03-13 11:46:31 +07:00
|
|
|
filename, lineno, (int) (linepos - line));
|
2003-12-03 09:38:30 +07:00
|
|
|
}
|
|
|
|
}
|
2004-03-23 13:22:20 +07:00
|
|
|
|
|
|
|
file_unmap(buf, bufsize);
|
2003-12-03 09:38:30 +07:00
|
|
|
return retval;
|
2003-12-17 14:36:19 +07:00
|
|
|
}
|
2003-12-03 09:38:30 +07:00
|
|
|
|
2005-03-13 04:36:32 +07:00
|
|
|
int udev_rules_init(void)
|
2003-12-03 09:38:30 +07:00
|
|
|
{
|
2004-12-18 17:34:17 +07:00
|
|
|
struct stat stats;
|
|
|
|
int retval;
|
2003-12-03 09:38:30 +07:00
|
|
|
|
2004-12-18 17:34:17 +07:00
|
|
|
if (stat(udev_rules_filename, &stats) != 0)
|
2004-03-23 13:22:20 +07:00
|
|
|
return -1;
|
2003-12-03 09:38:30 +07:00
|
|
|
|
2004-02-24 10:31:14 +07:00
|
|
|
if ((stats.st_mode & S_IFMT) != S_IFDIR)
|
2005-03-13 04:36:32 +07:00
|
|
|
retval = rules_parse(NULL, udev_rules_filename);
|
2004-03-27 16:21:46 +07:00
|
|
|
else
|
2005-03-13 04:36:32 +07:00
|
|
|
retval = call_foreach_file(rules_parse, NULL, udev_rules_filename, RULEFILE_SUFFIX);
|
2004-02-24 10:31:14 +07:00
|
|
|
|
2004-12-18 17:34:17 +07:00
|
|
|
return retval;
|
2004-02-24 10:31:14 +07:00
|
|
|
}
|
2005-02-09 14:43:18 +07:00
|
|
|
|
2005-03-13 04:36:32 +07:00
|
|
|
void udev_rules_close(void)
|
2005-02-09 14:43:18 +07:00
|
|
|
{
|
2005-03-13 04:36:32 +07:00
|
|
|
struct udev_rule *rule;
|
|
|
|
struct udev_rule *temp_rule;
|
2005-02-09 14:43:18 +07:00
|
|
|
|
2005-03-13 04:36:32 +07:00
|
|
|
list_for_each_entry_safe(rule, temp_rule, &udev_rule_list, node) {
|
|
|
|
list_del(&rule->node);
|
|
|
|
free(rule);
|
2005-02-09 14:43:18 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|