chiark / gitweb /
remove mknod() logic and rely on 'devtmpfs'
authorKay Sievers <kay.sievers@vrfy.org>
Sun, 1 Jan 2012 03:21:15 +0000 (04:21 +0100)
committerKay Sievers <kay.sievers@vrfy.org>
Sun, 1 Jan 2012 03:21:15 +0000 (04:21 +0100)
28 files changed:
NEWS
extras/cdrom_id/60-cdrom_id.rules
extras/edd_id/61-persistent-storage-edd.rules
extras/mtd_probe/75-probe_mtd.rules
extras/v4l_id/60-persistent-v4l.rules
libudev/libudev-device-private.c
libudev/libudev-device.c
libudev/libudev-private.h
libudev/libudev-util-private.c
libudev/libudev.c
rules/rules.d/60-persistent-storage-tape.rules
rules/rules.d/60-persistent-storage.rules
test/sys/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0/uevent
test/sys/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5/uevent
test/sys/devices/virtual/block/fake!blockdev0/uevent
test/sys/devices/virtual/misc/misc-fake1/uevent
test/sys/devices/virtual/misc/misc-fake89999/uevent
test/sys/devices/virtual/tty/console/uevent
test/sys/devices/virtual/tty/tty0/uevent
test/sys/devices/virtual/tty/tty33/uevent
test/udev-test.pl.in
udev/test-udev.c
udev/udev-event.c
udev/udev-node.c
udev/udev-rules.c
udev/udev.h
udev/udev.xml
udev/udevd.c

diff --git a/NEWS b/NEWS
index b052257c332ace211fa3fe1f35cf27199f1ab47a..f65ae0d7b097ae21a1915c130a37d66969466219 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,9 @@
 udev 175
 ========
+The 'devtmpfs' filesystem is required now, udev will not create or delete
+device nodes anymore, it only adjusts permissions and ownership of device
+nodes and maintains additional symlinks.
+
 A writable /run directory (tmpfs) is required now for a fully functional
 udev.
 
@@ -26,7 +30,7 @@ All built-in tools can be listed and tested with 'udevadm test-builtin'.
 The 'udevadm control --reload-rules' option has been renamed to '--reload'.
 It reloads the kernel module configuration.
 
-The systemd socket files use PassCred=yes, which requires systemd
+The systemd socket files use PassCredentials=yes, which requires systemd
 version 38.
 
 The udev build system only creates a .xz tarball now.
index 896af3482562a50be6bcf1091599d00b366e330f..353f522b0b0bbe22eb0fdf0d65ff7bf8e37a5f8d 100644 (file)
@@ -9,10 +9,10 @@ ENV{DEVTYPE}!="disk", GOTO="cdrom_end"
 KERNEL=="sr[0-9]*", ENV{ID_CDROM}="1"
 
 # media eject button pressed
-ENV{DISK_EJECT_REQUEST}=="?*", RUN+="cdrom_id --eject-media $tempnode", GOTO="cdrom_end"
+ENV{DISK_EJECT_REQUEST}=="?*", RUN+="cdrom_id --eject-media $devnode", GOTO="cdrom_end"
 
 # import device and media properties and lock tray to
 # enable the receiving of media eject button events
-IMPORT{program}="cdrom_id --lock-media $tempnode"
+IMPORT{program}="cdrom_id --lock-media $devnode"
 
 LABEL="cdrom_end"
index 1ab1be347e22876acd51313a9a9ac0fd1c809230..6b4fb8ecfea53f9b511f215cfbca33ec8e4cc54c 100644 (file)
@@ -5,7 +5,7 @@ SUBSYSTEM!="block", GOTO="persistent_storage_edd_end"
 KERNEL!="sd*|hd*|cciss*", GOTO="persistent_storage_edd_end"
 
 # BIOS Enhanced Disk Device
-ENV{DEVTYPE}=="disk", IMPORT{program}="edd_id --export $tempnode"
+ENV{DEVTYPE}=="disk", IMPORT{program}="edd_id --export $devnode"
 ENV{DEVTYPE}=="disk", ENV{ID_EDD}=="?*", SYMLINK+="disk/by-id/edd-$env{ID_EDD}"
 ENV{DEVTYPE}=="partition", ENV{ID_EDD}=="?*", SYMLINK+="disk/by-id/edd-$env{ID_EDD}-part%n"
 
index 6b0c1c27e6ccb775f2320b2a02cd74c9e93dd172..c0e08397858a98cc94498e73cfa079d14fcb57aa 100644 (file)
@@ -2,7 +2,7 @@
 
 ACTION!="add", GOTO="mtd_probe_end"
 
-KERNEL=="mtd*ro", IMPORT{program}="mtd_probe $tempnode"
+KERNEL=="mtd*ro", IMPORT{program}="mtd_probe $devnode"
 KERNEL=="mtd*ro", ENV{MTD_FTL}=="smartmedia", IMPORT{builtin}="kmod load sm_ftl"
 
 LABEL="mtd_probe_end"
index edfd8447535782d3b71fc34c8916f748a9ddb050..93c5ee8c276abf363be6e4b6c8fb1789d7ac1d52 100644 (file)
@@ -4,7 +4,7 @@ ACTION=="remove", GOTO="persistent_v4l_end"
 SUBSYSTEM!="video4linux", GOTO="persistent_v4l_end"
 ENV{MAJOR}=="", GOTO="persistent_v4l_end"
 
-IMPORT{program}="v4l_id $tempnode"
+IMPORT{program}="v4l_id $devnode"
 
 SUBSYSTEMS=="usb", IMPORT{builtin}="usb_id"
 KERNEL=="video*", ENV{ID_SERIAL}=="?*", SYMLINK+="v4l/by-id/$env{ID_BUS}-$env{ID_SERIAL}-video-index$attr{index}"
index b78b6c9553503b61e0c9aa07731c6ce2b894b2da..086491930106b3cb4015c92d5c170e28c594cd67 100644 (file)
@@ -78,7 +78,6 @@ int udev_device_tag_index(struct udev_device *dev, struct udev_device *dev_old,
 
 static bool device_has_info(struct udev_device *udev_device)
 {
-       struct udev *udev = udev_device_get_udev(udev_device);
        struct udev_list_entry *list_entry;
 
        if (udev_device_get_devlinks_list_entry(udev_device) != NULL)
@@ -90,12 +89,6 @@ static bool device_has_info(struct udev_device *udev_device)
                        return true;
        if (udev_device_get_tags_list_entry(udev_device) != NULL)
                return true;
-       if (udev_device_get_devnode(udev_device) != NULL && udev_device_get_knodename(udev_device) != NULL) {
-               size_t devlen = strlen(udev_get_dev_path(udev))+1;
-
-               if (strcmp(&udev_device_get_devnode(udev_device)[devlen], udev_device_get_knodename(udev_device)) != 0)
-                       return true;
-       }
        if (udev_device_get_watch_handle(udev_device) >= 0)
                return true;
        return false;
@@ -142,20 +135,22 @@ int udev_device_update_db(struct udev_device *udev_device)
                fchmod(fileno(f), 01644);
 
        if (has_info) {
-               size_t devlen = strlen(udev_get_dev_path(udev))+1;
                struct udev_list_entry *list_entry;
 
-               if (udev_device_get_devnode(udev_device) != NULL) {
-                       fprintf(f, "N:%s\n", &udev_device_get_devnode(udev_device)[devlen]);
+               if (major(udev_device_get_devnum(udev_device)) > 0) {
+                       size_t devlen = strlen(udev_get_dev_path(udev))+1;
+
                        udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(udev_device))
                                fprintf(f, "S:%s\n", &udev_list_entry_get_name(list_entry)[devlen]);
+                       if (udev_device_get_devlink_priority(udev_device) != 0)
+                               fprintf(f, "L:%i\n", udev_device_get_devlink_priority(udev_device));
+                       if (udev_device_get_watch_handle(udev_device) >= 0)
+                               fprintf(f, "W:%i\n", udev_device_get_watch_handle(udev_device));
                }
-               if (udev_device_get_devlink_priority(udev_device) != 0)
-                       fprintf(f, "L:%i\n", udev_device_get_devlink_priority(udev_device));
-               if (udev_device_get_watch_handle(udev_device) >= 0)
-                       fprintf(f, "W:%i\n", udev_device_get_watch_handle(udev_device));
+
                if (udev_device_get_usec_initialized(udev_device) > 0)
                        fprintf(f, "I:%llu\n", udev_device_get_usec_initialized(udev_device));
+
                udev_list_entry_foreach(list_entry, udev_device_get_properties_list_entry(udev_device)) {
                        if (!udev_list_entry_get_num(list_entry))
                                continue;
@@ -163,6 +158,7 @@ int udev_device_update_db(struct udev_device *udev_device)
                                udev_list_entry_get_name(list_entry),
                                udev_list_entry_get_value(list_entry));
                }
+
                udev_list_entry_foreach(list_entry, udev_device_get_tags_list_entry(udev_device))
                        fprintf(f, "G:%s\n", udev_list_entry_get_name(list_entry));
        }
index 28df7a2a11e7c110d75d4c6bffc6ec66e365b8a3..e5950bb4b13bb7176626fc10b64e1c01b6887037 100644 (file)
@@ -57,7 +57,6 @@ struct udev_device {
        char *driver;
        char *action;
        char *devpath_old;
-       char *knodename;
        char *id_filename;
        char **envp;
        char *monitor_buf;
@@ -161,23 +160,6 @@ static int udev_device_set_devnum(struct udev_device *udev_device, dev_t devnum)
        return 0;
 }
 
-const char *udev_device_get_knodename(struct udev_device *udev_device)
-{
-       return udev_device->knodename;
-}
-
-static int udev_device_set_knodename(struct udev_device *udev_device, const char *knodename)
-{
-       free(udev_device->knodename);
-       udev_device->knodename = strdup(knodename);
-       if (udev_device->knodename == NULL)
-               return -ENOMEM;
-       /* do not overwrite the udev property with the kernel property */
-       if (udev_device->devnode == NULL)
-               udev_device_add_property(udev_device, "DEVNAME", udev_device->knodename);
-       return 0;
-}
-
 const char *udev_device_get_devpath_old(struct udev_device *udev_device)
 {
        return udev_device->devpath_old;
@@ -381,10 +363,7 @@ void udev_device_add_property_from_string_parse(struct udev_device *udev_device,
        } else if (strncmp(property, "DEVTYPE=", 8) == 0) {
                udev_device_set_devtype(udev_device, &property[8]);
        } else if (strncmp(property, "DEVNAME=", 8) == 0) {
-               if (property[8] == '/')
-                       udev_device_set_devnode(udev_device, &property[8]);
-               else
-                       udev_device_set_knodename(udev_device, &property[8]);
+               udev_device_set_devnode(udev_device, &property[8]);
        } else if (strncmp(property, "DEVLINKS=", 9) == 0) {
                char devlinks[UTIL_PATH_SIZE];
                char *slink;
@@ -516,10 +495,6 @@ int udev_device_read_db(struct udev_device *udev_device, const char *dbfile)
                line[len-1] = '\0';
                val = &line[2];
                switch(line[0]) {
-               case 'N':
-                       util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev_device->udev), "/", val, NULL);
-                       udev_device_set_devnode(udev_device, filename);
-                       break;
                case 'S':
                        util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev_device->udev), "/", val, NULL);
                        udev_device_add_devlink(udev_device, filename, 0);
