summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rules/rules.d/50-udev-default.rules3
-rw-r--r--udev/udev-node.c16
2 files changed, 16 insertions, 3 deletions
diff --git a/rules/rules.d/50-udev-default.rules b/rules/rules.d/50-udev-default.rules
index c4eb9276ad..cd745effe0 100644
--- a/rules/rules.d/50-udev-default.rules
+++ b/rules/rules.d/50-udev-default.rules
@@ -1,8 +1,5 @@
# do not edit this file, it will be overwritten on update
-SUBSYSTEM=="block", SYMLINK{unique}+="block/%M:%m"
-SUBSYSTEM!="block", SYMLINK{unique}+="char/%M:%m"
-
KERNEL=="pty[pqrstuvwxyzabcdef][0123456789abcdef]", GROUP="tty", MODE="0660"
KERNEL=="tty[pqrstuvwxyzabcdef][0123456789abcdef]", GROUP="tty", MODE="0660"
KERNEL=="ptmx", GROUP="tty", MODE="0666"
diff --git a/udev/udev-node.c b/udev/udev-node.c
index 92634427f9..70488c420b 100644
--- a/udev/udev-node.c
+++ b/udev/udev-node.c
@@ -369,6 +369,7 @@ void udev_node_update_old_links(struct udev_device *dev, struct udev_device *dev
int udev_node_add(struct udev_device *dev, mode_t mode, uid_t uid, gid_t gid)
{
struct udev *udev = udev_device_get_udev(dev);
+ char filename[UTIL_PATH_SIZE];
struct udev_list_entry *list_entry;
int err = 0;
@@ -382,6 +383,13 @@ int udev_node_add(struct udev_device *dev, mode_t mode, uid_t uid, gid_t gid)
goto exit;
}
+ /* always add /dev/{block,char}/$major:$minor */
+ snprintf(filename, sizeof(filename), "%s/%s/%u:%u",
+ udev_get_dev_path(udev),
+ 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);
+
/* create/update symlinks, add symlinks to name index */
udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(dev)) {
if (udev_list_entry_get_flags(list_entry))
@@ -401,6 +409,7 @@ int udev_node_remove(struct udev_device *dev)
const char *devnode;
struct stat stats;
struct udev_device *dev_check;
+ char filename[UTIL_PATH_SIZE];
int err = 0;
/* remove/update symlinks, remove symlinks from name index */
@@ -434,6 +443,13 @@ int udev_node_remove(struct udev_device *dev)
err = util_unlink_secure(udev, devnode);
if (err == 0)
util_delete_path(udev, devnode);
+
+ /* remove /dev/{block,char}/$major:$minor */
+ snprintf(filename, sizeof(filename), "%s/%s/%u:%u",
+ udev_get_dev_path(udev),
+ strcmp(udev_device_get_subsystem(dev), "block") == 0 ? "block" : "char",
+ major(udev_device_get_devnum(dev)), minor(udev_device_get_devnum(dev)));
+ unlink(filename);
out:
return err;
}