Created attachment 679 [details] Use $SUBSYSTEM too, for testing whether a device is a block device When mdev -s is executed, it correctly creates block device nodes in /dev for every block device it founds. But if a nand flash driver is loaded later in the running system (after mdev is set up as hotplug client), a hotplug event is triggered, which makes 'mdev' being launched without parameters. In this mode mdev uses $SUBSYSTEM and $DEVPATH environment variables to determine what new device appeared in the system. Older versions of mdev expected $DEVPATH to contain /sys/block/ which caused this same bug with kernels >= 2.6.25 as the block device entries were moved to /sys/class/block/. The current version of mdev checks whether $DEVPATH contains /block/ or not. If it doesn't, a character device node is created for it, instead of a block device node. The problem is that in our system mdev gets called with the following environment variables: SUBSYSTEM="block" DEVPATH="/devices/virtual/mtd/mtd3/mtdblock3" As $DEVPATH does not contain /block/, a character device node is assigned to it. The attached patch fixes this problem by checking whether the first 5 characters of $SUBSYSTEM are "block", assuming that it is a block device if they are. The patch was created for 1.15.1 with the official patches applied.
This was just applied to git: /* Make path point to "subsystem/device_name" */ - if (path[5] == 'b') /* legacy /sys/block? */ + subsystem_slash_devname = NULL; + /* Check for coldplug invocations first */ + if (strncmp(path, "/sys/block/", 11) == 0) /* legacy case */ path += sizeof("/sys/") - 1; - else + else if (strncmp(path, "/sys/class/", 11) == 0) path += sizeof("/sys/class/") - 1; + else { + /* Example of a hotplug invocation: + * SUBSYSTEM="block" + * DEVPATH="/sys" + "/devices/virtual/mtd/mtd3/mtdblock3" + * ("/sys" is added by mdev_main) + * - path does not contain subsystem + */ + subsystem_slash_devname = concat_path_file(G.subsystem, device_name); + path = subsystem_slash_devname; + }
Closing as fixed, reopen if you still experience this problem.