1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00

move code to its own files

Signed-off-by: Kay Sievers <kay.sievers@suse.de>
This commit is contained in:
Kay Sievers 2005-07-22 12:35:58 -04:00
parent 761e5b476f
commit e8d569b414
25 changed files with 380 additions and 311 deletions

View File

@ -115,34 +115,36 @@ CFLAGS += -D_GNU_SOURCE
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 = \
@ -151,7 +153,7 @@ OBJS = \
SYSFS = $(PWD)/libsysfs/sysfs.a
CFLAGS += -I$(PWD)/libsysfs/sysfs \
CFLAGS += -I$(PWD)/libsysfs/sysfs \
-I$(PWD)/libsysfs
ifeq ($(strip $(USE_LOG)),true)

View File

@ -28,7 +28,7 @@ INSTALL_PROGRAM = ${INSTALL}
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 =

102
udev.c
View File

@ -1,10 +1,8 @@
/*
* 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
@ -69,8 +67,6 @@ int main(int argc, char *argv[], char *envp[])
{
struct udevice udev;
struct udev_rules rules;
char path[PATH_SIZE];
const char *error;
const char *action;
const char *devpath;
const char *subsystem;
@ -121,98 +117,9 @@ int main(int argc, char *argv[], char *envp[])
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;
retval = udev_process_event(&rules, &udev);
/* 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;
}
}
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");
@ -220,7 +127,6 @@ run:
execute_program(name_loop->name, udev.subsystem, NULL, 0, NULL);
}
cleanup:
udev_cleanup_device(&udev);
exit:

7
udev.h
View File

@ -1,8 +1,6 @@
/*
* udev.h
*
* Userspace devfs
*
* Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
* Copyright (C) 2003-2005 Kay Sievers <kay.sievers@vrfy.org>
*
@ -40,6 +38,8 @@
#define DEFAULT_PARTITIONS_COUNT 15
#define UDEV_ALARM_TIMEOUT 120
struct udev_rules;
enum device_type {
DEV_UNKNOWN,
DEV_CLASS,
@ -82,6 +82,9 @@ struct udevice {
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);

View File

@ -27,7 +27,7 @@
# 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
@ -41,8 +41,9 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
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

View File

@ -1,10 +1,8 @@
/*
* 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

View File

@ -1,10 +1,8 @@
/*
* 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

View File

@ -1,8 +1,6 @@
/*
* udev_db.c
*
* Userspace devfs
*
* Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com>
* Copyright (C) 2004-2005 Kay Sievers <kay.sievers@vrfy.org>
*

View File

@ -1,10 +1,8 @@
/*
* 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

121
udev_device.c Normal file
View File

@ -0,0 +1,121 @@
/*
* 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);
}
}

141
udev_event.c Normal file
View File

@ -0,0 +1,141 @@
/*
* 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;
}

View File

@ -1,10 +1,8 @@
/*
* 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

View File

@ -1,12 +1,9 @@
/*
* 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.
@ -44,59 +41,6 @@
#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)
{

View File

@ -1,9 +1,8 @@
/*
* 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
@ -108,6 +107,9 @@ struct udev_rules {
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);

View File

@ -1,12 +1,9 @@
/*
* 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.

View File

@ -1,7 +1,7 @@
/*
* 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
@ -39,84 +39,57 @@
#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)

View File

@ -1,8 +1,7 @@
/*
* 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
@ -19,19 +18,18 @@
*
*/
#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);

View File

@ -1,11 +1,8 @@
/*
* 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.

View File

@ -1,11 +1,8 @@
/*
* 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

View File

@ -1,9 +1,9 @@
/*
* 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

View File

@ -1,5 +1,5 @@
/*
* udevinfo - fetches attributes for a device
* udevinfo.c - fetches attributes for a device
*
* Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
*

View File

@ -1,9 +1,9 @@
/*
* 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

View File

@ -1,12 +1,9 @@
/*
* 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.

View File

@ -2,10 +2,12 @@
* 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
@ -41,8 +43,8 @@
#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;

View File

@ -1,9 +1,7 @@
/*
* 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