if (strstr(argv[0], "udevstart") || (argv[1] != NULL && strstr(argv[1], "udevstart"))) {
act_type = UDEVSTART;
} else {
- const char *action = get_action();
- const char *devpath = get_devpath();
- const char *subsystem = get_subsystem(main_argv[1]);
+ const char *action = getenv("ACTION");
+ const char *devpath = getenv("DEVPATH");
+ const char *subsystem = argv[1];
if (!action) {
dbg("no action?");
goto exit;
}
- udev_set_values(&udev, devpath, subsystem);
+ udev_set_values(&udev, devpath, subsystem, action);
/* skip blacklisted subsystems */
if (udev.type != 'n' && subsystem_expect_no_dev(subsystem)) {
#define COMMENT_CHARACTER '#'
#define NAME_SIZE 256
-#define OWNER_SIZE 30
-#define GROUP_SIZE 30
+#define OWNER_SIZE 32
+#define GROUP_SIZE 32
#define MODE_SIZE 8
#define ACTION_SIZE 32
struct udevice {
char devpath[DEVPATH_SIZE];
char subsystem[SUBSYSTEM_SIZE];
+ char action[ACTION_SIZE];
char name[NAME_SIZE];
char owner[OWNER_SIZE];
char group[GROUP_SIZE];
#include "list.h"
-char *get_action(void)
-{
- char *action;
-
- action = getenv("ACTION");
- if (action != NULL && strlen(action) > ACTION_SIZE)
- action[ACTION_SIZE-1] = '\0';
-
- return action;
-}
-
-char *get_devpath(void)
-{
- char *devpath;
-
- devpath = getenv("DEVPATH");
- if (devpath != NULL && strlen(devpath) > DEVPATH_SIZE)
- devpath[DEVPATH_SIZE-1] = '\0';
-
- return devpath;
-}
-
-char *get_devname(void)
-{
- char *devname;
-
- devname = getenv("DEVNAME");
- if (devname != NULL && strlen(devname) > NAME_SIZE)
- devname[NAME_SIZE-1] = '\0';
-
- return devname;
-}
-
-char *get_seqnum(void)
-{
- char *seqnum;
-
- seqnum = getenv("SEQNUM");
-
- return seqnum;
-}
-
-char *get_subsystem(char *subsystem)
-{
- if (subsystem != NULL && strlen(subsystem) > SUBSYSTEM_SIZE)
- subsystem[SUBSYSTEM_SIZE-1] = '\0';
-
- return subsystem;
-}
-
#define BLOCK_PATH "/block/"
#define CLASS_PATH "/class/"
#define NET_PATH "/class/net/"
return '\0';
}
-void udev_set_values(struct udevice *udev, const char* devpath, const char *subsystem)
+void udev_set_values(struct udevice *udev, const char* devpath,
+ const char *subsystem, const char* action)
{
memset(udev, 0x00, sizeof(struct udevice));
strfieldcpy(udev->devpath, devpath);
strfieldcpy(udev->subsystem, subsystem);
+ strfieldcpy(udev->action, action);
udev->type = get_device_type(devpath, subsystem);
}
# define asmlinkage /* nothing */
#endif
-extern char *get_action(void);
-extern char *get_devpath(void);
-extern char *get_devname(void);
-extern char *get_seqnum(void);
-extern char *get_subsystem(char *subsystem);
extern char get_device_type(const char *path, const char *subsystem);
-extern void udev_set_values(struct udevice *udev, const char* devpath, const char *subsystem);
+extern void udev_set_values(struct udevice *udev, const char* devpath,
+ const char *subsystem, const char* action);
extern int create_path(const char *path);
extern int file_map(const char *filename, char **buf, size_t *bufsize);
extern void file_unmap(char *buf, size_t bufsize);
return -ENODEV;
}
- udev_set_values(&udev, devpath, subsystem);
+ udev_set_values(&udev, devpath, subsystem, "add");
udev_add_device(&udev, class_dev);
/* run scripts */
subsystem = argv[2];
/* fill in values and test_run flag*/
- udev_set_values(&udev, devpath, subsystem);
+ udev_set_values(&udev, devpath, subsystem, "add");
/* open the device */
snprintf(path, SYSFS_PATH_MAX, "%s%s", sysfs_path, udev.devpath);