/* preserve link with correct target, do not replace node of other device */
if (lstat(slink, &stats) == 0) {
if (S_ISBLK(stats.st_mode) || S_ISCHR(stats.st_mode)) {
- struct stat stats2;
-
- log_debug("found existing node instead of symlink '%s'\n", slink);
- if (lstat(node, &stats2) == 0) {
- if ((stats.st_mode & S_IFMT) == (stats2.st_mode & S_IFMT) &&
- stats.st_rdev == stats2.st_rdev && stats.st_ino != stats2.st_ino) {
- log_debug("replace device node '%s' with symlink to our node '%s'\n",
- slink, node);
- } else {
- log_error("device node '%s' already exists, "
- "link to '%s' will not overwrite it\n",
- slink, node);
- goto exit;
- }
- }
+ log_error("conflicting device node '%s' found, link to '%s' will not be created\n", slink, node);
+ goto exit;
} else if (S_ISLNK(stats.st_mode)) {
char buf[UTIL_PATH_SIZE];
int len;
buf[len] = '\0';
if (strcmp(target, buf) == 0) {
log_debug("preserve already existing symlink '%s' to '%s'\n", slink, target);
- label_fix(slink, true);
+ label_fix(slink, true, false);
utimensat(AT_FDCWD, slink, NULL, AT_SYMLINK_NOFOLLOW);
goto exit;
}
const char *target;
char buf[UTIL_PATH_SIZE];
- util_path_encode(slink + strlen(TEST_PREFIX "/dev"), name_enc, sizeof(name_enc));
- util_strscpyl(dirname, sizeof(dirname), TEST_PREFIX "/run/udev/links/", name_enc, NULL);
+ util_path_encode(slink + strlen("/dev"), name_enc, sizeof(name_enc));
+ util_strscpyl(dirname, sizeof(dirname), "/run/udev/links/", name_enc, NULL);
util_strscpyl(filename, sizeof(filename), dirname, "/", udev_device_get_id_filename(dev), NULL);
if (!add && unlink(filename) == 0)
* something else has set a custom context in the meantime.
*/
if (strcmp(udev_device_get_action(dev), "add") == 0)
- label_fix(devnode, true);
+ label_fix(devnode, true, false);
/* always update timestamp when we re-use the node, like on media change events */
utimensat(AT_FDCWD, devnode, NULL, 0);
return;
/* always add /dev/{block,char}/$major:$minor */
- snprintf(filename, sizeof(filename), TEST_PREFIX "/dev/%s/%u:%u",
+ snprintf(filename, sizeof(filename), "/dev/%s/%u:%u",
strcmp(udev_device_get_subsystem(dev), "block") == 0 ? "block" : "char",
major(udev_device_get_devnum(dev)), minor(udev_device_get_devnum(dev)));
node_symlink(udev, udev_device_get_devnode(dev), filename);
link_update(dev, udev_list_entry_get_name(list_entry), 0);
/* remove /dev/{block,char}/$major:$minor */
- snprintf(filename, sizeof(filename), TEST_PREFIX "/dev/%s/%u:%u",
+ snprintf(filename, sizeof(filename), "/dev/%s/%u:%u",
strcmp(udev_device_get_subsystem(dev), "block") == 0 ? "block" : "char",
major(udev_device_get_devnum(dev)), minor(udev_device_get_devnum(dev)));
unlink(filename);