[busybox] problems with mdev -s

Rich Mahn rich at lat.com
Fri May 9 08:21:34 PDT 2008


On Tuesday 06 May 2008 22:02, Rich Mahn wrote:
> > The problem:
> >    With certain configurations, when 'mdev -s' is run, all devices
> > created are character devices, including those which should be block
> > devices.  This is easily reproducible.
> > 
> > More details:
> >    The devices created are correct WRT permissions, major and minor
> > numbers.  However, when the problem occurs, all new devices are
> > character devices.  Devices that already exist are not changed--if
> > they are already block devices they staay that way.  Adding printf
> > statements in mdev.c shows that the correct values are being sent to
> > the system call 'mknod' appear to be correct

> Wow. if this is true that mknod have correct arguments,
> then I can't see what I can fix. But I'm doubtful.
> Can you show me these debug printouts added, and their output?


Same problem with Busybox 1.10.2.  Same patch fixes it.  Caused by
linux 2.6.25 placing same block devices that are in /sys/block into
/sys/class/block as well.  Here's my version of the patch fix for 1.10.2

rich


--- util-linux/mdev.c~
+++ util-linux/mdev.c
@@ -72,8 +72,10 @@
 	/* Determine device name, type, major and minor */
 	device_name = bb_basename(path);
 	/* http://kernel.org/doc/pending/hotplug.txt says that only
-	 * "/sys/block/..." is for block devices. "sys/bus" etc is not! */
-	type = (strncmp(&path[5], "block/", 6) == 0 ? S_IFBLK : S_IFCHR);
+	 * "/sys/block/..." is for block devices. "sys/bus" etc is not!
+	 * linux 2.6.25 also places these in "/sys/class/block/..."  */
+	type = (strncmp(&path[5], "block/", 6) == 0 ? S_IFBLK :
+		(strncmp(&path[5], "class/block/", 12) == 0 ? S_IFBLK : S_IFCHR));
 
 	if (ENABLE_FEATURE_MDEV_CONF) {
 		FILE *fp;


More information about the busybox mailing list