* subsystem/
* default/
*/
-void dev_d_send(struct udevice *dev, char *subsystem)
+void dev_d_send(struct udevice *dev, char *subsystem, char *devpath)
{
char dirname[256];
char devname[NAME_SIZE];
strfieldcat(devname, dev->name);
} else if (dev->type == 'n') {
strfieldcpy(devname, dev->name);
+ setenv("DEVPATH", devpath, 1);
}
- setenv("DEVNODE", devname, 1); /* FIXME: bad name for netif */
setenv("DEVNAME", devname, 1);
dbg("DEVNAME='%s'", devname);
{
struct sysfs_class_device *class_dev;
struct udevice dev;
- char key[DEVPATH_SIZE];
+ char devpath[DEVPATH_SIZE];
char *pos;
int retval;
dbg("udevdb_add_dev failed, but we are going to try "
"to create the node anyway. But remove might not "
"work properly for this device.");
+
+ dev_d_send(&dev, subsystem, path);
break;
case 'n':
- strfieldcpy(key, path);
if (strcmp(dev.name, dev.kernel_name) != 0) {
retval = rename_net_if(&dev, fake);
if (fake || retval != 0)
/* netif's are keyed with the configured name, cause
* the original kernel name sleeps with the fishes
*/
- pos = strrchr(key, '/');
+ strfieldcpy(devpath, path);
+ pos = strrchr(devpath, '/');
if (pos != NULL) {
pos[1] = '\0';
- strfieldcat(key, dev.name);
+ strfieldcat(devpath, dev.name);
}
}
- if (udevdb_add_dev(key, &dev) != 0)
+ if (udevdb_add_dev(devpath, &dev) != 0)
dbg("udevdb_add_dev failed");
+
+ dev_d_send(&dev, subsystem, devpath);
break;
}
- /* execute programs in dev.d/ with the name in the environment */
- dev_d_send(&dev, subsystem);
-
exit:
sysfs_close_class_device(class_dev);
dbg("name='%s'", dev.name);
dev.type = get_device_type(path, subsystem);
- dev_d_send(&dev, subsystem);
+ dev_d_send(&dev, subsystem, path);
udevdb_delete_dev(path);
if (dev.type == 'b' || dev.type == 'c')
extern int udev_remove_device(char *path, char *subsystem);
extern void udev_init_config(void);
extern int parse_get_pair(char **orig_string, char **left, char **right);
-extern void dev_d_send(struct udevice *dev, char *subsystem);
+extern void dev_d_send(struct udevice *dev, char *subsystem, char *devpath);
extern char **main_argv;
extern char **main_envp;
#define set_var(_name, _var) \
if (strcasecmp(variable, _name) == 0) { \
- dbg_parse("%s = '%s'", _name, value); \
- strfieldcpymax(_var, value, sizeof(_var));\
+ dbg_parse("%s='%s'", _name, value); \
+ strfieldcpy(_var, value);\
}
#define set_bool(_name, _var) \
if (strcasecmp(variable, _name) == 0) { \
- dbg_parse("%s = '%s'", _name, value); \
+ dbg_parse("%s='%s'", _name, value); \
_var = string_is_true(value); \
}
char devpath[DEVPATH_SIZE];
char *env[] = { action, devpath, NULL };
- snprintf(action, sizeof(action), "ACTION=%s", msg->action);
- snprintf(devpath, sizeof(devpath), "DEVPATH=%s", msg->devpath);
+ strcpy(action, "ACTION=");
+ strfieldcat(action, msg->action);
+ strcpy(devpath, "DEVPATH=");
+ strfieldcat(devpath, msg->devpath);
pid = fork();
switch (pid) {
#include <unistd.h>
#include "logging.h"
+#include "udev_lib.h"
#ifdef LOG
char nosleep[] = "UDEV_NO_SLEEP=1";
char *env[] = { action, devpath, nosleep, NULL };
- snprintf(devpath, MAX_PATHLEN, "DEVPATH=%s", path);
- devpath[MAX_PATHLEN-1] = '\0';
+ strcpy(action, "DEVPATH=%s");
+ strfieldcat(action, path);
pid = fork();
switch (pid) {