X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;ds=sidebyside;f=udev_rules.c;h=1aedb111181f79cda426eab7d4914ccf553c3aba;hb=00152560f9ba3de71144e25c874f9fa2cfa6682b;hp=e9b32df1c66d85a838a311f160ae889955d0f90e;hpb=f8db897faaaf3417ed0a31a39c7f47cc8cf40bd6;p=elogind.git diff --git a/udev_rules.c b/udev_rules.c index e9b32df1c..1aedb1111 100644 --- a/udev_rules.c +++ b/udev_rules.c @@ -290,6 +290,12 @@ static int find_free_number(const char *base, const char *devpath) char filename[PATH_SIZE]; struct udevice *udev_db; int num = 0; + static int warn = 1; + + if (warn) { + err("%%e is deprecated, will be removed and is unlikey to work correctly. Don't use it."); + warn = 0; + } /* check if the device already owns a matching name */ udev_db = udev_device_init(); @@ -342,23 +348,33 @@ out: #define WAIT_LOOP_PER_SECOND 50 static int wait_for_sysfs(struct udevice *udev, const char *file, int timeout) { - char filename[PATH_SIZE]; + char devicepath[PATH_SIZE]; + char filepath[PATH_SIZE]; struct stat stats; int loop = timeout * WAIT_LOOP_PER_SECOND; - snprintf(filename, sizeof(filename), "%s%s/%s", sysfs_path, udev->dev->devpath, file); - filename[sizeof(filename)-1] = '\0'; - dbg("will wait %i sec for '%s'", timeout, filename); + strlcpy(devicepath, sysfs_path, sizeof(devicepath)); + strlcat(devicepath, udev->dev->devpath, sizeof(devicepath)); + strlcpy(filepath, devicepath, sizeof(filepath)); + strlcat(filepath, "/", sizeof(filepath)); + strlcat(filepath, file, sizeof(filepath)); + dbg("will wait %i sec for '%s'", timeout, filepath); while (--loop) { - if (stat(filename, &stats) == 0) { - info("file '%s' appeared after %i loops", filename, (timeout * WAIT_LOOP_PER_SECOND) - loop-1); + /* lookup file */ + if (stat(filepath, &stats) == 0) { + info("file '%s' appeared after %i loops", filepath, (timeout * WAIT_LOOP_PER_SECOND) - loop-1); return 0; } - info("wait for '%s' for %i mseconds", filename, 1000 / WAIT_LOOP_PER_SECOND); + /* make sure the device does not have disappeared in the meantime */ + if (stat(devicepath, &stats) != 0) { + info("device disappeared while waiting for '%s'", filepath); + return -2; + } + info("wait for '%s' for %i mseconds", filepath, 1000 / WAIT_LOOP_PER_SECOND); usleep(1000 * 1000 / WAIT_LOOP_PER_SECOND); } - err("waiting for '%s' failed", filename); + err("waiting for '%s' failed", filepath); return -1; } @@ -606,6 +622,13 @@ found: case SUBST_MODALIAS: { const char *value; + static int warn = 1; + + if (warn) { + err("$modalias is deprecated, use $env{MODALIAS} or " + "$sysfs{modalias} instead."); + warn = 0; + } value = sysfs_attr_get_value(udev->dev->devpath, "modalias"); if (value != NULL) { @@ -705,6 +728,12 @@ static int match_rule(struct udevice *udev, struct udev_rule *rule) if (rule->modalias.operation != KEY_OP_UNSET) { const char *value; + static int warn = 1; + + if (warn) { + err("MODALIAS is deprecated, use ENV{MODALIAS} or SYSFS{modalias} instead."); + warn = 0; + } value = sysfs_attr_get_value(udev->dev->devpath, "modalias"); if (value == NULL) {