From d4a60c10c0248aa5bea65057ddd29f9b831be20c Mon Sep 17 00:00:00 2001 From: illiliti Date: Sat, 25 Jul 2020 16:41:10 +0300 Subject: [PATCH] use readlink --- udev_device.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/udev_device.c b/udev_device.c index aab14f0..fb6387b 100644 --- a/udev_device.c +++ b/udev_device.c @@ -301,13 +301,17 @@ int udev_device_set_sysattr_value(struct udev_device *udev_device, const char *s static const char *udev_device_read_symlink(struct udev_device *udev_device, const char *name) { char link[PATH_MAX], path[PATH_MAX]; + ssize_t len; snprintf(path, sizeof(path), "%s/%s", udev_device_get_syspath(udev_device), name); - if (!realpath(path, link)) { + len = readlink(path, link, sizeof(link)); + + if (len == -1) { return NULL; } + link[len] = '\0'; return strrchr(link, '/') + 1; }