retval = udev_device_event(&rules, udev);
- if (retval == 0 && !udev->ignore_device && udev_run) {
- struct name_entry *name_loop;
-
- dbg("executing run list");
- list_for_each_entry(name_loop, &udev->run_list, node) {
- if (strncmp(name_loop->name, "socket:", strlen("socket:")) == 0)
- pass_env_to_socket(&name_loop->name[strlen("socket:")], devpath, action);
- else {
- char program[PATH_SIZE];
-
- strlcpy(program, name_loop->name, sizeof(program));
- udev_rules_apply_format(udev, program, sizeof(program));
- run_program(program, udev->dev->subsystem, NULL, 0, NULL);
- }
- }
- }
+ if (retval == 0 && !udev->ignore_device && udev_run)
+ udev_rules_run(udev);
udev_device_cleanup(udev);
fail:
return rc;
}
+int udev_rules_run(struct udevice *udev)
+{
+ struct name_entry *name_loop;
+ int retval = 0;
+
+ dbg("executing run list");
+ list_for_each_entry(name_loop, &udev->run_list, node) {
+ if (strncmp(name_loop->name, "socket:", strlen("socket:")) == 0) {
+ pass_env_to_socket(&name_loop->name[strlen("socket:")], udev->dev->devpath, udev->action);
+ } else {
+ char program[PATH_SIZE];
+
+ strlcpy(program, name_loop->name, sizeof(program));
+ udev_rules_apply_format(udev, program, sizeof(program));
+ if (run_program(program, udev->dev->subsystem, NULL, 0, NULL) != 0)
+ if (!name_loop->ignore_error)
+ retval = -1;
+ }
+ }
+
+ return retval;
+}
+
#define WAIT_LOOP_PER_SECOND 50
static int wait_for_sysfs(struct udevice *udev, const char *file, int timeout)
{
extern int udev_rules_get_name(struct udev_rules *rules, struct udevice *udev);
extern int udev_rules_get_run(struct udev_rules *rules, struct udevice *udev);
+extern int udev_rules_run(struct udevice *udev);
extern void udev_rules_apply_format(struct udevice *udev, char *string, size_t maxsize);
if (strncasecmp(key, "IMPORT", sizeof("IMPORT")-1) == 0) {
attr = get_key_attribute(key + sizeof("IMPORT")-1);
- if (attr && strstr(attr, "program")) {
+ if (attr != NULL && strstr(attr, "program")) {
dbg("IMPORT will be executed");
rule->import_type = IMPORT_PROGRAM;
- } else if (attr && strstr(attr, "file")) {
+ } else if (attr != NULL && strstr(attr, "file")) {
dbg("IMPORT will be included as file");
rule->import_type = IMPORT_FILE;
- } else if (attr && strstr(attr, "parent")) {
+ } else if (attr != NULL && strstr(attr, "parent")) {
dbg("IMPORT will include the parent values");
rule->import_type = IMPORT_PARENT;
} else {
if (strncasecmp(key, "RUN", sizeof("RUN")-1) == 0) {
attr = get_key_attribute(key + sizeof("RUN")-1);
- if (attr && strstr(attr, "ignore_error"))
- rule->run_ignore_error = 1;
+ if (attr != NULL) {
+ if (strstr(attr, "ignore_error"))
+ rule->run_ignore_error = 1;
+ }
add_rule_key(rule, &rule->run, operation, value);
valid = 1;
continue;
retval = udev_device_event(&rules, udev);
/* run programs collected by RUN-key*/
- if (retval == 0 && !udev->ignore_device && udev_run) {
- struct name_entry *name_loop;
-
- dbg("executing run list");
- list_for_each_entry(name_loop, &udev->run_list, node) {
- if (strncmp(name_loop->name, "socket:", strlen("socket:")) == 0)
- pass_env_to_socket(&name_loop->name[strlen("socket:")], udev->dev->devpath, udev->action);
- else {
- char program[PATH_SIZE];
-
- strlcpy(program, name_loop->name, sizeof(program));
- udev_rules_apply_format(udev, program, sizeof(program));
- if (run_program(program, udev->dev->subsystem, NULL, 0, NULL) != 0)
- if (!name_loop->ignore_error)
- retval = -1;
- }
- }
- }
+ if (retval == 0 && !udev->ignore_device && udev_run)
+ retval = udev_rules_run(udev);
udev_device_cleanup(udev);
return retval;
else
info("device node creation supressed");
- if (retval == 0 && udev_run) {
- struct name_entry *name_loop;
-
- dbg("executing run list");
- list_for_each_entry(name_loop, &udev->run_list, node) {
- if (strncmp(name_loop->name, "socket:", strlen("socket:")) == 0)
- pass_env_to_socket(&name_loop->name[strlen("socket:")], udev->dev->devpath, "add");
- else {
- char program[PATH_SIZE];
-
- strlcpy(program, name_loop->name, sizeof(program));
- udev_rules_apply_format(udev, program, sizeof(program));
- run_program(program, udev->dev->subsystem, NULL, 0, NULL);
- }
- }
- }
+ if (retval == 0 && udev_run)
+ udev_rules_run(udev);
exit:
udev_device_cleanup(udev);