@@ -582,7 +557,7 @@ int udev_device_read_uevent_file(struct udev_device *udev_device)
                else if (strncmp(line, "IFINDEX=", 8) == 0)
                        udev_device_set_ifindex(udev_device, strtoull(&line[8], NULL, 10));
                else if (strncmp(line, "DEVNAME=", 8) == 0)
-                       udev_device_set_knodename(udev_device, &line[8]);
+                       udev_device_set_devnode(udev_device, &line[8]);
                else if (strncmp(line, "DEVMODE=", 8) == 0)
                        udev_device->devnode_mode = strtoul(&line[8], NULL, 8);
 
@@ -1073,7 +1048,6 @@ UDEV_EXPORT void udev_device_unref(struct udev_device *udev_device)
        free(udev_device->action);
        free(udev_device->driver);
        free(udev_device->devpath_old);
-       free(udev_device->knodename);
        free(udev_device->id_filename);
        free(udev_device->envp);
        free(udev_device->monitor_buf);
@@ -1152,21 +1126,10 @@ UDEV_EXPORT const char *udev_device_get_devnode(struct udev_device *udev_device)
 {
        if (udev_device == NULL)
                return NULL;
-       if (!udev_device->info_loaded) {
-               udev_device_read_uevent_file(udev_device);
-               udev_device_read_db(udev_device, NULL);
-       }
-
-       /* we might get called before we handled an event and have a db, use the kernel-provided name */
-       if (udev_device->devnode == NULL && udev_device_get_knodename(udev_device) != NULL) {
-               char filename[UTIL_NAME_SIZE];
-
-               util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev_device->udev), "/",
-                             udev_device_get_knodename(udev_device), NULL);
-               udev_device_set_devnode(udev_device, filename);
+       if (udev_device->devnode != NULL)
                return udev_device->devnode;
-       }
-
+       if (!udev_device->info_loaded)
+               udev_device_read_uevent_file(udev_device);
        return udev_device->devnode;
 }
 
@@ -1522,7 +1485,12 @@ int udev_device_set_syspath(struct udev_device *udev_device, const char *syspath
 int udev_device_set_devnode(struct udev_device *udev_device, const char *devnode)
 {
        free(udev_device->devnode);
-       udev_device->devnode = strdup(devnode);
+       if (devnode[0] != '/') {
+               if (asprintf(&udev_device->devnode, "%s/%s", udev_get_dev_path(udev_device->udev), devnode) < 0)
+                       udev_device->devnode = NULL;
+       } else {
+               udev_device->devnode = strdup(devnode);
+       }
        if (udev_device->devnode == NULL)
                return -ENOMEM;
        udev_device_add_property(udev_device, "DEVNAME", udev_device->devnode);
index b86f6a837836e48e1e8cc06b372d3aabf6bfb39d..83976698a9b3361bd435c2da885a38504946a22d 100644 (file)
@@ -83,7 +83,6 @@ int udev_device_read_db(struct udev_device *udev_device, const char *dbfile);
 int udev_device_read_uevent_file(struct udev_device *udev_device);
 int udev_device_set_action(struct udev_device *udev_device, const char *action);
 const char *udev_device_get_devpath_old(struct udev_device *udev_device);
-const char *udev_device_get_knodename(struct udev_device *udev_device);
 const char *udev_device_get_id_filename(struct udev_device *udev_device);
 void udev_device_set_is_initialized(struct udev_device *udev_device);
 int udev_device_add_tag(struct udev_device *udev_device, const char *tag);
@@ -187,7 +186,6 @@ uint64_t util_string_bloom64(const char *str);
 int util_create_path(struct udev *udev, const char *path);
 int util_create_path_selinux(struct udev *udev, const char *path);
 int util_delete_path(struct udev *udev, const char *path);
-int util_unlink_secure(struct udev *udev, const char *filename);
 uid_t util_lookup_user(struct udev *udev, const char *user);
 gid_t util_lookup_group(struct udev *udev, const char *group);
 int util_resolve_subsys_kernel(struct udev *udev, const char *string,
index 2d7f8dc758f5bd595e304db9198b2800858ad2ba..015e6d58625221c91c062f3ccdf7dc05476c9ed6 100644 (file)
@@ -113,23 +113,6 @@ int util_delete_path(struct udev *udev, const char *path)
        return err;
 }
 
-/* Reset permissions on the device node, before unlinking it to make sure,
- * that permissions of possible hard links will be removed too.
- */
-int util_unlink_secure(struct udev *udev, const char *filename)
-{
-       int err;
-
-       chown(filename, 0, 0);
-       chmod(filename, 0000);
-       err = unlink(filename);
-       if (errno == ENOENT)
-               err = 0;
-       if (err)
-               err(udev, "unlink(%s) failed: %m\n", filename);
-       return err;
-}
-
 uid_t util_lookup_user(struct udev *udev, const char *user)
 {
        char *endptr;
index 93f2d8f1b5d6d9f58553629e4e9d1ae898430224..ca2ac5d03069fe0c4322faa3f7ba5ea6ea3a220f 100644 (file)
@@ -223,6 +223,10 @@ UDEV_EXPORT struct udev *udev_new(void)
                                set_value(&udev->run_path, val);
                                continue;
                        }
+                       if (strcmp(key, "udev_sys") == 0) {
+                               set_value(&udev->sys_path, val);
+                               continue;
+                       }
                        if (strcmp(key, "udev_rules") == 0) {
                                set_value(&udev->rules_path[0], val);
                                udev->rules_path_count = 1;
@@ -237,18 +241,6 @@ UDEV_EXPORT struct udev *udev_new(void)
        if (env != NULL)
                udev_set_log_priority(udev, util_log_priority(env));
 
-       env = getenv("UDEV_ROOT");
-       if (env != NULL) {
-               set_value(&udev->dev_path, env);
-               udev_add_property(udev, "UDEV_ROOT", udev->dev_path);
-       }
-
-       env = getenv("SYSFS_PATH");
-       if (env != NULL) {
-               set_value(&udev->sys_path, env);
-               udev_add_property(udev, "SYSFS_PATH", udev->sys_path);
-       }
-
        /* set defaults */
        if (udev->dev_path == NULL)
                if (set_value(&udev->dev_path, "/dev") == NULL)
@@ -401,8 +393,8 @@ int udev_get_rules_path(struct udev *udev, char **path[], unsigned long long *st
  * @udev: udev library context
  *
  * Retrieve the sysfs mount point. The default is "/sys". For
- * testing purposes, it can be overridden with the environment
- * variable SYSFS_PATH.
+ * testing purposes, it can be overridden with udev_sys=
+ * in the udev configuration file.
  *
  * Returns: the sys mount point
  **/
index b1a64cee12bc54745ed99af2097e08568e11bae7..f2eabd92a84cbd6634ddf6076ca9ced2733c944d 100644 (file)
@@ -5,7 +5,7 @@
 ACTION=="remove", GOTO="persistent_storage_tape_end"
 
 # type 8 devices are "Medium Changers"
-SUBSYSTEM=="scsi_generic", SUBSYSTEMS=="scsi", ATTRS{type}=="8", IMPORT{program}="scsi_id --sg-version=3 --export --whitelisted -d $tempnode", \
+SUBSYSTEM=="scsi_generic", SUBSYSTEMS=="scsi", ATTRS{type}=="8", IMPORT{program}="scsi_id --sg-version=3 --export --whitelisted -d $devnode", \
   SYMLINK+="tape/by-id/scsi-$env{ID_SERIAL}"
 
 SUBSYSTEM!="scsi_tape", GOTO="persistent_storage_tape_end"
index 9b340334f422f517ab59fc2a60a32408e2bb7d22..b7da8b8bc22e88c4c345963aebae9d5fbb79dcdd 100644 (file)
@@ -27,20 +27,20 @@ KERNEL=="vd*[!0-9]", ATTRS{serial}=="?*", ENV{ID_SERIAL}="$attr{serial}", SYMLIN
 KERNEL=="vd*[0-9]", ATTRS{serial}=="?*", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/virtio-$env{ID_SERIAL}-part%n"
 
 # ATA devices with their own "ata" kernel subsystem
-KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="ata", IMPORT{program}="ata_id --export $tempnode"
+KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="ata", IMPORT{program}="ata_id --export $devnode"
 # ATA devices using the "scsi" subsystem
-KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", IMPORT{program}="ata_id --export $tempnode"
+KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", IMPORT{program}="ata_id --export $devnode"
 # ATA/ATAPI devices (SPC-3 or later) using the "scsi" subsystem
-KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="scsi", ATTRS{type}=="5", ATTRS{scsi_level}=="[6-9]*", IMPORT{program}="ata_id --export $tempnode"
+KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="scsi", ATTRS{type}=="5", ATTRS{scsi_level}=="[6-9]*", IMPORT{program}="ata_id --export $devnode"
 
 # Run ata_id on non-removable USB Mass Storage (SATA/PATA disks in enclosures)
-KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", ATTR{removable}=="0", SUBSYSTEMS=="usb", IMPORT{program}="ata_id --export $tempnode"
+KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", ATTR{removable}=="0", SUBSYSTEMS=="usb", IMPORT{program}="ata_id --export $devnode"
 # Otherwise fall back to using usb_id for USB devices
 KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="usb", IMPORT{builtin}="usb_id"
 
 # scsi devices
-KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", IMPORT{program}="scsi_id --export --whitelisted -d $tempnode", ENV{ID_BUS}="scsi"
-KERNEL=="cciss*", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}!="?*", IMPORT{program}="scsi_id --export --whitelisted -d $tempnode", ENV{ID_BUS}="cciss"
+KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", IMPORT{program}="scsi_id --export --whitelisted -d $devnode", ENV{ID_BUS}="scsi"
+KERNEL=="cciss*", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}!="?*", IMPORT{program}="scsi_id --export --whitelisted -d $devnode", ENV{ID_BUS}="cciss"
 KERNEL=="sd*|sr*|cciss*", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}"
 KERNEL=="sd*|cciss*", ENV{DEVTYPE}=="partition", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}-part%n"
 
