Bug 1771

Summary: Fakeroot and the target/generic/device_table.txt create bad device nodes.
Product: buildroot Reporter: Andy Kennedy <andy.kennedy>
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: andy.kennedy, buildroot
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: Other   
OS: Linux   
Host: Target:
Build:

Description Andy Kennedy 2010-05-13 20:53:15 UTC
BUILD=Slackware 12.0 (slightly modified)
TARGET=ARM
Filesystem=Jffs2.

brw-r----- 1 root root  3,  1 2010-04-27 09:55 hda
brw-r----- 1 root root  3,  1 2010-04-27 09:55 hda1
brw-r----- 1 root root  3,  2 2010-04-27 09:55 hda2
<SNIP>
brw-r----- 1 root root  3, 65 2010-04-27 09:55 hdb
brw-r----- 1 root root  3, 65 2010-04-27 09:55 hdb1
brw-r----- 1 root root  3, 66 2010-04-27 09:55 hdb2
<SNIP>
brw-r----- 1 root root 22,  0 2010-04-27 09:55 hdc
brw-r----- 1 root root 22,  0 2010-05-13 15:23 hdc0
brw-r----- 1 root root 22,  1 2010-04-27 09:55 hdc1
brw-r----- 1 root root 22,  2 2010-04-27 09:55 hdc2
<SNIP>

I attempted something "new" with the above.  For /dev/hdc* I made the following change in target/generic/device_table.txt to see what whould happen:

/dev/hda        b       640     0       0       3       0       0       0       -
/dev/hda        b       640     0       0       3       1       1       1       15
/dev/hdb        b       640     0       0       3       64      0       0       -
/dev/hdb        b       640     0       0       3       65      1       1       15
#/dev/hdc       b       640     0       0       22      0       0       0       -
#/dev/hdc       b       640     0       0       22      1       1       1       15
/dev/hdc        b       640     0       0       22      0       0       1       15

As you see from the above, the devices get made /dev/hdc (correctly), but then /dev/hdc0 (what's that!?!) however, hda and hdb are completely wrong.

For me the fix is simple, I make the correction to the file as I did for hdc for any others that I need like that, then I run a post script that deletes any occurance of hd.0.
Comment 1 Thomas Petazzoni 2010-05-21 21:44:49 UTC
I just made a test with the default target/generic/device_table.txt and the result for hd* is good :


fs/dev$ ls -l hd*
brw-r----- 1 root root 3,  0 2010-05-21 23:31 hda
brw-r----- 1 root root 3,  1 2010-05-21 23:31 hda1
brw-r----- 1 root root 3, 10 2010-05-21 23:31 hda10
brw-r----- 1 root root 3, 11 2010-05-21 23:31 hda11
brw-r----- 1 root root 3, 12 2010-05-21 23:31 hda12
brw-r----- 1 root root 3, 13 2010-05-21 23:31 hda13
brw-r----- 1 root root 3, 14 2010-05-21 23:31 hda14
brw-r----- 1 root root 3,  2 2010-05-21 23:31 hda2
brw-r----- 1 root root 3,  3 2010-05-21 23:31 hda3
brw-r----- 1 root root 3,  4 2010-05-21 23:31 hda4
brw-r----- 1 root root 3,  5 2010-05-21 23:31 hda5
brw-r----- 1 root root 3,  6 2010-05-21 23:31 hda6
brw-r----- 1 root root 3,  7 2010-05-21 23:31 hda7
brw-r----- 1 root root 3,  8 2010-05-21 23:31 hda8
brw-r----- 1 root root 3,  9 2010-05-21 23:31 hda9
brw-r----- 1 root root 3, 64 2010-05-21 23:31 hdb
brw-r----- 1 root root 3, 65 2010-05-21 23:31 hdb1
brw-r----- 1 root root 3, 74 2010-05-21 23:31 hdb10
brw-r----- 1 root root 3, 75 2010-05-21 23:31 hdb11
brw-r----- 1 root root 3, 76 2010-05-21 23:31 hdb12
brw-r----- 1 root root 3, 77 2010-05-21 23:31 hdb13
brw-r----- 1 root root 3, 78 2010-05-21 23:31 hdb14
brw-r----- 1 root root 3, 66 2010-05-21 23:31 hdb2
brw-r----- 1 root root 3, 67 2010-05-21 23:31 hdb3
brw-r----- 1 root root 3, 68 2010-05-21 23:31 hdb4
brw-r----- 1 root root 3, 69 2010-05-21 23:31 hdb5
brw-r----- 1 root root 3, 70 2010-05-21 23:31 hdb6
brw-r----- 1 root root 3, 71 2010-05-21 23:31 hdb7
brw-r----- 1 root root 3, 72 2010-05-21 23:31 hdb8
brw-r----- 1 root root 3, 73 2010-05-21 23:31 hdb9

In the device list you pasted, the minor numbers are incorrect. hda should be 3:0, hda1 should be 3:1, hda2 3:2, hdb should be 3:64, hdb1 3:65, hdb2 3:66. hdc is 22:0, hdc1 is 22:1, etc. See Documentation/devices.txt in the Linux kernel source tree for the official reference.

So I don't see what's wrong in Buildroot. Could explain in more details what is the problem for you ?

Thanks!
Comment 2 Andy Kennedy 2010-05-25 22:58:40 UTC
(In reply to comment #1)

I attempted to e-mail this, but it looks like it didn't go through. . . so if this is a dup, please forgive.

> --- Comment #1 from Thomas Petazzoni 
> <thomas.petazzoni@free-electrons.com>  ---
> I just made a test with the default 
> target/generic/device_table.txt and the
> result for hd* is good :

Sorry, I thought I had articulated correctly.  To restate:  this problem ONLY occurs with the building of a jffs2 filesystem.  When I 'make tarroot' I get a device tree with correctly populated device nodes.  Only when I 'make jffs2root' do I get funky minor numbers.

> In the device list you pasted, the minor numbers are 
> incorrect. hda should be
> 3:0, hda1 should be 3:1, hda2 3:2, hdb should be 3:64, hdb1 
> 3:65, hdb2 3:66.
> hdc is 22:0, hdc1 is 22:1, etc. See Documentation/devices.txt 
> in the Linux
> kernel source tree for the official reference.
> 

Yes, this was the reason for the bug report.  These devices are being made incorrectly.

More information, however, is that if I make the nodes myself in the <path to target>/dev directory, modify buildroot/target/generic/device_table.txt to EXCLUDE hd{a-c} and sd{a-c} then I get the devices correctly in the filesystem.  Which makes me wonder if fakeroot is the red herring and the real culprit is actually makedevs.

Hopefully I have cleared something up for you.

Andy
Comment 3 Thomas Petazzoni 2010-06-05 15:19:37 UTC
Ok, bug reproduced and understood. I've just sent a patch to the Buildroot list that fixes it: http://lists.busybox.net/pipermail/buildroot/2010-June/035015.html

Thanks for your report!