diff options
author | kay.sievers@vrfy.org <kay.sievers@vrfy.org> | 2004-11-12 06:21:16 +0100 |
---|---|---|
committer | Greg KH <gregkh@suse.de> | 2005-04-26 22:25:09 -0700 |
commit | 8673dcb84299fd2adba6281c5359bed4399d5b2d (patch) | |
tree | 9db3b5d4e7218b098c53d62b8805c9c9368a78af /dev_d.c | |
parent | af4b05d4917fdfa55eff3d8d53a830464d8162a1 (diff) |
[PATCH] Make dev.d/ handling a separate processing stage
Move the logic when and how to call the dev.d/ scripts into the
main processing path.
Diffstat (limited to 'dev_d.c')
-rw-r--r-- | dev_d.c | 38 |
1 files changed, 14 insertions, 24 deletions
@@ -32,9 +32,6 @@ #include "udevdb.h" #include "logging.h" -#define DEVD_DIR "/etc/dev.d/" -#define DEVD_SUFFIX ".dev" - static int run_program(const char *filename, void *data) { pid_t pid; @@ -75,7 +72,7 @@ static int run_program(const char *filename, void *data) * subsystem/ * default/ */ -void dev_d_execute(struct udevice *udev) +void dev_d_execute(struct udevice *udev, const char *basedir, const char *suffix) { char dirname[PATH_MAX]; char devname[NAME_SIZE]; @@ -85,37 +82,30 @@ void dev_d_execute(struct udevice *udev) if (udev_dev_d == 0) return; - /* skip if udev did nothing, like unchanged netif or no "dev" file */ - if (udev->devname[0] == '\0') - return; - - /* add the node name or the netif name to the environment */ - setenv("DEVNAME", udev->devname, 1); - dbg("DEVNAME='%s'", udev->devname); - strfieldcpy(devname, udev->name); - /* Chop the device name up into pieces based on '/' */ + /* chop the device name up into pieces based on '/' */ temp = strchr(devname, '/'); while (temp != NULL) { temp[0] = '\0'; - strcpy(dirname, DEVD_DIR); - strfieldcat(dirname, devname); - call_foreach_file(run_program, dirname, DEVD_SUFFIX, udev); + snprintf(dirname, PATH_MAX, "%s/%s", basedir, devname); + dirname[PATH_MAX-1] = '\0'; + call_foreach_file(run_program, dirname, suffix, udev); temp[0] = '/'; ++temp; temp = strchr(temp, '/'); } - strcpy(dirname, DEVD_DIR); - strfieldcat(dirname, udev->name); - call_foreach_file(run_program, dirname, DEVD_SUFFIX, udev); + snprintf(dirname, PATH_MAX, "%s/%s", basedir, udev->name); + dirname[PATH_MAX-1] = '\0'; + call_foreach_file(run_program, dirname, suffix, udev); - strcpy(dirname, DEVD_DIR); - strfieldcat(dirname, udev->subsystem); - call_foreach_file(run_program, dirname, DEVD_SUFFIX, udev); + snprintf(dirname, PATH_MAX, "%s/%s", basedir, udev->subsystem); + dirname[PATH_MAX-1] = '\0'; + call_foreach_file(run_program, dirname, suffix, udev); - strcpy(dirname, DEVD_DIR "default"); - call_foreach_file(run_program, dirname, DEVD_SUFFIX, udev); + snprintf(dirname, PATH_MAX, "%s/default", basedir); + dirname[PATH_MAX-1] = '\0'; + call_foreach_file(run_program, dirname, suffix, udev); } |