@@ -49,7 +49,7 @@ KERNEL=="sd*[!0-9]|sr*", ATTRS{ieee1394_id}=="?*", SYMLINK+="disk/by-id/ieee1394
 KERNEL=="sd*[0-9]", ATTRS{ieee1394_id}=="?*", SYMLINK+="disk/by-id/ieee1394-$attr{ieee1394_id}-part%n"
 
 # scsi compat links for ATA devices
-KERNEL=="sd*[!0-9]", ENV{ID_BUS}=="ata", PROGRAM="scsi_id --whitelisted --replace-whitespace -p0x80 -d$tempnode", RESULT=="?*", ENV{ID_SCSI_COMPAT}="$result", SYMLINK+="disk/by-id/scsi-$env{ID_SCSI_COMPAT}"
+KERNEL=="sd*[!0-9]", ENV{ID_BUS}=="ata", PROGRAM="scsi_id --whitelisted --replace-whitespace -p0x80 -d $devnode", RESULT=="?*", ENV{ID_SCSI_COMPAT}="$result", SYMLINK+="disk/by-id/scsi-$env{ID_SCSI_COMPAT}"
 KERNEL=="sd*[0-9]", ENV{ID_SCSI_COMPAT}=="?*", SYMLINK+="disk/by-id/scsi-$env{ID_SCSI_COMPAT}-part%n"
 
 KERNEL=="mmcblk[0-9]", SUBSYSTEMS=="mmc", ATTRS{name}=="?*", ATTRS{serial}=="?*", ENV{ID_NAME}="$attr{name}", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/mmc-$env{ID_NAME}_$env{ID_SERIAL}"
index 70997d361bd1b40bff34635a58c977d6d753e71b..6c472ca852992e15986e0042c715a1445bc28dd4 100644 (file)
@@ -1,3 +1,4 @@
 MAJOR=7
 MINOR=0
 DEVTYPE=disk
+DEVNAME=fake/blockdev0
index 79caac10ef829c4383c625d2bb7e7e5c7fa846d6..67faa81eb247b988528b4eb7b3b1c43a4f68f1bd 100644 (file)
@@ -1,2 +1,4 @@
 MAJOR=4095
 MINOR=1
+DEVNAME=misc-fake1
+
index 10915df8719163c0ae913179b3d58362075815c5..53bb34ad99ea7b3a393f145fbdfae98edbe5ca40 100644 (file)
@@ -1,2 +1,3 @@
 MAJOR=4095
 MINOR=89999
+DEVNAME=misc-fake89999
index 0eaf8b9eb00e954e2fd8d5f4bf09d490fa077643..71aad75b126f6bf02fbb1d80d1289048161f0f01 100644 (file)
@@ -1,2 +1,3 @@
 MAJOR=5
 MINOR=1
+DEVNAME=console
index 11692def2c2ca5572781559267bb39da2e38e459..f338919a3bc3ed1d3a84a355fbca5dc4f3841a86 100644 (file)
@@ -1,2 +1,3 @@
 MAJOR=4
 MINOR=0
+DEVNAME=tty0
index 70a82684947ed0f4049530e22fbf02fff18a8d87..737826b96ba705574f520eed1edd295f0966e92d 100644 (file)
@@ -1,2 +1,3 @@
 MAJOR=4
 MINOR=33
+DEVNAME=tty33
index 0befc7b530a033837edce67ccfc20d02ba750ef9..05055013d5d148b838e590eaa19c86f9bbd5585c 100755 (executable)
@@ -25,14 +25,13 @@ my $sysfs           = "test/sys/";
 my $udev_bin           = "udev/test-udev";
 my $valgrind           = 0;
 my $udev_bin_valgrind  = "valgrind --tool=memcheck --leak-check=yes --quiet $udev_bin";
