X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=udev%2Fudev-event.c;h=d5b4d0941e295f1d1a18fb97a879a7b04a00edc2;hb=1150c6e641374196f6dc47bd0e01dee7504abd9b;hp=2f32805f30d9b57885a12e847d778248adf72fa4;hpb=4950b6e6a8c298085a8c135393cfa8649644f7c9;p=elogind.git diff --git a/udev/udev-event.c b/udev/udev-event.c index 2f32805f3..d5b4d0941 100644 --- a/udev/udev-event.c +++ b/udev/udev-event.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2009 Kay Sievers + * Copyright (C) 2003-2009 Kay Sievers * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,9 +23,10 @@ #include #include #include +#include +#include #include #include -#include #include #include "udev.h" @@ -126,7 +127,7 @@ size_t udev_event_apply_format(struct udev_event *event, const char *src, char * } for (i = 0; i < ARRAY_SIZE(map); i++) { - if (strncasecmp(&from[1], map[i].name, strlen(map[i].name)) == 0) { + if (strncmp(&from[1], map[i].name, strlen(map[i].name)) == 0) { type = map[i].type; from += strlen(map[i].name)+1; dbg(event->udev, "will substitute format name '%s'\n", map[i].name); @@ -491,8 +492,7 @@ static int rename_netif(struct udev_event *event) } /* free our own name, another process may wait for us */ - util_strscpy(ifr.ifr_newname, IFNAMSIZ, udev_device_get_sysname(dev)); - util_strscpy(ifr.ifr_newname, IFNAMSIZ, "_rename"); + util_strscpyl(ifr.ifr_newname, IFNAMSIZ, udev_device_get_sysname(dev), "_rename", NULL); err = ioctl(sk, SIOCSIFNAME, &ifr); if (err != 0) { err(event->udev, "error changing netif name %s to %s: %m\n", @@ -505,6 +505,8 @@ static int rename_netif(struct udev_event *event) util_strscpy(ifr.ifr_newname, IFNAMSIZ, event->name); loop = 90 * 20; while (loop--) { + const struct timespec duration = { 0, 1000 * 1000 * 1000 / 20 }; + err = ioctl(sk, SIOCSIFNAME, &ifr); if (err == 0) { rename_netif_kernel_log(ifr); @@ -518,7 +520,7 @@ static int rename_netif(struct udev_event *event) } dbg(event->udev, "wait for netif '%s' to become free, loop=%i\n", event->name, (90 * 20) - loop); - usleep(1000 * 1000 / 20); + nanosleep(&duration, NULL); } } exit: @@ -531,10 +533,12 @@ int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules) struct udev_device *dev = event->dev; int err = 0; - if (udev_device_get_devpath_old(dev) != NULL) { - if (udev_device_rename_db(dev, udev_device_get_devpath(dev)) == 0) - info(event->udev, "moved database from '%s' to '%s'\n", - udev_device_get_devpath_old(dev), udev_device_get_devpath(dev)); + if (udev_device_get_sysname_old(dev) != NULL && + strcmp(udev_device_get_sysname_old(dev), udev_device_get_sysname(dev)) != 0) { + udev_device_rename_db(dev); + info(event->udev, "moved database from '%s:%s' to '%s:%s'\n", + udev_device_get_subsystem(dev), udev_device_get_sysname_old(dev), + udev_device_get_subsystem(dev), udev_device_get_sysname(dev)); } /* add device node */ @@ -571,7 +575,7 @@ int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules) } if (event->name != NULL && event->name[0] == '\0') { - info(event->udev, "device node creation supressed\n"); + info(event->udev, "device node creation suppressed\n"); delete_kdevnode = 1; goto exit_add; } @@ -683,9 +687,9 @@ exit_add: char devnode[UTIL_PATH_SIZE]; info(event->udev, "'%s' not found in database, using kernel name '%s'\n", - udev_device_get_syspath(dev), udev_device_get_sysname(dev)); + udev_device_get_syspath(dev), udev_device_get_knodename(dev)); util_strscpyl(devnode, sizeof(devnode), - udev_get_dev_path(event->udev), "/", udev_device_get_sysname(dev), NULL); + udev_get_dev_path(event->udev), "/", udev_device_get_knodename(dev), NULL); udev_device_set_devnode(dev, devnode); } @@ -717,7 +721,7 @@ exit: return err; } -int udev_event_execute_run(struct udev_event *event) +int udev_event_execute_run(struct udev_event *event, const sigset_t *sigmask) { struct udev_list_entry *list_entry; int err = 0; @@ -740,8 +744,8 @@ int udev_event_execute_run(struct udev_event *event) udev_event_apply_format(event, cmd, program, sizeof(program)); envp = udev_device_get_properties_envp(event->dev); - if (util_run_program(event->udev, program, envp, NULL, 0, NULL) != 0) { - if (!udev_list_entry_get_flag(list_entry)) + if (util_run_program(event->udev, program, envp, NULL, 0, NULL, sigmask) != 0) { + if (udev_list_entry_get_flag(list_entry)) err = -1; } }