#include <errno.h>
#include <dirent.h>
#include <fnmatch.h>
+#include <time.h>
#include "udev.h"
[TK_M_PROGRAM] = "M PROGRAM",
[TK_M_IMPORT_FILE] = "M IMPORT_FILE",
[TK_M_IMPORT_PROG] = "M IMPORT_PROG",
- [TK_M_IMPORT_PARENT] = "M MPORT_PARENT",
+ [TK_M_IMPORT_PARENT] = "M IMPORT_PARENT",
[TK_M_RESULT] = "M RESULT",
[TK_M_MAX] = "M MAX",
char *line;
envp = udev_device_get_properties_envp(dev);
- if (util_run_program(udev, program, envp, result, sizeof(result), &reslen) != 0)
+ if (util_run_program(udev, program, envp, result, sizeof(result), &reslen, NULL) != 0)
return -1;
line = result;
dbg(udev, "will wait %i sec for '%s'\n", timeout, file);
while (--loop) {
+ const struct timespec duration = { 0, 1000 * 1000 * 1000 / WAIT_LOOP_PER_SECOND };
+
/* lookup file */
if (stat(file, &stats) == 0) {
info(udev, "file '%s' appeared after %i loops\n", file, (timeout * WAIT_LOOP_PER_SECOND) - loop-1);
return -2;
}
info(udev, "wait for '%s' for %i mseconds\n", file, 1000 / WAIT_LOOP_PER_SECOND);
- usleep(1000 * 1000 / WAIT_LOOP_PER_SECOND);
+ nanosleep(&duration, NULL);
}
info(udev, "waiting for '%s' failed\n", file);
return -1;
char *temp;
linepos = *line;
- if (linepos == NULL && linepos[0] == '\0')
+ if (linepos == NULL || linepos[0] == '\0')
return -1;
/* skip whitespace */
int flag = 0;
attr = get_key_attribute(rules->udev, key + sizeof("RUN")-1);
- if (attr != NULL && strstr(attr, "ignore_error"))
+ if (attr != NULL && strstr(attr, "fail_event_on_error"))
flag = 1;
rule_add_key(&rule_tmp, TK_A_RUN, op, value, &flag);
continue;
} else {
if (value[0] == '\0')
info(rules->udev, "name empty, node creation suppressed\n");
+ else if (strcmp(value, "%k") == 0)
+ err(rules->udev, "NAME=\"%%k\" is superfluous and breaks "
+ "kernel supplied names, please remove it from %s:%u\n", filename, lineno);
rule_add_key(&rule_tmp, TK_A_NAME, op, value, NULL);
attr = get_key_attribute(rules->udev, key + sizeof("NAME")-1);
if (attr != NULL) {
int tout = atoi(&pos[strlen("event_timeout=")]);
rule_add_key(&rule_tmp, TK_A_EVENT_TIMEOUT, 0, NULL, &tout);
- dbg(rules->udev, "event timout=%i\n", tout);
+ dbg(rules->udev, "event timeout=%i\n", tout);
}
pos = strstr(value, "string_escape=");
if (pos != NULL) {
first_token = rules->token_cur;
- while(fgets(line, sizeof(line), f) != NULL) {
+ while (fgets(line, sizeof(line), f) != NULL) {
char *key;
size_t len;
while (line[len-2] == '\\') {
if (fgets(&line[len-2], (sizeof(line)-len)+2, f) == NULL)
break;
+ if (strlen(&line[len-2]) < 2)
+ break;
line_nr++;
len = strlen(line);
}
if (stat(filename, &statbuf) == 0 && statbuf.st_size > 0)
parse_file(rules, filename, filename_off);
else
- info(udev, "can not read '%s'\n", filename);
+ err(udev, "can not read '%s'\n", filename);
udev_list_entry_delete(file_loop);
}
program,
&rules->buf[rule->rule.filename_off],
rule->rule.filename_line);
- if (util_run_program(event->udev, program, envp, result, sizeof(result), NULL) != 0) {
+ if (util_run_program(event->udev, program, envp, result, sizeof(result), NULL, NULL) != 0) {
if (cur->key.op != OP_NOMATCH)
goto nomatch;
} else {