OPTFLAGS := $(call cc-supports, -Os, -O2)
HEADERS = \
- udev.h \
- udev_utils.h \
- udev_rules.h \
- udev_version.h \
- udev_db.h \
- udev_sysfs.h \
- logging.h \
- udev_libc_wrapper.h \
- udev_selinux.h \
+ udev.h \
+ udev_utils.h \
+ udev_rules.h \
+ udev_version.h \
+ udev_db.h \
+ udev_sysfs.h \
+ logging.h \
+ udev_libc_wrapper.h \
+ udev_selinux.h \
list.h
SYSFS_OBJS = \
- libsysfs/sysfs_class.o \
- libsysfs/sysfs_device.o \
- libsysfs/sysfs_dir.o \
- libsysfs/sysfs_driver.o \
- libsysfs/sysfs_utils.o \
+ libsysfs/sysfs_class.o \
+ libsysfs/sysfs_device.o \
+ libsysfs/sysfs_dir.o \
+ libsysfs/sysfs_driver.o \
+ libsysfs/sysfs_utils.o \
libsysfs/dlist.o
UDEV_OBJS = \
- udev_utils.o \
- udev_config.o \
- udev_add.o \
- udev_remove.o \
- udev_sysfs.o \
- udev_db.o \
- udev_rules.o \
- udev_rules_parse.o \
+ udev_utils.o \
+ udev_event.o \
+ udev_device.o \
+ udev_config.o \
+ udev_add.o \
+ udev_remove.o \
+ udev_sysfs.o \
+ udev_db.o \
+ udev_rules.o \
+ udev_rules_parse.o \
udev_libc_wrapper.o
OBJS = \
SYSFS = $(PWD)/libsysfs/sysfs.a
-CFLAGS += -I$(PWD)/libsysfs/sysfs \
+CFLAGS += -I$(PWD)/libsysfs/sysfs \
-I$(PWD)/libsysfs
ifeq ($(strip $(USE_LOG)),true)
INSTALL_DATA = ${INSTALL} -m 644
INSTALL_SCRIPT = ${INSTALL_PROGRAM}
-override CFLAGS+=-D_FILE_OFFSET_BITS=64
+CFLAGS+=-D_FILE_OFFSET_BITS=64
OBJS = $(PROG).o $(VOLUME_ID_OBJS) ../../udev.a ../../libsysfs/sysfs.a
HEADERS =
/*
* udev.c
*
- * Userspace devfs
- *
- * Copyright (C) 2003,2004 Greg Kroah-Hartman <greg@kroah.com>
- * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
+ * Copyright (C) 2003-2004 Greg Kroah-Hartman <greg@kroah.com>
+ * Copyright (C) 2004-2005 Kay Sievers <kay.sievers@vrfy.org>
*
* 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
{
struct udevice udev;
struct udev_rules rules;
- char path[PATH_SIZE];
- const char *error;
const char *action;
const char *devpath;
const char *subsystem;
udev_init_device(&udev, devpath, subsystem, action);
udev_rules_init(&rules, 0);
- if (udev.type == DEV_BLOCK || udev.type == DEV_CLASS || udev.type == DEV_NET) {
- /* handle device node */
- if (strcmp(action, "add") == 0) {
- struct sysfs_class_device *class_dev;
-
- /* wait for sysfs of /sys/class /sys/block */
- dbg("node add");
- snprintf(path, sizeof(path), "%s%s", sysfs_path, udev.devpath);
- path[sizeof(path)-1] = '\0';
- class_dev = wait_class_device_open(path);
- if (class_dev == NULL) {
- dbg("open class device failed");
- goto run;
- }
- dbg("opened class_dev->name='%s'", class_dev->name);
- wait_for_class_device(class_dev, &error);
-
- /* get major/minor */
- if (udev.type == DEV_BLOCK || udev.type == DEV_CLASS)
- udev.devt = get_devt(class_dev);
-
- if (udev.type == DEV_NET || udev.devt) {
- /* name device */
- udev_rules_get_name(&rules, &udev, class_dev);
- if (udev.ignore_device) {
- info("device event will be ignored");
- sysfs_close_class_device(class_dev);
- goto cleanup;
- }
- if (udev.name[0] == '\0') {
- info("device node creation supressed");
- sysfs_close_class_device(class_dev);
- goto cleanup;
- }
- /* create node, store in db */
- retval = udev_add_device(&udev, class_dev);
- } else {
- dbg("no dev-file found");
- udev_rules_get_run(&rules, &udev, class_dev, NULL);
- if (udev.ignore_device) {
- info("device event will be ignored");
- sysfs_close_class_device(class_dev);
- goto cleanup;
- }
- }
- sysfs_close_class_device(class_dev);
- } else if (strcmp(action, "remove") == 0) {
- dbg("node remove");
- udev_rules_get_run(&rules, &udev, NULL, NULL);
- if (udev.ignore_device) {
- dbg("device event will be ignored");
- goto cleanup;
- }
-
- /* get name from db, remove db-entry, delete node */
- retval = udev_remove_device(&udev);
- }
-
- /* export name of device node or netif */
- if (udev.devname[0] != '\0')
- setenv("DEVNAME", udev.devname, 1);
- } else if (udev.type == DEV_DEVICE && strcmp(action, "add") == 0) {
- struct sysfs_device *devices_dev;
-
- /* wait for sysfs of /sys/devices/ */
- dbg("devices add");
- snprintf(path, sizeof(path), "%s%s", sysfs_path, devpath);
- path[sizeof(path)-1] = '\0';
- devices_dev = wait_devices_device_open(path);
- if (!devices_dev) {
- dbg("devices device unavailable (probably remove has beaten us)");
- goto run;
- }
- dbg("devices device opened '%s'", path);
- wait_for_devices_device(devices_dev, &error);
- udev_rules_get_run(&rules, &udev, NULL, devices_dev);
- sysfs_close_device(devices_dev);
- if (udev.ignore_device) {
- info("device event will be ignored");
- goto cleanup;
- }
- } else {
- dbg("default handling");
- udev_rules_get_run(&rules, &udev, NULL, NULL);
- if (udev.ignore_device) {
- info("device event will be ignored");
- goto cleanup;
- }
- }
+ retval = udev_process_event(&rules, &udev);
-run:
- if (udev_run && !list_empty(&udev.run_list)) {
+ if (!retval && udev_run && !list_empty(&udev.run_list)) {
struct name_entry *name_loop;
dbg("executing run list");
execute_program(name_loop->name, udev.subsystem, NULL, 0, NULL);
}
-cleanup:
udev_cleanup_device(&udev);
exit:
/*
* udev.h
*
- * Userspace devfs
- *
* Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
* Copyright (C) 2003-2005 Kay Sievers <kay.sievers@vrfy.org>
*
#define DEFAULT_PARTITIONS_COUNT 15
#define UDEV_ALARM_TIMEOUT 120
+struct udev_rules;
+
enum device_type {
DEV_UNKNOWN,
DEV_CLASS,
int test_run;
};
+extern int udev_init_device(struct udevice *udev, const char* devpath, const char *subsystem, const char *action);
+extern void udev_cleanup_device(struct udevice *udev);
+extern int udev_process_event(struct udev_rules *rules, struct udevice *udev);
extern int udev_add_device(struct udevice *udev, struct sysfs_class_device *class_dev);
extern int udev_remove_device(struct udevice *udev);
extern void udev_init_config(void);
# 1 - build it
%define volume_id 1
-Summary: A userspace implementation of devfs
+Summary: A userspace device manager providing devfs functionality
Name: udev
Version: 063
Release: 1
Prereq: /bin/sh, fileutils, hotplug
%description
-udev is a implementation of devfs in userspace using sysfs and
-/sbin/hotplug. It requires a 2.6 kernel to run properly.
+udev is a userspace device manager, using sysfs and uevents
+to provide a devfs-like device directory management and uevent
+dispatching.
%prep
%setup -q
/*
* udev-add.c
*
- * Userspace devfs
- *
* Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
- *
+ * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
*
* 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
/*
* udev_config.c
*
- * Userspace devfs
- *
* Copyright (C) 2003,2004 Greg Kroah-Hartman <greg@kroah.com>
- *
+ * Copyright (C) 2004, 2005 Kay Sievers <kay.sievers@vrfy.org>
*
* 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
/*
* udev_db.c
*
- * Userspace devfs
- *
* Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
* Copyright (C) 2004-2005 Kay Sievers <kay.sievers@vrfy.org>
*
/*
* udev_db.h
*
- * Userspace devfs
- *
* Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
- * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
+ * Copyright (C) 2004-2005 Kay Sievers <kay.sievers@vrfy.org>
*
* 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
--- /dev/null
+/*
+ * udev_utils.c - generic stuff used by udev
+ *
+ * Copyright (C) 2004, 2005 Kay Sievers <kay.sievers@vrfy.org>
+ *
+ * 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 <stdlib.h>
+#include <stdio.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <ctype.h>
+#include <dirent.h>
+#include <syslog.h>
+#include <sys/wait.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <sys/utsname.h>
+
+#include "udev_libc_wrapper.h"
+#include "udev.h"
+#include "logging.h"
+#include "udev_utils.h"
+#include "udev_sysfs.h"
+#include "list.h"
+
+
+int udev_init_device(struct udevice *udev, const char* devpath, const char *subsystem, const char *action)
+{
+ char *pos;
+
+ memset(udev, 0x00, sizeof(struct udevice));
+ INIT_LIST_HEAD(&udev->symlink_list);
+ INIT_LIST_HEAD(&udev->run_list);
+ INIT_LIST_HEAD(&udev->env_list);
+
+ if (subsystem)
+ strlcpy(udev->subsystem, subsystem, sizeof(udev->subsystem));
+
+ if (action)
+ strlcpy(udev->action, action, sizeof(udev->action));
+
+ if (devpath) {
+ strlcpy(udev->devpath, devpath, sizeof(udev->devpath));
+ remove_trailing_char(udev->devpath, '/');
+
+ if (strncmp(udev->devpath, "/block/", 7) == 0)
+ udev->type = DEV_BLOCK;
+ else if (strncmp(udev->devpath, "/class/net/", 11) == 0)
+ udev->type = DEV_NET;
+ else if (strncmp(udev->devpath, "/class/", 7) == 0)
+ udev->type = DEV_CLASS;
+ else if (strncmp(udev->devpath, "/devices/", 9) == 0)
+ udev->type = DEV_DEVICE;
+
+ /* get kernel name */
+ pos = strrchr(udev->devpath, '/');
+ if (pos) {
+ strlcpy(udev->kernel_name, &pos[1], sizeof(udev->kernel_name));
+ dbg("kernel_name='%s'", udev->kernel_name);
+
+ /* Some block devices have '!' in their name, change that to '/' */
+ pos = udev->kernel_name;
+ while (pos[0] != '\0') {
+ if (pos[0] == '!')
+ pos[0] = '/';
+ pos++;
+ }
+
+ /* get kernel number */
+ pos = &udev->kernel_name[strlen(udev->kernel_name)];
+ while (isdigit(pos[-1]))
+ pos--;
+ strlcpy(udev->kernel_number, pos, sizeof(udev->kernel_number));
+ dbg("kernel_number='%s'", udev->kernel_number);
+ }
+ }
+
+ if (udev->type == DEV_BLOCK || udev->type == DEV_CLASS) {
+ udev->mode = 0660;
+ strcpy(udev->owner, "root");
+ strcpy(udev->group, "root");
+ }
+
+ return 0;
+}
+
+void udev_cleanup_device(struct udevice *udev)
+{
+ struct name_entry *name_loop;
+ struct name_entry *temp_loop;
+
+ list_for_each_entry_safe(name_loop, temp_loop, &udev->symlink_list, node) {
+ list_del(&name_loop->node);
+ free(name_loop);
+ }
+ list_for_each_entry_safe(name_loop, temp_loop, &udev->run_list, node) {
+ list_del(&name_loop->node);
+ free(name_loop);
+ }
+ list_for_each_entry_safe(name_loop, temp_loop, &udev->env_list, node) {
+ list_del(&name_loop->node);
+ free(name_loop);
+ }
+}
--- /dev/null
+/*
+ * udev_event.c - udev event process
+ *
+ * Copyright (C) 2004, 2005 Kay Sievers <kay.sievers@vrfy.org>
+ *
+ * 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 <stdlib.h>
+#include <stdio.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <ctype.h>
+#include <dirent.h>
+#include <syslog.h>
+#include <sys/wait.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <sys/utsname.h>
+
+#include "udev_libc_wrapper.h"
+#include "udev.h"
+#include "logging.h"
+#include "udev_rules.h"
+#include "udev_utils.h"
+#include "udev_sysfs.h"
+#include "list.h"
+
+
+int udev_process_event(struct udev_rules *rules, struct udevice *udev)
+{
+ int retval;
+ char path[PATH_SIZE];
+ const char *error;
+
+ if (udev->type == DEV_BLOCK || udev->type == DEV_CLASS || udev->type == DEV_NET) {
+ /* handle device node */
+ if (strcmp(udev->action, "add") == 0) {
+ struct sysfs_class_device *class_dev;
+
+ /* wait for sysfs of /sys/class /sys/block */
+ dbg("node add");
+ snprintf(path, sizeof(path), "%s%s", sysfs_path, udev->devpath);
+ path[sizeof(path)-1] = '\0';
+ class_dev = wait_class_device_open(path);
+ if (class_dev == NULL) {
+ dbg("open class device failed");
+ return 0;
+ }
+ dbg("opened class_dev->name='%s'", class_dev->name);
+ wait_for_class_device(class_dev, &error);
+
+ /* get major/minor */
+ if (udev->type == DEV_BLOCK || udev->type == DEV_CLASS)
+ udev->devt = get_devt(class_dev);
+
+ if (udev->type == DEV_NET || udev->devt) {
+ /* name device */
+ udev_rules_get_name(rules, udev, class_dev);
+ if (udev->ignore_device) {
+ info("device event will be ignored");
+ sysfs_close_class_device(class_dev);
+ return -1;
+ }
+ if (udev->name[0] == '\0') {
+ info("device node creation supressed");
+ sysfs_close_class_device(class_dev);
+ return -1;
+ }
+ /* create node, store in db */
+ retval = udev_add_device(udev, class_dev);
+ } else {
+ dbg("no dev-file found");
+ udev_rules_get_run(rules, udev, class_dev, NULL);
+ if (udev->ignore_device) {
+ info("device event will be ignored");
+ sysfs_close_class_device(class_dev);
+ return -1;
+ }
+ }
+ sysfs_close_class_device(class_dev);
+ } else if (strcmp(udev->action, "remove") == 0) {
+ dbg("node remove");
+ udev_rules_get_run(rules, udev, NULL, NULL);
+ if (udev->ignore_device) {
+ dbg("device event will be ignored");
+ return -1;
+ }
+
+ /* get name from db, remove db-entry, delete node */
+ retval = udev_remove_device(udev);
+ }
+
+ /* export name of device node or netif */
+ if (udev->devname[0] != '\0')
+ setenv("DEVNAME", udev->devname, 1);
+ } else if (udev->type == DEV_DEVICE && strcmp(udev->action, "add") == 0) {
+ struct sysfs_device *devices_dev;
+
+ /* wait for sysfs of /sys/devices/ */
+ dbg("devices add");
+ snprintf(path, sizeof(path), "%s%s", sysfs_path, udev->devpath);
+ path[sizeof(path)-1] = '\0';
+ devices_dev = wait_devices_device_open(path);
+ if (!devices_dev) {
+ dbg("devices device unavailable (probably remove has beaten us)");
+ return 0;
+ }
+ dbg("devices device opened '%s'", path);
+ wait_for_devices_device(devices_dev, &error);
+ udev_rules_get_run(rules, udev, NULL, devices_dev);
+ sysfs_close_device(devices_dev);
+ if (udev->ignore_device) {
+ info("device event will be ignored");
+ return -1;
+ }
+ } else {
+ dbg("default handling");
+ udev_rules_get_run(rules, udev, NULL, NULL);
+ if (udev->ignore_device) {
+ info("device event will be ignored");
+ return -1;
+ }
+ }
+ return 0;
+}
/*
* udev-remove.c
*
- * Userspace devfs
- *
* Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
- *
+ * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
*
* 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
/*
* udev_rules.c
*
- * Userspace devfs
- *
* Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
* Copyright (C) 2003-2005 Kay Sievers <kay.sievers@vrfy.org>
*
- *
* 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.
#include "udev_db.h"
-/* compare string with pattern (supports * ? [0-9] [!A-Z]) */
-static int strcmp_pattern(const char *p, const char *s)
-{
- if (s[0] == '\0') {
- while (p[0] == '*')
- p++;
- return (p[0] != '\0');
- }
- switch (p[0]) {
- case '[':
- {
- int not = 0;
- p++;
- if (p[0] == '!') {
- not = 1;
- p++;
- }
- while ((p[0] != '\0') && (p[0] != ']')) {
- int match = 0;
- if (p[1] == '-') {
- if ((s[0] >= p[0]) && (s[0] <= p[2]))
- match = 1;
- p += 3;
- } else {
- match = (p[0] == s[0]);
- p++;
- }
- if (match ^ not) {
- while ((p[0] != '\0') && (p[0] != ']'))
- p++;
- if (p[0] == ']')
- return strcmp_pattern(p+1, s+1);
- }
- }
- }
- break;
- case '*':
- if (strcmp_pattern(p, s+1))
- return strcmp_pattern(p+1, s);
- return 0;
- case '\0':
- if (s[0] == '\0') {
- return 0;
- }
- break;
- default:
- if ((p[0] == s[0]) || (p[0] == '?'))
- return strcmp_pattern(p+1, s+1);
- break;
- }
- return 1;
-}
-
/* extract possible {attr} and move str behind it */
static char *get_format_attribute(char **str)
{
/*
* udev_rules.h
*
- * Userspace devfs
- *
- * Copyright (C) 2003,2004 Greg Kroah-Hartman <greg@kroah.com>
+ * Copyright (C) 2003-2004 Greg Kroah-Hartman <greg@kroah.com>
+ * Copyright (C) 2004-2005 Kay Sievers <kay.sievers@vrfy.org>
*
* 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
extern int udev_rules_init(struct udev_rules *rules, int resolve_names);
extern void udev_rules_close(struct udev_rules *rules);
+extern void udev_apply_format(struct udevice *udev, char *string, size_t maxsize,
+ struct sysfs_class_device *class_dev, struct sysfs_device *sysfs_device);
+
extern void udev_rules_iter_init(struct udev_rules *rules);
extern struct udev_rule *udev_rules_iter_next(struct udev_rules *rules);
extern struct udev_rule *udev_rules_iter_label(struct udev_rules *rules, const char *label);
/*
* udev_rules_parse.c
*
- * Userspace devfs
- *
* Copyright (C) 2003,2004 Greg Kroah-Hartman <greg@kroah.com>
* Copyright (C) 2003-2005 Kay Sievers <kay.sievers@vrfy.org>
*
- *
* 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.
/*
- * udev_lib - generic stuff used by udev
+ * udev_utils.c - generic stuff used by udev
*
- * Copyright (C) 2004 Kay Sievers <kay@vrfy.org>
+ * Copyright (C) 2004-2005 Kay Sievers <kay.sievers@vrfy.org>
*
* 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
#include "udev_utils.h"
#include "list.h"
-
-int udev_init_device(struct udevice *udev, const char* devpath, const char *subsystem, const char *action)
+/* compare string with pattern (supports * ? [0-9] [!A-Z]) */
+int strcmp_pattern(const char *p, const char *s)
{
- char *pos;
-
- memset(udev, 0x00, sizeof(struct udevice));
- INIT_LIST_HEAD(&udev->symlink_list);
- INIT_LIST_HEAD(&udev->run_list);
- INIT_LIST_HEAD(&udev->env_list);
-
- if (subsystem)
- strlcpy(udev->subsystem, subsystem, sizeof(udev->subsystem));
-
- if (action)
- strlcpy(udev->action, action, sizeof(udev->action));
-
- if (devpath) {
- strlcpy(udev->devpath, devpath, sizeof(udev->devpath));
- remove_trailing_char(udev->devpath, '/');
-
- if (strncmp(udev->devpath, "/block/", 7) == 0)
- udev->type = DEV_BLOCK;
- else if (strncmp(udev->devpath, "/class/net/", 11) == 0)
- udev->type = DEV_NET;
- else if (strncmp(udev->devpath, "/class/", 7) == 0)
- udev->type = DEV_CLASS;
- else if (strncmp(udev->devpath, "/devices/", 9) == 0)
- udev->type = DEV_DEVICE;
-
- /* get kernel name */
- pos = strrchr(udev->devpath, '/');
- if (pos) {
- strlcpy(udev->kernel_name, &pos[1], sizeof(udev->kernel_name));
- dbg("kernel_name='%s'", udev->kernel_name);
-
- /* Some block devices have '!' in their name, change that to '/' */
- pos = udev->kernel_name;
- while (pos[0] != '\0') {
- if (pos[0] == '!')
- pos[0] = '/';
- pos++;
+ if (s[0] == '\0') {
+ while (p[0] == '*')
+ p++;
+ return (p[0] != '\0');
+ }
+ switch (p[0]) {
+ case '[':
+ {
+ int not = 0;
+ p++;
+ if (p[0] == '!') {
+ not = 1;
+ p++;
+ }
+ while ((p[0] != '\0') && (p[0] != ']')) {
+ int match = 0;
+ if (p[1] == '-') {
+ if ((s[0] >= p[0]) && (s[0] <= p[2]))
+ match = 1;
+ p += 3;
+ } else {
+ match = (p[0] == s[0]);
+ p++;
+ }
+ if (match ^ not) {
+ while ((p[0] != '\0') && (p[0] != ']'))
+ p++;
+ if (p[0] == ']')
+ return strcmp_pattern(p+1, s+1);
+ }
}
-
- /* get kernel number */
- pos = &udev->kernel_name[strlen(udev->kernel_name)];
- while (isdigit(pos[-1]))
- pos--;
- strlcpy(udev->kernel_number, pos, sizeof(udev->kernel_number));
- dbg("kernel_number='%s'", udev->kernel_number);
}
+ break;
+ case '*':
+ if (strcmp_pattern(p, s+1))
+ return strcmp_pattern(p+1, s);
+ return 0;
+ case '\0':
+ if (s[0] == '\0') {
+ return 0;
+ }
+ break;
+ default:
+ if ((p[0] == s[0]) || (p[0] == '?'))
+ return strcmp_pattern(p+1, s+1);
+ break;
}
-
- if (udev->type == DEV_BLOCK || udev->type == DEV_CLASS) {
- udev->mode = 0660;
- strcpy(udev->owner, "root");
- strcpy(udev->group, "root");
- }
-
- return 0;
-}
-
-void udev_cleanup_device(struct udevice *udev)
-{
- struct name_entry *name_loop;
- struct name_entry *temp_loop;
-
- list_for_each_entry_safe(name_loop, temp_loop, &udev->symlink_list, node) {
- list_del(&name_loop->node);
- free(name_loop);
- }
- list_for_each_entry_safe(name_loop, temp_loop, &udev->run_list, node) {
- list_del(&name_loop->node);
- free(name_loop);
- }
- list_for_each_entry_safe(name_loop, temp_loop, &udev->env_list, node) {
- list_del(&name_loop->node);
- free(name_loop);
- }
+ return 1;
}
int string_is_true(const char *str)
/*
- * udev_lib - generic stuff used by udev
- *
- * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
+ * udev_utils.c - generic stuff used by udev
*
+ * Copyright (C) 2004-2005 Kay Sievers <kay.sievers@vrfy.org>
*
* 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
*
*/
-#ifndef _UDEV_LIB_H_
-#define _UDEV_LIB_H_
+#ifndef _UDEV_COMMON_H_
+#define _UDEV_COMMON_H_
#include "udev.h"
+#include "list.h"
struct name_entry {
struct list_head node;
char name[PATH_SIZE];
};
-extern int udev_init_device(struct udevice *udev, const char* devpath, const char *subsystem, const char *action);
-extern void udev_cleanup_device(struct udevice *udev);
-
+extern int strcmp_pattern(const char *p, const char *s);
extern int kernel_release_satisfactory(unsigned int version, unsigned int patchlevel, unsigned int sublevel);
extern int create_path(const char *path);
extern int log_priority(const char *priority);
/*
* udevcontrol.c
*
- * Userspace devfs
- *
* Copyright (C) 2005 Kay Sievers <kay.sievers@vrfy.org>
*
- *
* 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.
/*
* udevd.h
*
- * Userspace devfs
- *
* Copyright (C) 2004 Ling, Xiaofeng <xiaofeng.ling@intel.com>
- * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
- *
+ * Copyright (C) 2004-2005 Kay Sievers <kay.sievers@vrfy.org>
*
* 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
/*
* udeveventrecorder.c
*
- * Userspace devfs
- *
- * Copyright (C) 2004, 2005 Olaf Hering <olh@suse.de>
+ * Copyright (C) 2004-2005 SuSE Linux Products GmbH
+ * Author:
+ * Olaf Hering <olh@suse.de>
*
* 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
/*
- * udevinfo - fetches attributes for a device
+ * udevinfo.c - fetches attributes for a device
*
* Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
*
/*
* udevinitsend.c
*
- * Userspace devfs
- *
- * Copyright (C) 2004, 2005 Hannes Reinecke <hare@suse.de>
+ * Copyright (C) 2004, 2005 SuSE Linux Products GmbH
+ * Author:
+ * Hannes Reinecke <hare@suse.de>
*
* 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
/*
* udevsend.c
*
- * Userspace devfs
- *
* Copyright (C) 2004 Ling, Xiaofeng <xiaofeng.ling@intel.com>
* Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
*
- *
* 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.
* udevstart.c
*
* Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com>
- *
+ * Copyright (C) 2004 Kay Sievers <kay@vrfy.org>
+ *
* Quick and dirty way to populate a /dev with udev if your system
- * does not have access to a shell. Based originally on a patch to udev
- * from Harald Hoyer <harald@redhat.com>
+ * does not have access to a shell. Based originally on a patch
+ * from:
+ * Harald Hoyer <harald@redhat.com>
*
* 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
#include "udev.h"
#include "udev_version.h"
#include "logging.h"
-#include "udev_rules.h"
#include "udev_utils.h"
+#include "udev_rules.h"
#include "list.h"
static const char *udev_run_str;
/*
* udevtest.c
*
- * Userspace devfs
- *
- * Copyright (C) 2003,2004 Greg Kroah-Hartman <greg@kroah.com>
+ * Copyright (C) 2003-2004 Greg Kroah-Hartman <greg@kroah.com>
*
* 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