-my $udev_root          = "udev-root/";
+my $udev_root          = "udev-root";
 my $udev_conf          = "udev-test.conf";
 my $udev_rules         = "udev-test.rules";
 
 my @tests = (
        {
                desc            => "no rules",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "sda" ,
                exp_rem_error   => "yes",
@@ -42,7 +41,6 @@ EOF
        },
        {
                desc            => "label test of scsi disc",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "boot_disk" ,
                rules           => <<EOF
@@ -52,7 +50,6 @@ EOF
        },
        {
                desc            => "label test of scsi disc",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "boot_disk" ,
                rules           => <<EOF
@@ -62,7 +59,6 @@ EOF
        },
        {
                desc            => "label test of scsi disc",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "boot_disk" ,
                rules           => <<EOF
@@ -72,7 +68,6 @@ EOF
        },
        {
                desc            => "label test of scsi partition",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
                exp_name        => "boot_disk1" ,
                rules           => <<EOF
@@ -81,7 +76,6 @@ EOF
        },
        {
                desc            => "label test of pattern match",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
                exp_name        => "boot_disk1" ,
                rules           => <<EOF
@@ -93,7 +87,6 @@ EOF
        },
        {
                desc            => "label test of multiple sysfs files",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
                exp_name        => "boot_disk1" ,
                rules           => <<EOF
@@ -103,7 +96,6 @@ EOF
        },
        {
                desc            => "label test of max sysfs files (skip invalid rule)",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
                exp_name        => "boot_disk1" ,
                rules           => <<EOF
@@ -113,7 +105,6 @@ EOF
        },
        {
                desc            => "catch device by *",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "modem/0" ,
                rules           => <<EOF
@@ -122,7 +113,6 @@ EOF
        },
        {
                desc            => "catch device by * - take 2",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "modem/0" ,
                rules           => <<EOF
@@ -132,7 +122,6 @@ EOF
        },
        {
                desc            => "catch device by ?",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "modem/0" ,
                rules           => <<EOF
@@ -143,7 +132,6 @@ EOF
        },
        {
                desc            => "catch device by character class",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "modem/0" ,
                rules           => <<EOF
@@ -154,7 +142,6 @@ EOF
        },
        {
                desc            => "replace kernel name",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "modem" ,
                rules           => <<EOF
@@ -163,7 +150,6 @@ EOF
        },
        {
                desc            => "Handle comment lines in config file (and replace kernel name)",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "modem" ,
                rules           => <<EOF
@@ -174,7 +160,6 @@ EOF
        },
        {
                desc            => "Handle comment lines in config file with whitespace (and replace kernel name)",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "modem" ,
                rules           => <<EOF
@@ -185,7 +170,6 @@ EOF
        },
        {
                desc            => "Handle whitespace only lines (and replace kernel name)",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "whitespace" ,
                rules           => <<EOF
@@ -201,7 +185,6 @@ EOF
        },
        {
                desc            => "Handle empty lines in config file (and replace kernel name)",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "modem" ,
                rules           => <<EOF
@@ -212,7 +195,6 @@ EOF
        },
        {
                desc            => "Handle backslashed multi lines in config file (and replace kernel name)",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "modem" ,
                rules           => <<EOF
@@ -223,7 +205,6 @@ EOF
        },
        {
                desc            => "preserve backslashes, if they are not for a newline",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "aaa",
                rules           => <<EOF
@@ -232,7 +213,6 @@ EOF
        },
        {
                desc            => "Handle stupid backslashed multi lines in config file (and replace kernel name)",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "modem" ,
                rules           => <<EOF
@@ -251,7 +231,6 @@ EOF
        },
        {
                desc            => "subdirectory handling",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "sub/direct/ory/modem" ,
                rules           => <<EOF
@@ -260,7 +239,6 @@ EOF
        },
        {
                desc            => "parent device name match of scsi partition",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
                exp_name        => "first_disk5" ,
                rules           => <<EOF
@@ -269,7 +247,6 @@ EOF
        },
        {
                desc            => "test substitution chars",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
                exp_name        => "Major:8:minor:5:kernelnumber:5:id:0:0:0:0" ,
                rules           => <<EOF
@@ -278,7 +255,6 @@ EOF
        },
        {
                desc            => "import of shell-value file",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "subdir/err/node" ,
                rules           => <<EOF
@@ -288,7 +264,6 @@ EOF
        },
        {
                desc            => "import of shell-value returned from program",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "node12345678",
                rules           => <<EOF
@@ -298,7 +273,6 @@ EOF
        },
        {
                desc            => "sustitution of sysfs value (%s{file})",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "disk-ATA-sda" ,
                rules           => <<EOF
@@ -308,7 +282,6 @@ EOF
        },
        {
                desc            => "program result substitution",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
                exp_name        => "special-device-5" ,
                not_exp_name    => "not" ,
@@ -319,7 +292,6 @@ EOF
        },
        {
                desc            => "program result substitution (newline removal)",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
                exp_name        => "newline_removed" ,
                rules           => <<EOF
@@ -328,7 +300,6 @@ EOF
        },
        {
                desc            => "program result substitution",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
                exp_name        => "test-0:0:0:0" ,
                rules           => <<EOF
@@ -337,7 +308,6 @@ EOF
        },
        {
                desc            => "program with lots of arguments",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
                exp_name        => "foo9" ,
                rules           => <<EOF
@@ -346,7 +316,6 @@ EOF
        },
        {
                desc            => "program with subshell",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
                exp_name        => "bar9" ,
                rules           => <<EOF
@@ -355,7 +324,6 @@ EOF
        },
        {
                desc            => "program arguments combined with apostrophes",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
                exp_name        => "foo7" ,
                rules           => <<EOF
@@ -364,7 +332,6 @@ EOF
        },
        {
                desc            => "characters before the %c{N} substitution",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
                exp_name        => "my-foo9" ,
                rules           => <<EOF
@@ -373,7 +340,6 @@ EOF
        },
        {
                desc            => "substitute the second to last argument",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
                exp_name        => "my-foo8" ,
                rules           => <<EOF
@@ -382,7 +348,6 @@ EOF
        },
        {
                desc            => "test substitution by variable name",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
                exp_name        => "Major:8-minor:5-kernelnumber:5-id:0:0:0:0",
                rules           => <<EOF
@@ -391,7 +356,6 @@ EOF
        },
        {
                desc            => "test substitution by variable name 2",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
                exp_name        => "Major:8-minor:5-kernelnumber:5-id:0:0:0:0",
                rules           => <<EOF
@@ -400,7 +364,6 @@ EOF
        },
        {
                desc            => "test substitution by variable name 3",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
                exp_name        => "850:0:0:05" ,
                rules           => <<EOF
@@ -409,7 +372,6 @@ EOF
        },
        {
                desc            => "test substitution by variable name 4",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
                exp_name        => "855" ,
                rules           => <<EOF
@@ -418,7 +380,6 @@ EOF
        },
        {
                desc            => "test substitution by variable name 5",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
                exp_name        => "8550:0:0:0" ,
                rules           => <<EOF
@@ -427,7 +388,6 @@ EOF
        },
        {
                desc            => "non matching SUBSYSTEMS for device with no parent",
-               subsys          => "tty",
                devpath         => "/devices/virtual/tty/console",
                exp_name        => "TTY",
                rules           => <<EOF
@@ -437,7 +397,6 @@ EOF
        },
        {
                desc            => "non matching SUBSYSTEMS",
-               subsys          => "tty",
                devpath         => "/devices/virtual/tty/console",
                exp_name        => "TTY" ,
                rules           => <<EOF
@@ -447,7 +406,6 @@ EOF
        },
        {
                desc            => "ATTRS match",
-               subsys          => "tty",
                devpath         => "/devices/virtual/tty/console",
                exp_name        => "foo" ,
                rules           => <<EOF
@@ -457,7 +415,6 @@ EOF
        },
        {
                desc            => "ATTR (empty file)",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "empty" ,
                rules           => <<EOF
@@ -469,7 +426,6 @@ EOF
        },
        {
                desc            => "ATTR (non-existent file)",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "non-existent" ,
                rules           => <<EOF
@@ -483,7 +439,6 @@ EOF
        },
        {
                desc            => "program and bus type match",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "scsi-0:0:0:0" ,
                rules           => <<EOF
@@ -494,7 +449,6 @@ EOF
        },
        {
                desc            => "sysfs parent hierarchy",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "modem" ,
                rules           => <<EOF
@@ -503,7 +457,6 @@ EOF
        },
        {
                desc            => "name test with ! in the name",
-               subsys          => "block",
                devpath         => "/devices/virtual/block/fake!blockdev0",
                exp_name        => "is/a/fake/blockdev0" ,
                rules           => <<EOF
@@ -514,7 +467,6 @@ EOF
        },
        {
                desc            => "name test with ! in the name, but no matching rule",
-               subsys          => "block",
                devpath         => "/devices/virtual/block/fake!blockdev0",
                exp_name        => "fake/blockdev0" ,
                exp_rem_error   => "yes",
@@ -524,7 +476,6 @@ EOF
        },
        {
                desc            => "KERNELS rule",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "scsi-0:0:0:0",
                rules           => <<EOF
@@ -537,7 +488,6 @@ EOF
        },
        {
                desc            => "KERNELS wildcard all",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "scsi-0:0:0:0",
                rules           => <<EOF
@@ -550,7 +500,6 @@ EOF
        },
        {
                desc            => "KERNELS wildcard partial",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "scsi-0:0:0:0",
                rules           => <<EOF
@@ -560,7 +509,6 @@ EOF
        },
        {
                desc            => "KERNELS wildcard partial 2",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "scsi-0:0:0:0",
                rules           => <<EOF
@@ -570,7 +518,6 @@ EOF
        },
        {
                desc            => "substitute attr with link target value (first match)",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "driver-is-sd",
                rules           => <<EOF
@@ -579,7 +526,6 @@ EOF
        },
        {
                desc            => "substitute attr with link target value (currently selected device)",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "driver-is-ahci",
                rules           => <<EOF
@@ -588,7 +534,6 @@ EOF
        },
        {
                desc            => "ignore ATTRS attribute whitespace",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "ignored",
                rules           => <<EOF
@@ -597,7 +542,6 @@ EOF
        },
        {
                desc            => "do not ignore ATTRS attribute whitespace",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "matched-with-space",
                rules           => <<EOF
@@ -607,7 +551,6 @@ EOF
        },
        {
                desc            => "permissions USER=bad GROUP=name",
-               subsys          => "tty",
                devpath         => "/devices/virtual/tty/tty33",
                exp_name        => "tty33",
                exp_perms       => "0:0:0600",
@@ -617,7 +560,6 @@ EOF
        },
        {
                desc            => "permissions OWNER=5000",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "node",
                exp_perms       => "5000::0600",
@@ -627,7 +569,6 @@ EOF
        },
        {
                desc            => "permissions GROUP=100",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "node",
                exp_perms       => ":100:0660",
@@ -637,7 +578,6 @@ EOF
        },
        {
                desc            => "textual user id",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "node",
                exp_perms       => "nobody::0600",
@@ -647,7 +587,6 @@ EOF
        },
        {
                desc            => "textual group id",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "node",
                exp_perms       => ":daemon:0660",
@@ -657,7 +596,6 @@ EOF
        },
        {
                desc            => "textual user/group id",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "node",
                exp_perms       => "root:mail:0660",
@@ -667,7 +605,6 @@ EOF
        },
        {
                desc            => "permissions MODE=0777",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "node",
                exp_perms       => "::0777",
@@ -677,7 +614,6 @@ EOF
        },
        {
                desc            => "permissions OWNER=5000 GROUP=100 MODE=0777",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "node",
                exp_perms       => "5000:100:0777",
@@ -687,7 +623,6 @@ EOF
        },
        {
                desc            => "permissions OWNER to 5000",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "ttyACM0",
                exp_perms       => "5000::",
@@ -697,7 +632,6 @@ EOF
        },
        {
                desc            => "permissions GROUP to 100",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "ttyACM0",
                exp_perms       => ":100:0660",
@@ -707,7 +641,6 @@ EOF
        },
        {
                desc            => "permissions MODE to 0060",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "ttyACM0",
                exp_perms       => "::0060",
@@ -717,7 +650,6 @@ EOF
        },
        {
                desc            => "permissions OWNER, GROUP, MODE",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "ttyACM0",
                exp_perms       => "5000:100:0777",
@@ -727,7 +659,6 @@ EOF
        },
        {
                desc            => "permissions only rule",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "ttyACM0",
                exp_perms       => "5000:100:0777",
@@ -739,7 +670,6 @@ EOF
        },
        {
                desc            => "multiple permissions only rule",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "ttyACM0",
                exp_perms       => "3000:4000:0777",
@@ -753,7 +683,6 @@ EOF
        },
        {
                desc            => "permissions only rule with override at SYMLINK+ rule",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "ttyACM0",
                exp_perms       => "3000:8000:0777",
@@ -767,7 +696,6 @@ EOF
        },
        {
                desc            => "major/minor number test",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "node",
                exp_majorminor  => "8:0",
@@ -777,7 +705,6 @@ EOF
        },
        {
                desc            => "big major number test",
-               subsys          => "misc",
                devpath         => "/devices/virtual/misc/misc-fake1",
                exp_name        => "node",
                exp_majorminor  => "4095:1",
@@ -787,7 +714,6 @@ EOF
        },
        {
                desc            => "big major and big minor number test",
-               subsys          => "misc",
                devpath         => "/devices/virtual/misc/misc-fake89999",
                exp_name        => "node",
                exp_majorminor  => "4095:89999",
@@ -797,7 +723,6 @@ EOF
        },
        {
                desc            => "multiple symlinks with format char",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "symlink2-ttyACM0",
                rules           => <<EOF
@@ -806,7 +731,6 @@ EOF
        },
        {
                desc            => "multiple symlinks with a lot of s p a c e s",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "one",
                not_exp_name    => " ",
@@ -816,38 +740,14 @@ EOF
        },
        {
                desc            => "symlink creation (same directory)",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "modem0",
                rules           => <<EOF
 KERNEL=="ttyACM[0-9]*", SYMLINK+="ttyACM%n", SYMLINK="modem%n"
-EOF
-       },
-       {
-               desc            => "symlink creation (relative link forward)",
-               subsys          => "block",
-               devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda6",
-               exp_name        => "1/2/symlink" ,
-               exp_target      => "a/b/node",
-               exp_rem_error   => "yes",
-               rules           => <<EOF
-SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", NAME="1/2/a/b/node", SYMLINK+="1/2/symlink"
-EOF
-       },
-       {
-               desc            => "symlink creation (relative link back and forward)",
-               subsys          => "block",
-               devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda6",
-               exp_name        => "1/2/c/d/symlink" ,
-               exp_target      => "../../a/b/node",
-               exp_rem_error   => "yes",
-               rules           => <<EOF
-SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", NAME="1/2/a/b/node", SYMLINK+="1/2/c/d/symlink"
 EOF
        },
        {
                desc            => "multiple symlinks",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "second-0" ,
                rules           => <<EOF
@@ -856,7 +756,6 @@ EOF
        },
        {
                desc            => "symlink name '.'",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => ".",
                exp_add_error   => "yes",
@@ -867,7 +766,6 @@ EOF
        },
        {
                desc            => "symlink node to itself",
-               subsys          => "tty",
                devpath         => "/devices/virtual/tty/tty0",
                exp_name        => "link",
                exp_add_error   => "yes",
@@ -879,7 +777,6 @@ EOF
        },
        {
                desc            => "symlink %n substitution",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "symlink0",
                rules           => <<EOF
@@ -888,7 +785,6 @@ EOF
        },
        {
                desc            => "symlink %k substitution",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "symlink-ttyACM0",
                rules           => <<EOF
@@ -897,7 +793,6 @@ EOF
        },
        {
                desc            => "symlink %M:%m substitution",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "major-166:0",
                rules           => <<EOF
@@ -906,17 +801,14 @@ EOF
        },
        {
                desc            => "symlink %b substitution",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "symlink-0:0:0:0",
-               exp_target      => "node",
                rules           => <<EOF
-SUBSYSTEMS=="scsi", KERNEL=="sda", NAME="node", SYMLINK+="symlink-%b"
+SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="symlink-%b"
 EOF
        },
        {
                desc            => "symlink %c substitution",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "test",
                rules           => <<EOF
@@ -925,7 +817,6 @@ EOF
        },
        {
                desc            => "symlink %c{N} substitution",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "test",
                rules           => <<EOF
@@ -934,7 +825,6 @@ EOF
        },
        {
                desc            => "symlink %c{N+} substitution",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "this",
                rules           => <<EOF
@@ -943,7 +833,6 @@ EOF
        },
        {
                desc            => "symlink only rule with %c{N+}",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "test",
                rules           => <<EOF
@@ -952,7 +841,6 @@ EOF
        },
        {
                desc            => "symlink %s{filename} substitution",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "166:0",
                rules           => <<EOF
@@ -961,7 +849,6 @@ EOF
        },
        {
                desc            => "program result substitution (numbered part of)",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
                exp_name        => "link1",
                rules           => <<EOF
@@ -970,7 +857,6 @@ EOF
        },
        {
                desc            => "program result substitution (numbered part of+)",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda5",
                exp_name        => "link4",
                rules           => <<EOF
@@ -979,7 +865,6 @@ EOF
        },
        {
                desc            => "SUBSYSTEM match test",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "node",
                rules           => <<EOF
@@ -990,7 +875,6 @@ EOF
        },
        {
                desc            => "DRIVERS match test",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "node",
                rules           => <<EOF
@@ -999,38 +883,23 @@ SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="node", DRIVERS=="sd"
 EOF
        },
        {
-               desc            => "temporary node creation test",
-               subsys          => "block",
+               desc            => "devnode substitution test",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "node",
                rules           => <<EOF
-SUBSYSTEMS=="scsi", KERNEL=="sda", PROGRAM=="/usr@rootprefix@/bin/test -b %N" SYMLINK+="node"
-EOF
-       },
-       {
-               desc            => "parent node name substitution test sequence 1/2 (keep)",
-               subsys          => "block",
-               devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
-               exp_name        => "main_device",
-               option          => "keep",
-               exp_rem_error   => "yes",
-               rules           => <<EOF
-SUBSYSTEMS=="scsi", KERNEL=="sda", NAME="main_device"
+SUBSYSTEMS=="scsi", KERNEL=="sda", PROGRAM=="/usr/bin/test -b %N" SYMLINK+="node"
 EOF
        },
        {
-               desc            => "parent node name substitution test sequence 2/2 (clean)",
-               subsys          => "block",
+               desc            => "parent node name substitution test",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
-               exp_name        => "main_device-part-1",
-               option          => "clean",
+               exp_name        => "sda-part-1",
                rules           => <<EOF
 SUBSYSTEMS=="scsi", KERNEL=="sda1", SYMLINK+="%P-part-1"
 EOF
        },
        {
                desc            => "udev_root substitution",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
                exp_name        => "start-udev-root-end",
                rules           => <<EOF
@@ -1039,7 +908,6 @@ EOF
        },
        {
                desc            => "last_rule option",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
                exp_name        => "last",
                rules           => <<EOF
@@ -1049,7 +917,6 @@ EOF
        },
        {
                desc            => "negation KERNEL!=",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
                exp_name        => "match",
                rules           => <<EOF
@@ -1060,7 +927,6 @@ EOF
        },
        {
                desc            => "negation SUBSYSTEM!=",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
                exp_name        => "not-anything",
                rules           => <<EOF
@@ -1071,7 +937,6 @@ EOF
        },
        {
                desc            => "negation PROGRAM!= exit code",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
                exp_name        => "nonzero-program",
                rules           => <<EOF
@@ -1081,7 +946,6 @@ EOF
        },
        {
                desc            => "test for whitespace between the operator",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
                exp_name        => "true",
                rules           => <<EOF
@@ -1091,7 +955,6 @@ EOF
        },
        {
                desc            => "ENV{} test",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
                exp_name        => "true",
                rules           => <<EOF
@@ -1103,7 +966,6 @@ EOF
        },
        {
                desc            => "ENV{} test",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
                exp_name        => "true",
                rules           => <<EOF
@@ -1116,7 +978,6 @@ EOF
        },
        {
                desc            => "ENV{} test (assign)",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
                exp_name        => "true",
                rules           => <<EOF
@@ -1128,7 +989,6 @@ EOF
        },
        {
                desc            => "ENV{} test (assign 2 times)",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
                exp_name        => "true",
                rules           => <<EOF
@@ -1141,7 +1001,6 @@ EOF
        },
        {
                desc            => "ENV{} test (assign2)",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
                exp_name        => "part",
                rules           => <<EOF
@@ -1154,7 +1013,6 @@ EOF
        },
        {
                desc            => "untrusted string sanitize",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
                exp_name        => "sane",
                rules           => <<EOF
@@ -1163,7 +1021,6 @@ EOF
        },
        {
                desc            => "untrusted string sanitize (don't replace utf8)",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
                exp_name        => "uber",
                rules           => <<EOF
@@ -1172,7 +1029,6 @@ EOF
        },
        {
                desc            => "untrusted string sanitize (replace invalid utf8)",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
                exp_name        => "replaced",
                rules           => <<EOF
@@ -1181,7 +1037,6 @@ EOF
        },
        {
                desc            => "read sysfs value from parent device",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "serial-354172020305000",
                rules           => <<EOF
@@ -1190,7 +1045,6 @@ EOF
        },
        {
                desc            => "match against empty key string",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "ok",
                rules           => <<EOF
@@ -1202,28 +1056,15 @@ EOF
        },
        {
                desc            => "check ACTION value",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "ok",
                rules           => <<EOF
 ACTION=="unknown", KERNEL=="sda", SYMLINK+="unknown-not-ok"
 ACTION=="add", KERNEL=="sda", SYMLINK+="ok"
-EOF
-       },
-       {
-               desc            => "test RUN key remove",
-               subsys          => "block",
-               devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
-               exp_name        => "testsymlink2",
-               exp_target      => "ok2",
-               rules           => <<EOF
-KERNEL=="sda", NAME="ok2", RUN+="@rootprefix@/bin/ln -s ok2 %r/testsymlink2"
-KERNEL=="sda", ACTION=="remove", RUN+="@rootprefix@/bin/rm -f %r/testsymlink2"
 EOF
        },
        {
                desc            => "final assignment",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "ok",
                exp_perms       => "root:tty:0640",
@@ -1234,7 +1075,6 @@ EOF
        },
        {
                desc            => "final assignment 2",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "ok",
                exp_perms       => "root:tty:0640",
@@ -1246,7 +1086,6 @@ EOF
        },
        {
                desc            => "env substitution",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "node-add-me",
                rules           => <<EOF
@@ -1255,7 +1094,6 @@ EOF
        },
        {
                desc            => "reset list to current value",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "three",
                not_exp_name    => "two",
@@ -1267,7 +1105,6 @@ EOF
        },
        {
                desc            => "test empty SYMLINK+ (empty override)",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "right",
                not_exp_name    => "wrong",
@@ -1279,7 +1116,6 @@ EOF
        },
        {
                desc            => "test multi matches",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "right",
                rules           => <<EOF
@@ -1289,7 +1125,6 @@ EOF
        },
        {
                desc            => "test multi matches 2",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "right",
                rules           => <<EOF
@@ -1300,7 +1135,6 @@ EOF
        },
        {
                desc            => "test multi matches 3",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "right",
                rules           => <<EOF
@@ -1312,7 +1146,6 @@ EOF
        },
        {
                desc            => "test multi matches 4",
-               subsys          => "tty",
                devpath         => "/devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/tty/ttyACM0",
                exp_name        => "right",
                rules           => <<EOF
@@ -1325,7 +1158,6 @@ EOF
        },
        {
                desc            => "IMPORT parent test sequence 1/2 (keep)",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "parent",
                option          => "keep",
@@ -1336,7 +1168,6 @@ EOF
        },
        {
                desc            => "IMPORT parent test sequence 2/2 (keep)",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
                exp_name        => "parentenv-parent_right",
                option          => "clean",
@@ -1346,7 +1177,6 @@ EOF
        },
        {
                desc            => "GOTO test",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
                exp_name        => "right",
                rules           => <<EOF
@@ -1361,7 +1191,6 @@ EOF
        },
        {
                desc            => "GOTO label does not exist",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
                exp_name        => "right",
                rules           => <<EOF
@@ -1372,7 +1201,6 @@ EOF
        },
        {
                desc            => "SYMLINK+ compare test",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
                exp_name        => "right",
                not_exp_name    => "wrong",
@@ -1384,7 +1212,6 @@ EOF
        },
        {
                desc            => "invalid key operation",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
                exp_name        => "yes",
                rules           => <<EOF
@@ -1394,7 +1221,6 @@ EOF
        },
        {
                desc            => "operator chars in attribute",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "yes",
                rules           => <<EOF
@@ -1403,7 +1229,6 @@ EOF
        },
        {
                desc            => "overlong comment line",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
                exp_name        => "yes",
                rules           => <<EOF
@@ -1415,7 +1240,6 @@ EOF
        },
        {
                desc            => "magic subsys/kernel lookup",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "00:16:41:e2:8d:ff",
                rules           => <<EOF
@@ -1424,7 +1248,6 @@ EOF
        },
        {
                desc            => "TEST absolute path",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "there",
                rules           => <<EOF
@@ -1434,7 +1257,6 @@ EOF
        },
        {
                desc            => "TEST subsys/kernel lookup",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "yes",
                rules           => <<EOF
@@ -1443,7 +1265,6 @@ EOF
        },
        {
                desc            => "TEST relative path",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "relative",
                rules           => <<EOF
@@ -1452,7 +1273,6 @@ EOF
        },
        {
                desc            => "TEST wildcard substitution (find queue/nr_requests)",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "found-subdir",
                rules           => <<EOF
@@ -1461,7 +1281,6 @@ EOF
        },
        {
                desc            => "TEST MODE=0000",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "sda",
                exp_perms       => "0:0:0000",
@@ -1472,7 +1291,6 @@ EOF
        },
        {
                desc            => "TEST PROGRAM feeds OWNER, GROUP, MODE",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "sda",
                exp_perms       => "5000:100:0400",
@@ -1484,7 +1302,6 @@ EOF
        },
        {
                desc            => "TEST PROGRAM feeds MODE with overflow",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "sda",
                exp_perms       => "0:0:0440",
@@ -1496,7 +1313,6 @@ EOF
        },
        {
                desc            => "magic [subsys/sysname] attribute substitution",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "sda-8741C4G-end",
                exp_perms       => "0:0:0600",
@@ -1508,7 +1324,6 @@ EOF
        },
        {
                desc            => "builtin path_id",
-               subsys          => "block",
                devpath         => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
                exp_name        => "disk/by-path/pci-0000:00:1f.2-scsi-0:0:0:0",
                rules           => <<EOF
@@ -1519,25 +1334,20 @@ EOF
 );
 
 # set env
-$ENV{SYSFS_PATH} = $sysfs;
 $ENV{UDEV_CONFIG_FILE} = $udev_conf;
 
 sub udev {
-       my ($action, $subsys, $devpath, $rules) = @_;
-
-       $ENV{DEVPATH} = $devpath;
+       my ($action, $devpath, $rules) = @_;
 
        # create temporary rules
        open CONF, ">$udev_rules" || die "unable to create rules file: $udev_rules";
        print CONF $$rules;
        close CONF;
 
-       $ENV{ACTION} = $action;
-       $ENV{SUBSYSTEM} = $subsys;
        if ($valgrind > 0) {
-               system("$udev_bin_valgrind");
+               system("$udev_bin_valgrind $action $devpath");
        } else {
-               system("$udev_bin");
+               system("$udev_bin $action $devpath");
        }
 }
 
@@ -1606,39 +1416,6 @@ sub major_minor_test {
        }
 }
 
