Bug 21

Summary: mdev called via hotplug generates broken device nodes
Product: uClibc Reporter: Waldemar Brodkorb <oss>
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal    
Priority: P3    
Version: 0.9.30   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Host: Debian/amd64 Target: Qemu/i586
Build: Debian/amd64
Attachments: Patch which I applied to svn

Description Waldemar Brodkorb 2009-01-08 09:23:25 UTC
Hi,

I am using a self compiled Linux system and getting a strange error with mdev.

Linux 2.6.28
binutils 2.19
gcc 4.3.2
uClibc 0.9.30
(with following patch applied:
http://sources.busybox.net/index.py/trunk/uClibc/libc/sysdeps/linux/common/mknod.c?r1=23831&r2=24046)
busybox 1.12.4

The Linux hotplug system is configured to call mdev on any event.
# cat /proc/sys/kernel/hotplug 
/sbin/mdev

When I load the device-mapper kernel modul a device node is created:
# ls -la /dev/device-mapper 
crw-rw----    1 root     root      10,  60 Jan  8 10:05 /dev/device-mapper

But some thing is broken with this node:
# strace -f -estat64 ls /dev/device-mapper  
stat64("/dev/device-mapper", {st_mode=S_IFCHR|0660, st_rdev=makedev(2058, 753468), ...}) = 0

And dmsetup does not work:
# ln -sf /dev/device-mapper /dev/mapper/control
# dmsetup targets
/dev/mapper/control: open failed: No such device or address
Failure to communicate with kernel device-mapper driver.
Command failed

When I delete the device node and recreate it with either mknod or mdev -s,
everything works like expected:
# rm /dev/device-mapper 
# mdev -s
# strace -f -estat64 ls /dev/device-mapper
stat64("/dev/device-mapper", {st_mode=S_IFCHR|0660, st_rdev=makedev(10, 60), ...}) = 0
/dev/device-mapper
# dmsetup targets
crypt            v1.6.0
striped          v1.1.0
linear           v1.0.3
error            v1.0.1

A similar problem occured with busybox mknod applet _before_ I applied the uClibc patch mentioned above.

If any information is missing, don't hesitate to ask.

Thanks in advance
 Waldemar 

P.S.: I can provide a link to the qemu image on personal request.
Comment 1 Waldemar Brodkorb 2009-01-09 22:24:39 UTC
Hi,

finally found a solution.

In uClibc-0.9.30/libc/sysdeps/linux/i386/bits/kernel_types.h the type for
__kernel_dev_t is wrong for Linux 2.6.28.

When I change it:
-typedef unsigned short	__kernel_dev_t;
+typedef unsigned int	__kernel_dev_t;

Mdev works, dmsetup works and finally cryptsetup works with uClibc :}

bye
 Waldemar
Comment 2 Denys Vlasenko 2009-03-03 13:02:15 UTC
Created attachment 83 [details]
Patch which I applied to svn