mirror of
https://github.com/AuxXxilium/eudev.git
synced 2024-11-24 23:41:01 +07:00
udevadm: test - handling trailing '/' in devpath
On Wed, Mar 18, 2009 at 16:00, Matthias Schwarzott <zzam@gentoo.org> wrote: found out how the error occurs: It is a difference between A. udevadm test /sys/class/mem/null/ and B. udevadm test /sys/class/mem/null Case A was the case that showed the error behaviour. It seems udevadm is confused by the trailing slash. This behaviour seems to be there since ages.
This commit is contained in:
parent
b25d8cfa93
commit
f454f6708a
@ -16,7 +16,7 @@ test "$prefix" = NONE && test "$exec_prefix" = NONE && exec_prefix=
|
|||||||
|
|
||||||
dnl /* libudev version */
|
dnl /* libudev version */
|
||||||
LIBUDEV_LT_CURRENT=1
|
LIBUDEV_LT_CURRENT=1
|
||||||
LIBUDEV_LT_REVISION=0
|
LIBUDEV_LT_REVISION=1
|
||||||
LIBUDEV_LT_AGE=1
|
LIBUDEV_LT_AGE=1
|
||||||
AC_SUBST(LIBUDEV_LT_CURRENT)
|
AC_SUBST(LIBUDEV_LT_CURRENT)
|
||||||
AC_SUBST(LIBUDEV_LT_REVISION)
|
AC_SUBST(LIBUDEV_LT_REVISION)
|
||||||
|
@ -303,7 +303,7 @@ struct udev_device *udev_device_new_from_syspath(struct udev *udev, const char *
|
|||||||
/* path is not a root directory */
|
/* path is not a root directory */
|
||||||
subdir = &syspath[len+1];
|
subdir = &syspath[len+1];
|
||||||
pos = strrchr(subdir, '/');
|
pos = strrchr(subdir, '/');
|
||||||
if (pos == NULL || pos < &subdir[2]) {
|
if (pos == NULL || pos[1] == '\0' || pos < &subdir[2]) {
|
||||||
dbg(udev, "not a subdir :%s\n", syspath);
|
dbg(udev, "not a subdir :%s\n", syspath);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -94,12 +94,14 @@ int udevadm_test(struct udev *udev, int argc, char *argv[])
|
|||||||
if (strncmp(syspath, udev_get_sys_path(udev), strlen(udev_get_sys_path(udev))) != 0) {
|
if (strncmp(syspath, udev_get_sys_path(udev), strlen(udev_get_sys_path(udev))) != 0) {
|
||||||
util_strlcpy(filename, udev_get_sys_path(udev), sizeof(filename));
|
util_strlcpy(filename, udev_get_sys_path(udev), sizeof(filename));
|
||||||
util_strlcat(filename, syspath, sizeof(filename));
|
util_strlcat(filename, syspath, sizeof(filename));
|
||||||
syspath = filename;
|
} else {
|
||||||
|
util_strlcpy(filename, syspath, sizeof(filename));
|
||||||
}
|
}
|
||||||
|
util_remove_trailing_chars(filename, '/');
|
||||||
|
|
||||||
dev = udev_device_new_from_syspath(udev, syspath);
|
dev = udev_device_new_from_syspath(udev, filename);
|
||||||
if (dev == NULL) {
|
if (dev == NULL) {
|
||||||
fprintf(stderr, "unable to open device '%s'\n", syspath);
|
fprintf(stderr, "unable to open device '%s'\n", filename);
|
||||||
rc = 2;
|
rc = 2;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user