-sub symlink_test {
-       my ($rules) = @_;
-
-       my $output = `ls -l $PWD/$udev_root$rules->{exp_name}`;
-
-       if ($output =~ m/(.*)-> (.*)/) {
-               if ($2 eq $rules->{exp_target}) {
-                       print "symlink:     ok\n";
-               } else {
-                       print "  expected symlink from: \'$rules->{exp_name}\' to \'$rules->{exp_target}\'\n";
-                       print "  created symlink from: \'$rules->{exp_name}\' to \'$2\'\n";
-                       print "symlink: error";
-                       if ($rules->{exp_add_error}) {
-                               print " as expected\n";
-                       } else {
-                               print "\n";
-                               $error++;
-                               sleep(1);
-                       }
-               }
-       } else {
-               print "  expected symlink from: \'$rules->{exp_name}\' to \'$rules->{exp_target}\'\n";
-               print "symlink:     not created";
-               if ($rules->{exp_add_error}) {
-                       print " as expected\n";
-               } else {
-                       print "\n";
-                       $error++;
-                       sleep(1);
-               }
-       }
-}
-
 sub make_udev_root {
        system("rm -rf $udev_root");
        mkdir($udev_root) || die "unable to create udev_root: $udev_root\n";
@@ -1652,29 +1429,23 @@ sub run_test {
        my ($rules, $number) = @_;
 
        print "TEST $number: $rules->{desc}\n";
+       print "device \'$rules->{devpath}\' expecting node/link \'$rules->{exp_name}\'\n";
 
-       if ($rules->{exp_target}) {
-               print "device \'$rules->{devpath}\' expecting link '$rules->{exp_name}' to node \'$rules->{exp_target}\'\n";
-       } else {
-               print "device \'$rules->{devpath}\' expecting node/link \'$rules->{exp_name}\'\n";
-       }
-
-
-       udev("add", $rules->{subsys}, $rules->{devpath}, \$rules->{rules});
+       udev("add", $rules->{devpath}, \$rules->{rules});
        if (defined($rules->{not_exp_name})) {
-               if ((-e "$PWD/$udev_root$rules->{not_exp_name}") ||
-                   (-l "$PWD/$udev_root$rules->{not_exp_name}")) {
+               if ((-e "$PWD/$udev_root/$rules->{not_exp_name}") ||
+                   (-l "$PWD/$udev_root/$rules->{not_exp_name}")) {
                        print "nonexistent: error \'$rules->{not_exp_name}\' not expected to be there\n";
                        $error++;
                        sleep(1);
                }
        }
 
-       if ((-e "$PWD/$udev_root$rules->{exp_name}") ||
-           (-l "$PWD/$udev_root$rules->{exp_name}")) {
+       if ((-e "$PWD/$udev_root/$rules->{exp_name}") ||
+           (-l "$PWD/$udev_root/$rules->{exp_name}")) {
 
                my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
-                   $atime, $mtime, $ctime, $blksize, $blocks) = stat("$PWD/$udev_root$rules->{exp_name}");
+                   $atime, $mtime, $ctime, $blksize, $blocks) = stat("$PWD/$udev_root/$rules->{exp_name}");
 
                if (defined($rules->{exp_perms})) {
                        permissions_test($rules, $uid, $gid, $mode);
@@ -1682,9 +1453,6 @@ sub run_test {
                if (defined($rules->{exp_majorminor})) {
                        major_minor_test($rules, $rdev);
                }
-               if (defined($rules->{exp_target})) {
-                       symlink_test($rules);
-               }
                print "add:         ok\n";
        } else {
                print "add:         error";
@@ -1704,9 +1472,9 @@ sub run_test {
                return;
        }
 
-       udev("remove", $rules->{subsys}, $rules->{devpath}, \$rules->{rules});
-       if ((-e "$PWD/$udev_root$rules->{exp_name}") ||
-           (-l "$PWD/$udev_root$rules->{exp_name}")) {
+       udev("remove", $rules->{devpath}, \$rules->{rules});
+       if ((-e "$PWD/$udev_root/$rules->{exp_name}") ||
+           (-l "$PWD/$udev_root/$rules->{exp_name}")) {
                print "remove:      error";
                if ($rules->{exp_rem_error}) {
                        print " as expected\n";
@@ -1743,6 +1511,7 @@ make_udev_root();
 open CONF, ">$udev_conf" || die "unable to create config file: $udev_conf";
 print CONF "udev_root=\"$udev_root\"\n";
 print CONF "udev_run=\"$udev_root/.udev\"\n";
+print CONF "udev_sys=\"$sysfs\"\n";
 print CONF "udev_rules=\"$PWD\"\n";
 print CONF "udev_log=\"err\"\n";
 close CONF;
index 80394599060a14b19e809960cef39e7d76c66e7b..8d5baf7f54b9163fb596b07af39cf80322c664ab 100644 (file)
@@ -43,7 +43,6 @@ int main(int argc, char *argv[])
        char syspath[UTIL_PATH_SIZE];
        const char *devpath;
        const char *action;
-       const char *subsystem;
        sigset_t mask, sigmask_orig;
        int err = -EINVAL;
 
@@ -55,12 +54,15 @@ int main(int argc, char *argv[])
 
        sigprocmask(SIG_SETMASK, NULL, &sigmask_orig);
 
-       action = getenv("ACTION");
-       devpath = getenv("DEVPATH");
-       subsystem = getenv("SUBSYSTEM");
+       action = argv[1];
+       if (action == NULL) {
+               err(udev, "action missing\n");
+               goto out;
+       }
 
-       if (action == NULL || subsystem == NULL || devpath == NULL) {
-               err(udev, "action, subsystem or devpath missing\n");
+       devpath = argv[2];
+       if (devpath == NULL) {
+               err(udev, "devpath missing\n");
                goto out;
        }
 
@@ -73,10 +75,6 @@ int main(int argc, char *argv[])
                goto out;
        }
 
-       /* skip reading of db, but read kernel parameters */
-       udev_device_set_info_loaded(dev);
-       udev_device_read_uevent_file(dev);
-
        udev_device_set_action(dev, action);
        event = udev_event_new(dev);
 
@@ -88,6 +86,24 @@ int main(int argc, char *argv[])
                goto out;
        }
 
+       /* do what devtmpfs usually provides us */
+       if (udev_device_get_devnode(dev) != NULL) {
+               mode_t mode;
+
+               if (strcmp(udev_device_get_subsystem(dev), "block") == 0)
+                       mode |= S_IFBLK;
+               else
+                       mode |= S_IFCHR;
+
+               if (strcmp(action, "remove") != 0) {
+                       util_create_path(udev, udev_device_get_devnode(dev));
+                       mknod(udev_device_get_devnode(dev), mode, udev_device_get_devnum(dev));
+               } else {
+                       unlink(udev_device_get_devnode(dev));
+                       util_delete_path(udev, udev_device_get_devnode(dev));
+               }
+       }
+
        err = udev_event_execute_rules(event, rules, &sigmask_orig);
        if (err == 0)
                udev_event_execute_run(event, NULL);
index e10d48e13be467f267ab46bc5710a36073edb9f3..3801f23a6b43c52408222ec1aac6bef3931698e0 100644 (file)
@@ -59,7 +59,6 @@ void udev_event_unref(struct udev_event *event)
        if (event == NULL)
                return;
        udev_list_cleanup(&event->run_list);
-       free(event->tmp_node);
        free(event->program_result);
        free(event->name);
        dbg(event->udev, "free event %p\n", event);
@@ -71,7 +70,7 @@ size_t udev_event_apply_format(struct udev_event *event, const char *src, char *
        struct udev_device *dev = event->dev;
        enum subst_type {
                SUBST_UNKNOWN,
-               SUBST_TEMP_NODE,
+               SUBST_DEVNODE,
                SUBST_ATTR,
                SUBST_ENV,
                SUBST_KERNEL,
@@ -93,7 +92,8 @@ size_t udev_event_apply_format(struct udev_event *event, const char *src, char *
                char fmt;
                enum subst_type type;
        } map[] = {
-               { .name = "tempnode",   .fmt = 'N',     .type = SUBST_TEMP_NODE },
+               { .name = "devnode",    .fmt = 'N',     .type = SUBST_DEVNODE },
+               { .name = "tempnode",   .fmt = 'N',     .type = SUBST_DEVNODE },
                { .name = "attr",       .fmt = 's',     .type = SUBST_ATTR },
                { .name = "sysfs",      .fmt = 's',     .type = SUBST_ATTR },
                { .name = "env",        .fmt = 'E',     .type = SUBST_ENV },
@@ -332,7 +332,7 @@ subst:
                        dev_parent = udev_device_get_parent(event->dev);
                        if (dev_parent == NULL)
                                break;
-                               devnode = udev_device_get_devnode(dev_parent);
+                       devnode = udev_device_get_devnode(dev_parent);
                        if (devnode != NULL) {
                                size_t devlen = strlen(udev_get_dev_path(event->udev))+1;
 
@@ -342,56 +342,10 @@ subst:
                        }
                        break;
                }
-               case SUBST_TEMP_NODE: {
-                       dev_t devnum;
-                       struct stat statbuf;
-                       char filename[UTIL_PATH_SIZE];
-                       const char *devtype;
-
-                       if (event->tmp_node != NULL) {
-                               l = util_strpcpy(&s, l, event->tmp_node);
-                               dbg(event->udev, "tempnode: return earlier created one\n");
-                               break;
-                       }
-                       devnum = udev_device_get_devnum(dev);
-                       if (major(devnum) == 0)
-                               break;
-                       /* lookup kernel provided node */
-                       if (udev_device_get_knodename(dev) != NULL) {
-                               util_strscpyl(filename, sizeof(filename),
-                                             udev_get_dev_path(event->udev), "/", udev_device_get_knodename(dev), NULL);
-                               if (stat(filename, &statbuf) == 0 && statbuf.st_rdev == devnum) {
-                                       l = util_strpcpy(&s, l, filename);
-                                       dbg(event->udev, "tempnode: return kernel node\n");
-                                       break;
-                               }
-                       }
-                       /* lookup /dev/{char,block}/<maj>:<min> */
-                       if (strcmp(udev_device_get_subsystem(dev), "block") == 0)
-                               devtype = "block";
-                       else
-                               devtype = "char";
-                       snprintf(filename, sizeof(filename), "%s/%s/%u:%u",
-                                udev_get_dev_path(event->udev), devtype,
-                                major(udev_device_get_devnum(dev)),
-                                minor(udev_device_get_devnum(dev)));
-                       if (stat(filename, &statbuf) == 0 && statbuf.st_rdev == devnum) {
-                               l = util_strpcpy(&s, l, filename);
-                               dbg(event->udev, "tempnode: return maj:min node\n");
-                               break;
-                       }
-                       /* create temporary node */
-                       dbg(event->udev, "tempnode: create temp node\n");
-                       asprintf(&event->tmp_node, "%s/.tmp-%s-%u:%u",
-                                udev_get_dev_path(event->udev), devtype,
-                                major(udev_device_get_devnum(dev)),
-                                minor(udev_device_get_devnum(dev)));
-                       if (event->tmp_node == NULL)
-                               break;
-                       udev_node_mknod(dev, event->tmp_node, 0600, 0, 0);
-                       l = util_strpcpy(&s, l, event->tmp_node);
+               case SUBST_DEVNODE:
+                       if (udev_device_get_devnode(dev) != NULL)
+                               l = util_strpcpy(&s, l, udev_device_get_devnode(dev));
                        break;
-               }
                case SUBST_NAME:
                        if (event->name != NULL) {
                                l = util_strpcpy(&s, l, event->name);
@@ -975,44 +929,6 @@ int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules,
                }
 
                if (major(udev_device_get_devnum(dev)) != 0) {
-                       char filename[UTIL_PATH_SIZE];
-
-                       if (event->tmp_node != NULL) {
-                               info(event->udev, "cleanup temporary device node\n");
-                               util_unlink_secure(event->udev, event->tmp_node);
-                               free(event->tmp_node);
-                               event->tmp_node = NULL;
-                       }
-
-                       /* no rule, use kernel provided name */
-                       if (event->name == NULL) {
-                               if (udev_device_get_knodename(dev) != NULL) {
-                                       event->name = strdup(udev_device_get_knodename(dev));
-                                       info(event->udev, "no node name set, will use kernel supplied name '%s'\n", event->name);
-                               } else {
-                                       event->name = strdup(udev_device_get_sysname(event->dev));
-                                       info(event->udev, "no node name set, will use device name '%s'\n", event->name);
-                               }
-                       }
-
-                       if (event->name == NULL || event->name[0] == '\0') {
-                               udev_device_delete_db(dev);
-                               udev_device_tag_index(dev, NULL, false);
-                               udev_device_unref(event->dev_db);
-                               err = -ENOMEM;
-                               err(event->udev, "no node name, something went wrong, ignoring\n");
-                               goto out;
-                       }
-
-                       if (udev_device_get_knodename(dev) != NULL && strcmp(udev_device_get_knodename(dev), event->name) != 0)
-                               err(event->udev, "kernel-provided name '%s' and NAME= '%s' disagree, "
-                                   "please use SYMLINK+= or change the kernel to provide the proper name\n",
-                                   udev_device_get_knodename(dev), event->name);
-
-                       /* set device node name */
-                       util_strscpyl(filename, sizeof(filename), udev_get_dev_path(event->udev), "/", event->name, NULL);
-                       udev_device_set_devnode(dev, filename);
-
                        /* remove/update possible left-over symlinks from old database entry */
                        if (event->dev_db != NULL)
                                udev_node_update_old_links(dev, event->dev_db);
@@ -1030,10 +946,6 @@ int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules,
                                }
                        }
 
-                       /* set sticky bit, so we do not remove the node on module unload */
-                       if (event->static_node)
-                               event->mode |= 01000;
-
                        err = udev_node_add(dev, event->mode, event->uid, event->gid);
                }
 
index 44d3686db61a75f37d6994c2f98377644b5db039..31046bd71327bb39c044e422ca99c7fd63fef2a6 100644 (file)
 
 #define TMP_FILE_EXT           ".udev-tmp"
 
-int udev_node_mknod(struct udev_device *dev, const char *file, mode_t mode, uid_t uid, gid_t gid)
-{
-       struct udev *udev = udev_device_get_udev(dev);
-       dev_t devnum = udev_device_get_devnum(dev);
-       struct stat stats;
-       int err = 0;
-
-
-       if (strcmp(udev_device_get_subsystem(dev), "block") == 0)
-               mode |= S_IFBLK;
-       else
-               mode |= S_IFCHR;
-
-       if (file == NULL)
-               file = udev_device_get_devnode(dev);
-
-       if (lstat(file, &stats) == 0) {
-               if (((stats.st_mode & S_IFMT) == (mode & S_IFMT)) && (stats.st_rdev == devnum)) {
-                       info(udev, "preserve file '%s', because it has correct dev_t\n", file);
-                       if ((stats.st_mode & 0777) != (mode & 0777) || stats.st_uid != uid || stats.st_gid != gid) {
-                               /* preserve 'sticky' bit, if already set */
-                               mode |= stats.st_mode & 01000;
-                               info(udev, "set permissions %s, %#o, uid=%u, gid=%u\n", file, mode, uid, gid);
-                               chmod(file, mode);
-                               chown(file, uid, gid);
-                       } else {
-                               info(udev, "preserve permissions %s, %#o, uid=%u, gid=%u\n", file, mode, uid, gid);
-                       }
-                       /*
-                        * Set initial selinux file context only on add events.
-                        * We set the proper context on bootup (triger) or for newly
-                        * added devices, but we don't change it later, in case
-                        * something else has set a custom context in the meantime.
-                        */
-                       if (strcmp(udev_device_get_action(dev), "add") == 0)
-                               udev_selinux_lsetfilecon(udev, file, mode);
-                       /* always update timestamp when we re-use the node, like on media change events */
-                       utimensat(AT_FDCWD, file, NULL, 0);
-               } else {
-                       char file_tmp[UTIL_PATH_SIZE + sizeof(TMP_FILE_EXT)];
-
-                       info(udev, "atomically replace existing file '%s'\n", file);
-                       util_strscpyl(file_tmp, sizeof(file_tmp), file, TMP_FILE_EXT, NULL);
-                       unlink(file_tmp);
-                       udev_selinux_setfscreatecon(udev, file_tmp, mode);
-                       err = mknod(file_tmp, mode, devnum);
-                       udev_selinux_resetfscreatecon(udev);
-                       if (err != 0) {
-                               err(udev, "mknod '%s' %u:%u %#o failed: %m\n",
-                                   file_tmp, major(devnum), minor(devnum), mode);
-                               goto exit;
-                       }
-                       err = rename(file_tmp, file);
-                       if (err != 0) {
-                               err(udev, "rename '%s' '%s' failed: %m\n", file_tmp, file);
-                               unlink(file_tmp);
-                               goto exit;
-                       }
-                       info(udev, "set permissions '%s' %#o uid=%u gid=%u\n", file, mode, uid, gid);
-                       chmod(file, mode);
-                       chown(file, uid, gid);
-               }
-       } else {
-               info(udev, "mknod '%s' %u:%u %#o\n", file, major(devnum), minor(devnum), mode);
-               do {
-                       err = util_create_path_selinux(udev, file);
-                       if (err != 0 && err != -ENOENT)
-                               break;
-                       udev_selinux_setfscreatecon(udev, file, mode);
-                       err = mknod(file, mode, devnum);
-                       if (err != 0)
-                               err = -errno;
-                       udev_selinux_resetfscreatecon(udev);
-               } while (err == -ENOENT);
-               if (err != 0 && err != -EEXIST)
-                       err(udev, "mknod '%s' %u:%u %#o' failed: %m\n", file, major(devnum), minor(devnum), mode);
-               info(udev, "set permissions '%s' %#o uid=%u gid=%u\n", file, mode, uid, gid);
-               chmod(file, mode);
-               chown(file, uid, gid);
-       }
-exit:
-       return err;
-}
-
 static int node_symlink(struct udev *udev, const char *node, const char *slink)
 {
        struct stat stats;
@@ -362,6 +278,55 @@ void udev_node_update_old_links(struct udev_device *dev, struct udev_device *dev
        }
 }
 
+static int node_fixup(struct udev_device *dev, mode_t mode, uid_t uid, gid_t gid)
+{
+       struct udev *udev = udev_device_get_udev(dev);
+       const char *devnode = udev_device_get_devnode(dev);
+       dev_t devnum = udev_device_get_devnum(dev);
+       struct stat stats;
+       int err = 0;
+
+       if (strcmp(udev_device_get_subsystem(dev), "block") == 0)
+               mode |= S_IFBLK;
+       else
+               mode |= S_IFCHR;
+
+       if (lstat(devnode, &stats) != 0) {
+               err = -errno;
+               info(udev, "can not stat() node '%s' (%m)\n", devnode);
+               goto out;
+       }
+
+       if (((stats.st_mode & S_IFMT) != (mode & S_IFMT)) || (stats.st_rdev != devnum)) {
+               err = -EEXIST;
+               info(udev, "found node '%s' with non-matching devnum %s, skip handling\n",
+                    udev_device_get_devnode(dev), udev_device_get_id_filename(dev));
+               goto out;
+       }
+
+       if ((stats.st_mode & 0777) != (mode & 0777) || stats.st_uid != uid || stats.st_gid != gid) {
+               info(udev, "set permissions %s, %#o, uid=%u, gid=%u\n", devnode, mode, uid, gid);
+               chmod(devnode, mode);
+               chown(devnode, uid, gid);
+       } else {
+               info(udev, "preserve permissions %s, %#o, uid=%u, gid=%u\n", devnode, mode, uid, gid);
+       }
+
+       /*
+        * Set initial selinux file context only on add events.
+        * We set the proper context on bootup (triger) or for newly
+        * added devices, but we don't change it later, in case
+        * something else has set a custom context in the meantime.
+        */
+       if (strcmp(udev_device_get_action(dev), "add") == 0)
+               udev_selinux_lsetfilecon(udev, devnode, mode);
+
+       /* always update timestamp when we re-use the node, like on media change events */
+       utimensat(AT_FDCWD, devnode, NULL, 0);
+out:
+       return err;
+}
+
 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);
@@ -369,15 +334,12 @@ int udev_node_add(struct udev_device *dev, mode_t mode, uid_t uid, gid_t gid)
        struct udev_list_entry *list_entry;
        int err = 0;
 
-       info(udev, "creating device node '%s', devnum=%d:%d, mode=%#o, uid=%d, gid=%d\n",
-            udev_device_get_devnode(dev),
-            major(udev_device_get_devnum(dev)), minor(udev_device_get_devnum(dev)),
-            mode, uid, gid);
+       info(udev, "handling device node '%s', devnum=%s, mode=%#o, uid=%d, gid=%d\n",
+            udev_device_get_devnode(dev), udev_device_get_id_filename(dev), mode, uid, gid);
 
-       if (udev_node_mknod(dev, NULL, mode, uid, gid) != 0) {
-               err = -1;
+       err = node_fixup(dev, mode, uid, gid);
+       if (err < 0)
                goto exit;
-       }
 
        /* always add /dev/{block,char}/$major:$minor */
        snprintf(filename, sizeof(filename), "%s/%s/%u:%u",
@@ -412,38 +374,6 @@ int udev_node_remove(struct udev_device *dev)
        udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(dev))
                link_update(dev, udev_list_entry_get_name(list_entry), 0);
 
-       devnode = udev_device_get_devnode(dev);
-       if (devnode == NULL)
-               goto out;
-
-       if (stat(devnode, &stats) == 0) {
-               if (stats.st_rdev != udev_device_get_devnum(dev)) {
-                       info(udev, "device node '%s' points to a different device, skip removal\n", devnode);
-                       err = -1;
-                       goto out;
-               }
-
-               if (stats.st_mode & 01000) {
-                       info(udev, "device node '%s' has sticky bit set, skip removal\n", devnode);
-                       goto out;
-               }
-       } else {
-               info(udev, "device node '%s' not found\n", devnode);
-       }
-
-       dev_check = udev_device_new_from_syspath(udev, udev_device_get_syspath(dev));
-       if (dev_check != NULL) {
-               /* do not remove device node if the same sys-device is re-created in the meantime */
-               info(udev, "keeping device node of existing device'%s'\n", devnode);
-               udev_device_unref(dev_check);
-               goto out;
-       }
-
-       info(udev, "removing device node '%s'\n", devnode);
-       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),
index 411b9d88eb5a7ab7d948a6edc00057315855ce62..7e795451241e4a71bedd1171bbd48034900fb818 100644 (file)
@@ -2504,9 +2504,6 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event
                             &rules->buf[rule->rule.filename_off],
                             rule->rule.filename_line);
                        break;
-               case TK_A_STATIC_NODE:
-                       event->static_node = true;
-                       break;
                case TK_A_ENV: {
                        const char *name = &rules->buf[cur->key.attr_off];
                        char *value = &rules->buf[cur->key.value_off];
@@ -2729,8 +2726,6 @@ void udev_rules_apply_static_dev_perms(struct udev_rules *rules)
                                else
                                        mode = 0600;
                        }
-                       /* set sticky bit, so we do not remove the node on module unload */
-                       mode |= 01000;
                        if (mode != (stats.st_mode & 01777)) {
                                chmod(filename, mode);
                                info(rules->udev, "chmod '%s' %#o\n", filename, mode);
index 4f2886c69cd423701eba3f4bf30594ee831ae51d..56b1652c747cee9d3e0a3cbbe41bd79fbfdb318b 100644 (file)
@@ -32,7 +32,6 @@ struct udev_event {
        struct udev_device *dev_parent;
        struct udev_device *dev_db;
        char *name;
-       char *tmp_node;
        char *program_result;
        mode_t mode;
        uid_t uid;
@@ -51,7 +50,6 @@ struct udev_event {
        bool owner_final;
        bool mode_set;
        bool mode_final;
-       bool static_node;
        bool name_final;
        bool devlink_final;
        bool run_final;
@@ -91,7 +89,6 @@ void udev_watch_end(struct udev *udev, struct udev_device *dev);
 struct udev_device *udev_watch_lookup(struct udev *udev, int wd);
 
 /* udev-node.c */
-int udev_node_mknod(struct udev_device *dev, const char *file, mode_t mode, uid_t uid, gid_t gid);
 int udev_node_add(struct udev_device *dev, mode_t mode, uid_t uid, gid_t gid);
 int udev_node_remove(struct udev_device *dev);
 void udev_node_update_old_links(struct udev_device *dev, struct udev_device *dev_old);
index 7b31173b21870f6cc159e0331a7d342ec4f44b81..fca0dad7bff1956c8324e8dd75053ace61bb5d38 100644 (file)
         <varlistentry>
           <term><option>NAME</option></term>
           <listitem>
-            <para>Match the name of the node or network interface. It can
-            be used once the NAME key has been set in one of the preceding
-            rules.</para>
+            <para>Match the name of a network interface. It can be used once the
+            NAME key has been set in one of the preceding rules.</para>
           </listitem>
         </varlistentry>
 
         <varlistentry>
           <term><option>NAME</option></term>
           <listitem>
-            <para>What a network interface should be named.</para>
-            <para>Also, as a temporary workaround, this is what a device node
-            should be named; usually the kernel provides the defined node name or creates
-            and removes the node before udev even receives any event. Changing
-            the node name from the kernel's default creates inconsistencies
-            and is not supported. If the kernel and NAME specify different names,
-            an error is logged. udev is only expected to handle device node
-            permissions and to create additional symlinks, not to change
-            kernel-provided device node names. Instead of renaming a device node,
-            SYMLINK should be used. However, symlink names must never conflict with
-            device node names, as that would result in unpredictable behavior.</para>
+            <para>The name to use for a network interface. The name of a device node
+            can not be changed by udev, only additional symlinks can be created.</para>
           </listitem>
         </varlistentry>
 
         <varlistentry>
           <term><option>$name</option></term>
           <listitem>
-            <para>The current name of the device node. If not changed by a rule, it is the
+            <para>The current name of the device. If not changed by a rule, it is the
             name of the kernel device.</para>
           </listitem>
         </varlistentry>
         </varlistentry>
 
         <varlistentry>
-          <term><option>$tempnode</option>, <option>%N</option></term>
+          <term><option>$devnode</option>, <option>%N</option></term>
           <listitem>
-            <para>The name of a temporary device node created to provide access to
-            the device from a external program before the real node is created.</para>
+            <para>The name of the device node.</para>
           </listitem>
         </varlistentry>
 
index 63b4fd7ad26c33a28b17c097cc819461aa692d43..6b561977dc84a2f483e02c44e48fa107711a479f 100644 (file)
@@ -863,11 +863,10 @@ static void static_dev_create_from_modules(struct udev *udev)
                if (sscanf(devno, "%c%u:%u", &type, &maj, &min) != 3)
                        continue;
 
-               /* set sticky bit, so we do not remove the node on module unload */
                if (type == 'c')
-                       mode = 01600|S_IFCHR;
+                       mode = S_IFCHR;
                else if (type == 'b')
-                       mode = 01600|S_IFBLK;
+                       mode = S_IFBLK;
                else
                        continue;