From: Kay Sievers Date: Fri, 10 Dec 2010 12:27:03 +0000 (+0100) Subject: udevd: always create /dev/{char,block}/$major:$minor X-Git-Tag: 174~288 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2713e6ab0abfc47a54ccbae26be22471aef46b24;p=systemd udevd: always create /dev/{char,block}/$major:$minor --- diff --git a/rules/rules.d/50-udev-default.rules b/rules/rules.d/50-udev-default.rules index c4eb9276..cd745eff 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 92634427..70488c42 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; }