- util_strscpyl(path, sizeof(path), oldname, "/", ent->d_name, NULL);
- s = buf;
- l = util_strpcpy(&s, sizeof(buf), udev_get_sys_path(udev));
- len = readlink(path, s, l);
- if (len <= 0 || len >= (ssize_t)l) {
- unlink(path);
- continue;
- }
+ s = device;
+ l = util_strpcpy(&s, sizeof(device), udev_get_sys_path(udev));
+ len = readlinkat(dirfd(dir), ent->d_name, s, l);
+ if (len <= 0 || len == (ssize_t)l)
+ goto unlink;