From mike.cashwell@sdrcinc.net Wed Apr 18 17:39:11 2007
Delivered-To: vda.linux@gmail.com
Received: by 10.100.171.7 with SMTP id t7cs4479ane;
        Wed, 18 Apr 2007 08:59:43 -0700 (PDT)
Received: by 10.114.15.1 with SMTP id 1mr252902wao.1176911983321;
        Wed, 18 Apr 2007 08:59:43 -0700 (PDT)
Return-Path: <busybox-bounces@busybox.net>
Received: from busybox.net (busybox.osuosl.org [140.211.166.42])
        by mx.google.com with ESMTP id m28si376111poh.2007.04.18.08.59.42;
        Wed, 18 Apr 2007 08:59:43 -0700 (PDT)
Received-SPF: pass (google.com: domain of busybox-bounces@busybox.net designates 140.211.166.42 as permitted sender)
Received: from localhost.localdomain (busybox [127.0.0.1])
	by busybox.net (BusyBox.Net Mail Daemon) with ESMTP id B554548572;
	Wed, 18 Apr 2007 08:59:26 -0700 (PDT)
X-Original-To: busybox@busybox.net
Delivered-To: busybox@busybox.net
X-Greylist: delayed 1225 seconds by postgrey-1.21 at busybox;
	Wed, 18 Apr 2007 08:59:21 PDT
Received: from sol.prograde.net (gateway.prograde.net [66.92.163.78])
	by busybox.net (BusyBox.Net Mail Daemon) with ESMTP id 3AB9848560
	for <busybox@busybox.net>; Wed, 18 Apr 2007 08:59:21 -0700 (PDT)
Received: from [192.168.0.237] (unknown [72.165.80.4])
	by sol.prograde.net (Postfix) with ESMTP id 83AE6396220
	for <busybox@busybox.net>; Wed, 18 Apr 2007 11:38:52 -0400 (EDT)
Mime-Version: 1.0 (Apple Message framework v752.3)
Message-Id: <F82B0231-7242-46A5-896A-09812AA1D11F@sdrcinc.net>
To: busybox@busybox.net
From: Mike Cashwell <mike.cashwell@sdrcinc.net>
Subject: mdev problem with BB 1.4.2
Date: Wed, 18 Apr 2007 11:39:11 -0400
X-Mailer: Apple Mail (2.752.3)
X-BeenThere: busybox@busybox.net
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Discussion and development of BusyBox <busybox.busybox.net>
List-Unsubscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox>,
	<mailto:busybox-request@busybox.net?subject=unsubscribe>
List-Archive: <http://busybox.net/lists/busybox>
List-Post: <mailto:busybox@busybox.net>
List-Help: <mailto:busybox-request@busybox.net?subject=help>
List-Subscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox>,
	<mailto:busybox-request@busybox.net?subject=subscribe>
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: busybox-bounces@busybox.net
Errors-To: busybox-bounces@busybox.net
Status: RO
X-Status: RAC
X-KMail-EncryptionState: N
X-KMail-SignatureState: N
X-KMail-MDN-Sent:  

Greetings all,

I'm bringing up a completely new toolchain (gcc 4.1.1; glibc 2.5;  
linux 2.6.20.4; BB 1.4.2) on an ARM v4tle board. (Whew!)

I'm having trouble getting mdev to fully populate /dev. Specifically,  
I'm not getting entries for my 3 physical serial ports. I've scoured  
the mailing list archives and found a few near-misses, but nothing  
specific.

My hunch is that my sysfs is putting in symlinks in such a way that  
mdev is having trouble. I've included what I think is the relevant  
info below.

Anyone have any ideas? Maybe there's some BB config setting I don't  
have set? My confusion is why mdev is getting the block devices right  
but not the character ones.

Thanks for any assistance!
-Mike

------ /dev and /sys info -----

dm17:/dev $ ls -la
drwxrwxrwt    4 root     root          640 Jan  1 00:01 .
drwxrwxr-x   15 500      500          4096 Apr 18  2007 ..
crw-------    1 root     root       5,   1 Jan  1 04:58 console
srw-rw-rw-    1 root     root            0 Jan  1 00:01 log
brw-rw----    1 root     root       7,   0 Jan  1 00:01 loop0
brw-rw----    1 root     root       7,   1 Jan  1 00:01 loop1
brw-rw----    1 root     root       7,   2 Jan  1 00:01 loop2
brw-rw----    1 root     root       7,   3 Jan  1 00:01 loop3
brw-rw----    1 root     root       7,   4 Jan  1 00:01 loop4
brw-rw----    1 root     root       7,   5 Jan  1 00:01 loop5
brw-rw----    1 root     root       7,   6 Jan  1 00:01 loop6
brw-rw----    1 root     root       7,   7 Jan  1 00:01 loop7
crw-r--r--    1 root     root       1,   3 Jan  1 00:00 null
drwxr-xr-x    2 root     root           40 Jan  1 00:00 pts
brw-rw----    1 root     root       1,   0 Jan  1 00:01 ram0
brw-rw----    1 root     root       1,   1 Jan  1 00:01 ram1
brw-rw----    1 root     root       1,  10 Jan  1 00:01 ram10
brw-rw----    1 root     root       1,  11 Jan  1 00:01 ram11
brw-rw----    1 root     root       1,  12 Jan  1 00:01 ram12
brw-rw----    1 root     root       1,  13 Jan  1 00:01 ram13
brw-rw----    1 root     root       1,  14 Jan  1 00:01 ram14
brw-rw----    1 root     root       1,  15 Jan  1 00:01 ram15
brw-rw----    1 root     root       1,   2 Jan  1 00:01 ram2
brw-rw----    1 root     root       1,   3 Jan  1 00:01 ram3
brw-rw----    1 root     root       1,   4 Jan  1 00:01 ram4
brw-rw----    1 root     root       1,   5 Jan  1 00:01 ram5
brw-rw----    1 root     root       1,   6 Jan  1 00:01 ram6
brw-rw----    1 root     root       1,   7 Jan  1 00:01 ram7
brw-rw----    1 root     root       1,   8 Jan  1 00:01 ram8
brw-rw----    1 root     root       1,   9 Jan  1 00:01 ram9
crw-rw----    1 root     root     254,   0 Jan  1 00:01 rtc0
drwxr-xr-x    2 root     root           40 Jan  1 00:00 shm
dm17:/dev $ cd /sys
dm17:/sys $ ls
block     class     firmware  kernel    power
bus       devices   fs        module
dm17:/sys $ cd class/
dm17:/sys/class $ ls -la
drwxr-xr-x    9 root     root            0 Jan  1  1970 .
drwxr-xr-x   11 root     root            0 Jan  1  1970 ..
drwxr-xr-x    2 root     root            0 Jan  1 00:01 mem
drwxr-xr-x    2 root     root            0 Jan  1 00:01 misc
drwxr-xr-x    2 root     root            0 Jan  1  1970 mtd
drwxr-xr-x    4 root     root            0 Jan  1  1970 net
drwxr-xr-x    3 root     root            0 Jan  1  1970 rtc
drwxr-xr-x    3 root     root            0 Jan  1  1970 rtc-dev
drwxr-xr-x    2 root     root            0 Jan  1 00:01 tty
dm17:/sys/class $ cd tty/
dm17:/sys/class/tty $ ls -la
drwxr-xr-x    2 root     root            0 Jan  1 00:01 .
drwxr-xr-x    9 root     root            0 Jan  1  1970 ..
lrwxrwxrwx    1 root     root            0 Jan  1 00:01 console - 
 > ../../devices/virtual/tty/console
lrwxrwxrwx    1 root     root            0 Jan  1 00:01 ptmx -> ../../ 
devices/virtual/tty/ptmx
lrwxrwxrwx    1 root     root            0 Jan  1 00:01 tty -> ../../ 
devices/virtual/tty/tty
lrwxrwxrwx    1 root     root            0 Jan  1 00:01 ttyS0 - 
 > ../../devices/platform/serial8250.0/ttyS0
lrwxrwxrwx    1 root     root            0 Jan  1 00:01 ttyS1 - 
 > ../../devices/platform/serial8250.0/ttyS1
lrwxrwxrwx    1 root     root            0 Jan  1 00:01 ttyS2 - 
 > ../../devices/platform/serial8250.0/ttyS2
dm17:/sys/class/tty $ cat ttyS0/dev
4:64
dm17:/sys/class/tty $ cat /proc/devices
Character devices:
   1 mem
   4 ttyS
   5 /dev/tty
   5 /dev/console
   5 /dev/ptmx
10 misc
90 mtd
128 ptm
136 pts
254 rtc

Block devices:
   1 ramdisk
   7 loop
31 mtdblock


_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox

From tmathys@hsr.ch Wed Apr 18 19:29:56 2007
Delivered-To: vda.linux@gmail.com
Received: by 10.100.171.7 with SMTP id t7cs24853ane;
        Wed, 18 Apr 2007 10:38:00 -0700 (PDT)
Received: by 10.114.102.1 with SMTP id z1mr269775wab.1176917787307;
        Wed, 18 Apr 2007 10:36:27 -0700 (PDT)
Return-Path: <busybox-bounces@busybox.net>
Received: from busybox.net (busybox.osuosl.org [140.211.166.42])
        by mx.google.com with ESMTP id m26si1392342pof.2007.04.18.10.36.26;
        Wed, 18 Apr 2007 10:36:27 -0700 (PDT)
Received-SPF: pass (google.com: domain of busybox-bounces@busybox.net designates 140.211.166.42 as permitted sender)
Received: from localhost.localdomain (busybox [127.0.0.1])
	by busybox.net (BusyBox.Net Mail Daemon) with ESMTP id B3ED748577;
	Wed, 18 Apr 2007 10:36:05 -0700 (PDT)
X-Original-To: busybox@busybox.net
Delivered-To: busybox@busybox.net
X-Greylist: delayed 357 seconds by postgrey-1.21 at busybox;
	Wed, 18 Apr 2007 10:36:02 PDT
Received: from hsrmx2.hsr.ch (hsrmx2.hsr.ch [152.96.36.51])
	by busybox.net (BusyBox.Net Mail Daemon) with ESMTP id E2CB9480A2
	for <busybox@busybox.net>; Wed, 18 Apr 2007 10:36:02 -0700 (PDT)
Received: from localhost (localhost [127.0.0.1])
	by hsrmx2.hsr.ch (Postfix) with ESMTP id BA9709BC47
	for <busybox@busybox.net>; Wed, 18 Apr 2007 19:30:03 +0200 (CEST)
Received: from hsrmx2.hsr.ch ([127.0.0.1])
	by localhost (hsrmx2.hsr.ch [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 7TjoE+dGLI8T for <busybox@busybox.net>;
	Wed, 18 Apr 2007 19:29:56 +0200 (CEST)
Received: from sid00062.hsr.ch (unknown [152.96.21.100])
	by hsrmx2.hsr.ch (Postfix) with ESMTP id 994B79BC44
	for <busybox@busybox.net>; Wed, 18 Apr 2007 19:29:56 +0200 (CEST)
Received: from sid00060.hsr.ch ([152.96.22.60]) by sid00062.hsr.ch with
	Microsoft SMTPSVC(6.0.3790.1830); Wed, 18 Apr 2007 19:29:56 +0200
Received: from [152.96.201.22] ([152.96.201.22]) by sid00060.hsr.ch with
	Microsoft SMTPSVC(6.0.3790.1830); Wed, 18 Apr 2007 19:29:56 +0200
Message-ID: <46265594.9030604@hsr.ch>
Date: Wed, 18 Apr 2007 19:29:56 +0200
From: Thomas Mathys <tmathys@hsr.ch>
User-Agent: Icedove 1.5.0.10 (X11/20070329)
MIME-Version: 1.0
To: busybox@busybox.net
Subject: Re: mdev problem with BB 1.4.2
References: <F82B0231-7242-46A5-896A-09812AA1D11F@sdrcinc.net>
In-Reply-To: <F82B0231-7242-46A5-896A-09812AA1D11F@sdrcinc.net>
X-OriginalArrivalTime: 18 Apr 2007 17:29:56.0235 (UTC)
	FILETIME=[2E91DDB0:01C781DF]
X-BeenThere: busybox@busybox.net
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Discussion and development of BusyBox <busybox.busybox.net>
List-Unsubscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox>,
	<mailto:busybox-request@busybox.net?subject=unsubscribe>
List-Archive: <http://busybox.net/lists/busybox>
List-Post: <mailto:busybox@busybox.net>
List-Help: <mailto:busybox-request@busybox.net?subject=help>
List-Subscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox>,
	<mailto:busybox-request@busybox.net?subject=subscribe>
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: busybox-bounces@busybox.net
Errors-To: busybox-bounces@busybox.net
Status: RO
X-Status: RC
X-KMail-EncryptionState: N
X-KMail-SignatureState: N
X-KMail-MDN-Sent:  

Hello,

I had this problem too when I upgraded to a recent kernel, where sysfs 
heavily changed. The problem is, that  mdev does never follow symlinks 
(probably to keep mdev simple - sysfs is full of cycles caused by symlinks).

I did find a fix (forgive me for not sending it as a patch - I don't 
have access to that code right now):
Inside mdev.c is a function that recursively traverses sysfs. It 
descends only into entries that are NOT symlinks. I changed mdev.c, so 
that it does not descend into symlinks, UNLESS they're called subsystem.

Explanation:
- I observed that all the missing device nodes can be reached by 
following a symlink called subsystem
- And I observed that cycles in sysfs are never caused by the subsystem 
symlinks

Cheers
Thomas Mathys

Mike Cashwell wrote:
> Greetings all,
>
> I'm bringing up a completely new toolchain (gcc 4.1.1; glibc 2.5;  
> linux 2.6.20.4; BB 1.4.2) on an ARM v4tle board. (Whew!)
>
> I'm having trouble getting mdev to fully populate /dev. Specifically,  
> I'm not getting entries for my 3 physical serial ports. I've scoured  
> the mailing list archives and found a few near-misses, but nothing  
> specific.
>
> My hunch is that my sysfs is putting in symlinks in such a way that  
> mdev is having trouble. I've included what I think is the relevant  
> info below.
>
> Anyone have any ideas? Maybe there's some BB config setting I don't  
> have set? My confusion is why mdev is getting the block devices right  
> but not the character ones.
>
> Thanks for any assistance!
> -Mike
>
> ------ /dev and /sys info -----
>
> dm17:/dev $ ls -la
> drwxrwxrwt    4 root     root          640 Jan  1 00:01 .
> drwxrwxr-x   15 500      500          4096 Apr 18  2007 ..
> crw-------    1 root     root       5,   1 Jan  1 04:58 console
> srw-rw-rw-    1 root     root            0 Jan  1 00:01 log
> brw-rw----    1 root     root       7,   0 Jan  1 00:01 loop0
> brw-rw----    1 root     root       7,   1 Jan  1 00:01 loop1
> brw-rw----    1 root     root       7,   2 Jan  1 00:01 loop2
> brw-rw----    1 root     root       7,   3 Jan  1 00:01 loop3
> brw-rw----    1 root     root       7,   4 Jan  1 00:01 loop4
> brw-rw----    1 root     root       7,   5 Jan  1 00:01 loop5
> brw-rw----    1 root     root       7,   6 Jan  1 00:01 loop6
> brw-rw----    1 root     root       7,   7 Jan  1 00:01 loop7
> crw-r--r--    1 root     root       1,   3 Jan  1 00:00 null
> drwxr-xr-x    2 root     root           40 Jan  1 00:00 pts
> brw-rw----    1 root     root       1,   0 Jan  1 00:01 ram0
> brw-rw----    1 root     root       1,   1 Jan  1 00:01 ram1
> brw-rw----    1 root     root       1,  10 Jan  1 00:01 ram10
> brw-rw----    1 root     root       1,  11 Jan  1 00:01 ram11
> brw-rw----    1 root     root       1,  12 Jan  1 00:01 ram12
> brw-rw----    1 root     root       1,  13 Jan  1 00:01 ram13
> brw-rw----    1 root     root       1,  14 Jan  1 00:01 ram14
> brw-rw----    1 root     root       1,  15 Jan  1 00:01 ram15
> brw-rw----    1 root     root       1,   2 Jan  1 00:01 ram2
> brw-rw----    1 root     root       1,   3 Jan  1 00:01 ram3
> brw-rw----    1 root     root       1,   4 Jan  1 00:01 ram4
> brw-rw----    1 root     root       1,   5 Jan  1 00:01 ram5
> brw-rw----    1 root     root       1,   6 Jan  1 00:01 ram6
> brw-rw----    1 root     root       1,   7 Jan  1 00:01 ram7
> brw-rw----    1 root     root       1,   8 Jan  1 00:01 ram8
> brw-rw----    1 root     root       1,   9 Jan  1 00:01 ram9
> crw-rw----    1 root     root     254,   0 Jan  1 00:01 rtc0
> drwxr-xr-x    2 root     root           40 Jan  1 00:00 shm
> dm17:/dev $ cd /sys
> dm17:/sys $ ls
> block     class     firmware  kernel    power
> bus       devices   fs        module
> dm17:/sys $ cd class/
> dm17:/sys/class $ ls -la
> drwxr-xr-x    9 root     root            0 Jan  1  1970 .
> drwxr-xr-x   11 root     root            0 Jan  1  1970 ..
> drwxr-xr-x    2 root     root            0 Jan  1 00:01 mem
> drwxr-xr-x    2 root     root            0 Jan  1 00:01 misc
> drwxr-xr-x    2 root     root            0 Jan  1  1970 mtd
> drwxr-xr-x    4 root     root            0 Jan  1  1970 net
> drwxr-xr-x    3 root     root            0 Jan  1  1970 rtc
> drwxr-xr-x    3 root     root            0 Jan  1  1970 rtc-dev
> drwxr-xr-x    2 root     root            0 Jan  1 00:01 tty
> dm17:/sys/class $ cd tty/
> dm17:/sys/class/tty $ ls -la
> drwxr-xr-x    2 root     root            0 Jan  1 00:01 .
> drwxr-xr-x    9 root     root            0 Jan  1  1970 ..
> lrwxrwxrwx    1 root     root            0 Jan  1 00:01 console - 
>  > ../../devices/virtual/tty/console
> lrwxrwxrwx    1 root     root            0 Jan  1 00:01 ptmx -> ../../ 
> devices/virtual/tty/ptmx
> lrwxrwxrwx    1 root     root            0 Jan  1 00:01 tty -> ../../ 
> devices/virtual/tty/tty
> lrwxrwxrwx    1 root     root            0 Jan  1 00:01 ttyS0 - 
>  > ../../devices/platform/serial8250.0/ttyS0
> lrwxrwxrwx    1 root     root            0 Jan  1 00:01 ttyS1 - 
>  > ../../devices/platform/serial8250.0/ttyS1
> lrwxrwxrwx    1 root     root            0 Jan  1 00:01 ttyS2 - 
>  > ../../devices/platform/serial8250.0/ttyS2
> dm17:/sys/class/tty $ cat ttyS0/dev
> 4:64
> dm17:/sys/class/tty $ cat /proc/devices
> Character devices:
>    1 mem
>    4 ttyS
>    5 /dev/tty
>    5 /dev/console
>    5 /dev/ptmx
> 10 misc
> 90 mtd
> 128 ptm
> 136 pts
> 254 rtc
>
> Block devices:
>    1 ramdisk
>    7 loop
> 31 mtdblock
>
>
> _______________________________________________
> busybox mailing list
> busybox@busybox.net
> http://busybox.net/cgi-bin/mailman/listinfo/busybox
>   

_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox

From bugs@busybox.net Sun Apr 29 19:44:00 2007
Delivered-To: vda.linux@gmail.com
Received: by 10.78.42.5 with SMTP id p5cs20068hup;
        Sun, 29 Apr 2007 10:45:23 -0700 (PDT)
Received: by 10.114.60.19 with SMTP id i19mr1717314waa.1177868722643;
        Sun, 29 Apr 2007 10:45:22 -0700 (PDT)
Return-Path: <busybox-cvs-bounces@busybox.net>
Received: from busybox.net (busybox.net [140.211.166.42])
        by mx.google.com with ESMTP id m29si6330145poh.2007.04.29.10.45.22;
        Sun, 29 Apr 2007 10:45:22 -0700 (PDT)
Received-SPF: pass (google.com: domain of busybox-cvs-bounces@busybox.net designates 140.211.166.42 as permitted sender)
Received: from localhost.localdomain (busybox [127.0.0.1])
	by busybox.net (BusyBox.Net Mail Daemon) with ESMTP id 69ABC48022;
	Sun, 29 Apr 2007 10:44:01 -0700 (PDT)
X-Original-To: busybox-cvs@busybox.net
Delivered-To: busybox-cvs@busybox.net
Received: by busybox.net (BusyBox.Net Mail Daemon, from userid 33)
	id E820748021; Sun, 29 Apr 2007 10:44:00 -0700 (PDT)
To: busybox-cvs@busybox.net
Subject: [BusyBox 0001329]: Patch for "util-linux/mdev.c": make it able to
	create symlinks and subdirectories
Date: Sun, 29 Apr 2007 10:44:00 -0700
From: bugs@busybox.net
Message-ID: <ddfca9b71d8ec2d2d2fbac93a145b5e5@bugs.busybox.net>
X-Priority: 3
X-Mailer: PHPMailer [version 1.72]
MIME-Version: 1.0
X-BeenThere: busybox-cvs@busybox.net
X-Mailman-Version: 2.1.9
Precedence: list
Reply-To: busybox@busybox.net
List-Id: List of all SVN commit messages for BusyBox <busybox-cvs.busybox.net>
List-Unsubscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox-cvs>,
	<mailto:busybox-cvs-request@busybox.net?subject=unsubscribe>
List-Archive: <http://busybox.net/lists/busybox-cvs>
List-Post: <mailto:busybox-cvs@busybox.net>
List-Help: <mailto:busybox-cvs-request@busybox.net?subject=help>
List-Subscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox-cvs>,
	<mailto:busybox-cvs-request@busybox.net?subject=subscribe>
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: busybox-cvs-bounces@busybox.net
Errors-To: busybox-cvs-bounces@busybox.net
Status: RO
X-Status: RC
X-KMail-EncryptionState: N
X-KMail-SignatureState: N
X-KMail-MDN-Sent:  


The following issue has been SUBMITTED. 
====================================================================== 
http://busybox.net/bugs/view.php?id=1329 
====================================================================== 
Reported By:                Souf
Assigned To:                BusyBox
====================================================================== 
Project:                    BusyBox
Issue ID:                   1329
Category:                   New Features
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     assigned
====================================================================== 
Date Submitted:             04-29-2007 10:44 PDT
Last Modified:              04-29-2007 10:44 PDT
====================================================================== 
Summary:                    Patch for "util-linux/mdev.c": make it able to
create symlinks and subdirectories
Description: 
This patch adds to mdev.c the ability to create symlinks and
subdirectories:
examples:
stderr -> /proc/self/fd/2

pcmC[0-9]D[0-9]c 0:0 0666 >> /dev/snd/ 0755

modified files:
util-linux/mdev.c
util-linux/Config.in
docs/mdev.txt

The patch corrects also the bug 0001299

I wish that this patch be deeply tested before a possible integration


====================================================================== 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
04-29-07 10:44  Souf           New Issue                                    
04-29-07 10:44  Souf           Status                   new => assigned     
04-29-07 10:44  Souf           Assigned To               => BusyBox         
04-29-07 10:44  Souf           File Added: mdev.patch                       
======================================================================

_______________________________________________
busybox-cvs mailing list
busybox-cvs@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox-cvs

From bugs@busybox.net Wed May  2 19:57:44 2007
Delivered-To: vda.linux@gmail.com
Received: by 10.78.52.5 with SMTP id z5cs52729huz;
        Wed, 2 May 2007 10:57:50 -0700 (PDT)
Received: by 10.114.111.1 with SMTP id j1mr325947wac.1178128670019;
        Wed, 02 May 2007 10:57:50 -0700 (PDT)
Return-Path: <busybox-cvs-bounces@busybox.net>
Received: from busybox.net (busybox.net [140.211.166.42])
        by mx.google.com with ESMTP id t1si2792941poh.2007.05.02.10.57.49;
        Wed, 02 May 2007 10:57:49 -0700 (PDT)
Received-SPF: pass (google.com: domain of busybox-cvs-bounces@busybox.net designates 140.211.166.42 as permitted sender)
Received: from localhost.localdomain (busybox [127.0.0.1])
	by busybox.net (BusyBox.Net Mail Daemon) with ESMTP id 8C2D8485CF;
	Wed,  2 May 2007 10:57:48 -0700 (PDT)
X-Original-To: busybox-cvs@busybox.net
Delivered-To: busybox-cvs@busybox.net
Received: by busybox.net (BusyBox.Net Mail Daemon, from userid 33)
	id 87696485C8; Wed,  2 May 2007 10:57:44 -0700 (PDT)
To: busybox-cvs@busybox.net
Subject: [BusyBox 0001329]: Patch for "util-linux/mdev.c": make it able to
	create symlinks and subdirectories
Date: Wed, 2 May 2007 10:57:44 -0700
From: bugs@busybox.net
Message-ID: <8681d9dfdc725ccbcc21fe3bf42b7eb3@busybox.net>
X-Priority: 3
X-Mailer: PHPMailer [version 1.72]
MIME-Version: 1.0
X-BeenThere: busybox-cvs@busybox.net
X-Mailman-Version: 2.1.9
Precedence: list
Reply-To: busybox@busybox.net
List-Id: List of all SVN commit messages for BusyBox <busybox-cvs.busybox.net>
List-Unsubscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox-cvs>,
	<mailto:busybox-cvs-request@busybox.net?subject=unsubscribe>
List-Archive: <http://busybox.net/lists/busybox-cvs>
List-Post: <mailto:busybox-cvs@busybox.net>
List-Help: <mailto:busybox-cvs-request@busybox.net?subject=help>
List-Subscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox-cvs>,
	<mailto:busybox-cvs-request@busybox.net?subject=subscribe>
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: busybox-cvs-bounces@busybox.net
Errors-To: busybox-cvs-bounces@busybox.net
Status: RO
X-Status: RC
X-KMail-EncryptionState: N
X-KMail-SignatureState: N
X-KMail-MDN-Sent:  


A NOTE has been added to this issue. 
====================================================================== 
http://busybox.net/bugs/view.php?id=1329 
====================================================================== 
Reported By:                Souf
Assigned To:                BusyBox
====================================================================== 
Project:                    BusyBox
Issue ID:                   1329
Category:                   New Features
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     assigned
====================================================================== 
Date Submitted:             04-29-2007 10:44 PDT
Last Modified:              05-02-2007 10:57 PDT
====================================================================== 
Summary:                    Patch for "util-linux/mdev.c": make it able to
create symlinks and subdirectories
Description: 
This patch adds to mdev.c the ability to create symlinks and
subdirectories:
examples:
stderr -> /proc/self/fd/2

pcmC[0-9]D[0-9]c 0:0 0666 >> /dev/snd/ 0755

modified files:
util-linux/mdev.c
util-linux/Config.in
docs/mdev.txt

The patch corrects also the bug 0001299

I wish that this patch be deeply tested before a possible integration


====================================================================== 

---------------------------------------------------------------------- 
 vapier - 05-02-07 10:57  
---------------------------------------------------------------------- 
you removed support for program execution which is not desirable

i'll post a diff patch to the busybox mailing list we've been using in
Blackfin/uClinux-dist 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
04-29-07 10:44  Souf           New Issue                                    
04-29-07 10:44  Souf           Status                   new => assigned     
04-29-07 10:44  Souf           Assigned To               => BusyBox         
04-29-07 10:44  Souf           File Added: mdev.patch                       
05-02-07 10:57  vapier         Note Added: 0002336                          
======================================================================

_______________________________________________
busybox-cvs mailing list
busybox-cvs@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox-cvs

From vapier@gentoo.org Wed May  2 23:54:36 2007
Delivered-To: vda.linux@gmail.com
Received: by 10.78.52.5 with SMTP id z5cs68537huz;
        Wed, 2 May 2007 14:54:45 -0700 (PDT)
Received: by 10.114.178.1 with SMTP id a1mr377010waf.1178142884658;
        Wed, 02 May 2007 14:54:44 -0700 (PDT)
Return-Path: <busybox-bounces@busybox.net>
Received: from busybox.net (busybox.osuosl.org [140.211.166.42])
        by mx.google.com with ESMTP id q20si3447287pog.2007.05.02.14.54.43;
        Wed, 02 May 2007 14:54:44 -0700 (PDT)
Received-SPF: pass (google.com: domain of busybox-bounces@busybox.net designates 140.211.166.42 as permitted sender)
Received: from localhost.localdomain (busybox [127.0.0.1])
	by busybox.net (BusyBox.Net Mail Daemon) with ESMTP id F284E485DA;
	Wed,  2 May 2007 14:54:31 -0700 (PDT)
X-Original-To: busybox@busybox.net
Delivered-To: busybox@busybox.net
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	by busybox.net (BusyBox.Net Mail Daemon) with ESMTP id 32D5B485D8
	for <busybox@busybox.net>; Wed,  2 May 2007 14:54:27 -0700 (PDT)
Received: from ip6-localhost (localhost [127.0.0.1])
	by smtp.gentoo.org (Postfix) with ESMTP id C41EB64DDF
	for <busybox@busybox.net>; Wed,  2 May 2007 21:54:26 +0000 (UTC)
From: Mike Frysinger <vapier@gentoo.org>
Organization: wh0rd.org
To: busybox@busybox.net
Subject: [patch/rfc] add fourth field to mdev.conf for subdirs
Date: Wed, 2 May 2007 17:54:36 -0400
User-Agent: KMail/1.9.6
MIME-Version: 1.0
Content-Type: Multipart/Mixed;
  boundary="Boundary-00=_ciQOGNJU3xkeQJR"
Message-Id: <200705021754.36449.vapier@gentoo.org>
X-BeenThere: busybox@busybox.net
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Discussion and development of BusyBox <busybox.busybox.net>
List-Unsubscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox>,
	<mailto:busybox-request@busybox.net?subject=unsubscribe>
List-Archive: <http://busybox.net/lists/busybox>
List-Post: <mailto:busybox@busybox.net>
List-Help: <mailto:busybox-request@busybox.net?subject=help>
List-Subscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox>,
	<mailto:busybox-request@busybox.net?subject=subscribe>
Sender: busybox-bounces@busybox.net
Errors-To: busybox-bounces@busybox.net
Status: RO
X-Status: RT
X-KMail-EncryptionState: N
X-KMail-SignatureState: N
X-KMail-MDN-Sent:  

--Boundary-00=_ciQOGNJU3xkeQJR
Content-Type: multipart/signed;
  boundary="nextPart1206741.HAOpesnNYk";
  protocol="application/pgp-signature";
  micalg=pgp-sha1
Content-Transfer-Encoding: 7bit

--nextPart1206741.HAOpesnNYk
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

there are a few common/important set of device nodes that only work when in=
=20
the proper subdirectory ... for example, all of ALSA userland requires the=
=20
sound nodes to be in /dev/snd/ and all of the input device nodes need to be=
=20
in /dev/input/

we're using the attached patch by Sonic Zhang in our Blackfin distribution =
=2E..=20
it simply changes the syntax from:
<device regex> <uid>:<gid> <octal perms> [command]
to:
<device regex> <uid>:<gid> <octal perms> [subdir] [<@|$|*> command]

the patch isnt 100% correct right now ... i'd like to see what ideas other=
=20
people have
=2Dmike

--nextPart1206741.HAOpesnNYk
Content-Type: application/pgp-signature; name=signature.asc 
Content-Description: This is a digitally signed message part.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.3 (GNU/Linux)

iQIVAwUARjkInEFjO5/oN/WBAQKE0A/9FV7cxd/oz6sGQspvBYiUyiXEBpHnQ489
j8nwTXKRRU/Xekv9gI8YgidlixUczd/FYzH+CeH3an35L99e1xnL9cX4mt4cVNV1
2TAXILs0EDagyo0w5V5RbFDpCLDZyTHX4d6r+AOmHtF5Xq/ysa3pmn30RnYYmQbv
6r3boYMaePO1dl5sRmswwc8nNjP9BoDatZRtARNTPgGqs7NPOT4mbCPkWKCzJCCP
KaiGgbdXDSs5z++/uogshSRJd7/FNXpdyL4MiE3gVv8Sq/IxLCCNjQuk6ovon0Xd
soB/KH6f5E5rozBI3sJQqmny17k+FkVFbrhTxLh33WF3aD8AtQAzCus1BsFuXyq7
dy2tnv+D8d4Ei3vjCh8j7pIbGbasfaLlhi4KsE18lihRWFnv7Lrzf83Bet/G78yv
NBkr5bJIVqmc2NapuwsrpHRlu//OSe9kClACaSIsgn2yF+rVaUm/vsOc4SVxELr6
PG3rIlxxPJa3WSXdylhLDrsxxJiPdpVkGh2AsW1IUO3IHlliqTtUP0yopiApQXUq
p2N1tswfQryTe6waC+xld7DXjxi08Rj160WjhuuS20cqDVd8rfOXpzRrVBq3fRQ6
8AMMRoaREl9OfFZVodJtPJDWU5gOByEKwC9Wq5Ili52NMb9ZsJ3VK36OEyRTUcRA
JWDTSbw0ApI=
=bMKp
-----END PGP SIGNATURE-----

--nextPart1206741.HAOpesnNYk--

--Boundary-00=_ciQOGNJU3xkeQJR
Content-Type: text/x-diff;
  charset="us-ascii";
  name="mdev-subdirs.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
	filename="mdev-subdirs.patch"

--- trunk/user/busybox/util-linux/mdev.c	2007/04/04 08:06:03	5168
+++ trunk/user/busybox/util-linux/mdev.c	2007/04/04 09:52:50	5169
@@ -25,6 +25,7 @@
 static void make_device(char *path, int delete)
 {
 	char *device_name;
+	static char dev_path[255];
 	int major, minor, type, len;
 	int mode = 0660;
 	uid_t uid = 0;
@@ -48,6 +49,7 @@
 
 	device_name = strrchr(path, '/') + 1;
 	type = path[5]=='c' ? S_IFCHR : S_IFBLK;
+	strcpy(dev_path, "/dev/");
 
 	/* If we have a config file, look up permissions for this device */
 
@@ -76,8 +78,8 @@
 			for (end=pos; end-conf<len && *end!='\n'; end++)
 				;
 
-			/* Three fields: regex, uid:gid, mode */
-			for (field=0; field < (3 + ENABLE_FEATURE_MDEV_EXEC);
+			/* 4 fields: regex, uid:gid, mode, subdir */
+			for (field=0; field < (4 + ENABLE_FEATURE_MDEV_EXEC);
 					field++)
 			{
 				/* Skip whitespace */
@@ -90,19 +92,17 @@
 				if (field == 0) {
 					/* Regex to match this device */
 
-					char *regex = strndupa(pos, end2-pos);
+					char *regex = strndupa(pos, end2-pos-1);
 					regex_t match;
 					regmatch_t off;
 					int result;
 
 					/* Is this it? */
 					xregcomp(&match,regex, REG_EXTENDED);
-					result = regexec(&match, device_name, 1, &off, 0);
+					result = regexec(&match, path, 1, &off, 0);
 					regfree(&match);
 
-					/* If not this device, skip rest of line */
-					if (result || off.rm_so
-							|| off.rm_eo != strlen(device_name))
+					if (result)
 						break;
 				}
 				if (field == 1) {
@@ -126,7 +126,7 @@
 					s++;
 					/* parse GID */
 					gid = strtoul(s, &s2, 10);
-					if (end2 != s2) {
+					if (end2-1 != s2) {
 						struct group *grp;
 						grp = getgrnam(strndupa(s, end2-s));
 						if (!grp) break;
@@ -137,9 +137,16 @@
 					/* mode */
 
 					mode = strtoul(pos, &pos, 8);
-					if (pos != end2) break;
+					if (pos != end2-1) break;
 				}
-				if (ENABLE_FEATURE_MDEV_EXEC && field == 3) {
+				if (field == 3) {
+					/* get subdir */
+
+					strncat(dev_path, strndupa(pos, end2-pos), 250);
+					strcat(dev_path, "/");
+
+				}
+				if (ENABLE_FEATURE_MDEV_EXEC && field == 4) {
 					// Command to run
 					char *s = "@$*", *s2;
 					s2 = strchr(s, *pos++);
@@ -157,7 +164,7 @@
 
 			/* Did everything parse happily? */
 
-			if (field > 2) break;
+			if (field > 3) break;
 			if (field) bb_error_msg_and_die("bad line %d",line);
 
 			/* Next line */
@@ -170,7 +177,9 @@
 	umask(0);
 	if (!delete) {
 		if (sscanf(temp, "%d:%d", &major, &minor) != 2) return;
-		if (mknod(device_name, mode | type, makedev(major, minor)) && errno != EEXIST)
+		mkdir(dev_path, 0644);
+		strcat(dev_path, device_name);
+		if (mknod(dev_path, mode | type, makedev(major, minor)) && errno != EEXIST)
 			bb_perror_msg_and_die("mknod %s", device_name);
 
 		if (major == bbg.root_major && minor == bbg.root_minor)
@@ -191,7 +200,7 @@
 		free(command);
 		if (rc == -1) bb_perror_msg_and_die("cannot run %s", command);
 	}
-	if (delete) unlink(device_name);
+	if (delete) unlink(dev_path);
 }
 
 /* Recursive search of /sys/block or /sys/class.  path must be a writeable

--Boundary-00=_ciQOGNJU3xkeQJR
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox
--Boundary-00=_ciQOGNJU3xkeQJR--

From vapier@gentoo.org Wed May  2 23:54:36 2007
Delivered-To: vda.linux@gmail.com
Received: by 10.78.52.5 with SMTP id z5cs68537huz;
        Wed, 2 May 2007 14:54:45 -0700 (PDT)
Received: by 10.114.178.1 with SMTP id a1mr377010waf.1178142884658;
        Wed, 02 May 2007 14:54:44 -0700 (PDT)
Return-Path: <busybox-bounces@busybox.net>
Received: from busybox.net (busybox.osuosl.org [140.211.166.42])
        by mx.google.com with ESMTP id q20si3447287pog.2007.05.02.14.54.43;
        Wed, 02 May 2007 14:54:44 -0700 (PDT)
Received-SPF: pass (google.com: domain of busybox-bounces@busybox.net designates 140.211.166.42 as permitted sender)
Received: from localhost.localdomain (busybox [127.0.0.1])
	by busybox.net (BusyBox.Net Mail Daemon) with ESMTP id F284E485DA;
	Wed,  2 May 2007 14:54:31 -0700 (PDT)
X-Original-To: busybox@busybox.net
Delivered-To: busybox@busybox.net
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	by busybox.net (BusyBox.Net Mail Daemon) with ESMTP id 32D5B485D8
	for <busybox@busybox.net>; Wed,  2 May 2007 14:54:27 -0700 (PDT)
Received: from ip6-localhost (localhost [127.0.0.1])
	by smtp.gentoo.org (Postfix) with ESMTP id C41EB64DDF
	for <busybox@busybox.net>; Wed,  2 May 2007 21:54:26 +0000 (UTC)
From: Mike Frysinger <vapier@gentoo.org>
Organization: wh0rd.org
To: busybox@busybox.net
Subject: [patch/rfc] add fourth field to mdev.conf for subdirs
Date: Wed, 2 May 2007 17:54:36 -0400
User-Agent: KMail/1.9.6
MIME-Version: 1.0
Content-Type: Multipart/Mixed;
  boundary="Boundary-00=_ciQOGNJU3xkeQJR"
Message-Id: <200705021754.36449.vapier@gentoo.org>
X-BeenThere: busybox@busybox.net
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Discussion and development of BusyBox <busybox.busybox.net>
List-Unsubscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox>,
	<mailto:busybox-request@busybox.net?subject=unsubscribe>
List-Archive: <http://busybox.net/lists/busybox>
List-Post: <mailto:busybox@busybox.net>
List-Help: <mailto:busybox-request@busybox.net?subject=help>
List-Subscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox>,
	<mailto:busybox-request@busybox.net?subject=subscribe>
Sender: busybox-bounces@busybox.net
Errors-To: busybox-bounces@busybox.net
Status: RO
X-Status: RT
X-KMail-EncryptionState: N
X-KMail-SignatureState: N
X-KMail-MDN-Sent:  

--Boundary-00=_ciQOGNJU3xkeQJR
Content-Type: multipart/signed;
  boundary="nextPart1206741.HAOpesnNYk";
  protocol="application/pgp-signature";
  micalg=pgp-sha1
Content-Transfer-Encoding: 7bit

--nextPart1206741.HAOpesnNYk
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

there are a few common/important set of device nodes that only work when in=
=20
the proper subdirectory ... for example, all of ALSA userland requires the=
=20
sound nodes to be in /dev/snd/ and all of the input device nodes need to be=
=20
in /dev/input/

we're using the attached patch by Sonic Zhang in our Blackfin distribution =
=2E..=20
it simply changes the syntax from:
<device regex> <uid>:<gid> <octal perms> [command]
to:
<device regex> <uid>:<gid> <octal perms> [subdir] [<@|$|*> command]

the patch isnt 100% correct right now ... i'd like to see what ideas other=
=20
people have
=2Dmike

--nextPart1206741.HAOpesnNYk
Content-Type: application/pgp-signature; name=signature.asc 
Content-Description: This is a digitally signed message part.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.3 (GNU/Linux)

iQIVAwUARjkInEFjO5/oN/WBAQKE0A/9FV7cxd/oz6sGQspvBYiUyiXEBpHnQ489
j8nwTXKRRU/Xekv9gI8YgidlixUczd/FYzH+CeH3an35L99e1xnL9cX4mt4cVNV1
2TAXILs0EDagyo0w5V5RbFDpCLDZyTHX4d6r+AOmHtF5Xq/ysa3pmn30RnYYmQbv
6r3boYMaePO1dl5sRmswwc8nNjP9BoDatZRtARNTPgGqs7NPOT4mbCPkWKCzJCCP
KaiGgbdXDSs5z++/uogshSRJd7/FNXpdyL4MiE3gVv8Sq/IxLCCNjQuk6ovon0Xd
soB/KH6f5E5rozBI3sJQqmny17k+FkVFbrhTxLh33WF3aD8AtQAzCus1BsFuXyq7
dy2tnv+D8d4Ei3vjCh8j7pIbGbasfaLlhi4KsE18lihRWFnv7Lrzf83Bet/G78yv
NBkr5bJIVqmc2NapuwsrpHRlu//OSe9kClACaSIsgn2yF+rVaUm/vsOc4SVxELr6
PG3rIlxxPJa3WSXdylhLDrsxxJiPdpVkGh2AsW1IUO3IHlliqTtUP0yopiApQXUq
p2N1tswfQryTe6waC+xld7DXjxi08Rj160WjhuuS20cqDVd8rfOXpzRrVBq3fRQ6
8AMMRoaREl9OfFZVodJtPJDWU5gOByEKwC9Wq5Ili52NMb9ZsJ3VK36OEyRTUcRA
JWDTSbw0ApI=
=bMKp
-----END PGP SIGNATURE-----

--nextPart1206741.HAOpesnNYk--

--Boundary-00=_ciQOGNJU3xkeQJR
Content-Type: text/x-diff;
  charset="us-ascii";
  name="mdev-subdirs.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
	filename="mdev-subdirs.patch"

--- trunk/user/busybox/util-linux/mdev.c	2007/04/04 08:06:03	5168
+++ trunk/user/busybox/util-linux/mdev.c	2007/04/04 09:52:50	5169
@@ -25,6 +25,7 @@
 static void make_device(char *path, int delete)
 {
 	char *device_name;
+	static char dev_path[255];
 	int major, minor, type, len;
 	int mode = 0660;
 	uid_t uid = 0;
@@ -48,6 +49,7 @@
 
 	device_name = strrchr(path, '/') + 1;
 	type = path[5]=='c' ? S_IFCHR : S_IFBLK;
+	strcpy(dev_path, "/dev/");
 
 	/* If we have a config file, look up permissions for this device */
 
@@ -76,8 +78,8 @@
 			for (end=pos; end-conf<len && *end!='\n'; end++)
 				;
 
-			/* Three fields: regex, uid:gid, mode */
-			for (field=0; field < (3 + ENABLE_FEATURE_MDEV_EXEC);
+			/* 4 fields: regex, uid:gid, mode, subdir */
+			for (field=0; field < (4 + ENABLE_FEATURE_MDEV_EXEC);
 					field++)
 			{
 				/* Skip whitespace */
@@ -90,19 +92,17 @@
 				if (field == 0) {
 					/* Regex to match this device */
 
-					char *regex = strndupa(pos, end2-pos);
+					char *regex = strndupa(pos, end2-pos-1);
 					regex_t match;
 					regmatch_t off;
 					int result;
 
 					/* Is this it? */
 					xregcomp(&match,regex, REG_EXTENDED);
-					result = regexec(&match, device_name, 1, &off, 0);
+					result = regexec(&match, path, 1, &off, 0);
 					regfree(&match);
 
-					/* If not this device, skip rest of line */
-					if (result || off.rm_so
-							|| off.rm_eo != strlen(device_name))
+					if (result)
 						break;
 				}
 				if (field == 1) {
@@ -126,7 +126,7 @@
 					s++;
 					/* parse GID */
 					gid = strtoul(s, &s2, 10);
-					if (end2 != s2) {
+					if (end2-1 != s2) {
 						struct group *grp;
 						grp = getgrnam(strndupa(s, end2-s));
 						if (!grp) break;
@@ -137,9 +137,16 @@
 					/* mode */
 
 					mode = strtoul(pos, &pos, 8);
-					if (pos != end2) break;
+					if (pos != end2-1) break;
 				}
-				if (ENABLE_FEATURE_MDEV_EXEC && field == 3) {
+				if (field == 3) {
+					/* get subdir */
+
+					strncat(dev_path, strndupa(pos, end2-pos), 250);
+					strcat(dev_path, "/");
+
+				}
+				if (ENABLE_FEATURE_MDEV_EXEC && field == 4) {
 					// Command to run
 					char *s = "@$*", *s2;
 					s2 = strchr(s, *pos++);
@@ -157,7 +164,7 @@
 
 			/* Did everything parse happily? */
 
-			if (field > 2) break;
+			if (field > 3) break;
 			if (field) bb_error_msg_and_die("bad line %d",line);
 
 			/* Next line */
@@ -170,7 +177,9 @@
 	umask(0);
 	if (!delete) {
 		if (sscanf(temp, "%d:%d", &major, &minor) != 2) return;
-		if (mknod(device_name, mode | type, makedev(major, minor)) && errno != EEXIST)
+		mkdir(dev_path, 0644);
+		strcat(dev_path, device_name);
+		if (mknod(dev_path, mode | type, makedev(major, minor)) && errno != EEXIST)
 			bb_perror_msg_and_die("mknod %s", device_name);
 
 		if (major == bbg.root_major && minor == bbg.root_minor)
@@ -191,7 +200,7 @@
 		free(command);
 		if (rc == -1) bb_perror_msg_and_die("cannot run %s", command);
 	}
-	if (delete) unlink(device_name);
+	if (delete) unlink(dev_path);
 }
 
 /* Recursive search of /sys/block or /sys/class.  path must be a writeable

--Boundary-00=_ciQOGNJU3xkeQJR
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox
--Boundary-00=_ciQOGNJU3xkeQJR--

From natanael.copa@gmail.com Thu May  3 08:29:51 2007
Delivered-To: vda.linux@gmail.com
Received: by 10.78.52.5 with SMTP id z5cs94499huz;
        Wed, 2 May 2007 23:30:11 -0700 (PDT)
Received: by 10.115.33.1 with SMTP id l1mr557294waj.1178173810242;
        Wed, 02 May 2007 23:30:10 -0700 (PDT)
Return-Path: <busybox-bounces@busybox.net>
Received: from busybox.net (busybox.net [140.211.166.42])
        by mx.google.com with ESMTP id q18si4903124pog.2007.05.02.23.30.09;
        Wed, 02 May 2007 23:30:10 -0700 (PDT)
Received-SPF: pass (google.com: domain of busybox-bounces@busybox.net designates 140.211.166.42 as permitted sender)
Received: from localhost.localdomain (busybox [127.0.0.1])
	by busybox.net (BusyBox.Net Mail Daemon) with ESMTP id 286FA485E0;
	Wed,  2 May 2007 23:29:59 -0700 (PDT)
X-Original-To: busybox@busybox.net
Delivered-To: busybox@busybox.net
Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.171])
	by busybox.net (BusyBox.Net Mail Daemon) with ESMTP id EE181485DC
	for <busybox@busybox.net>; Wed,  2 May 2007 23:29:56 -0700 (PDT)
Received: by ug-out-1314.google.com with SMTP id j3so356904ugf
	for <busybox@busybox.net>; Wed, 02 May 2007 23:29:55 -0700 (PDT)
Received: by 10.82.148.7 with SMTP id v7mr3208577bud.1178173794996;
	Wed, 02 May 2007 23:29:54 -0700 (PDT)
Received: from ?192.168.65.211? ( [213.234.126.134])
	by mx.google.com with ESMTP id z34sm2457623ikz.2007.05.02.23.29.52;
	Wed, 02 May 2007 23:29:53 -0700 (PDT)
Subject: Re: [patch/rfc] add fourth field to mdev.conf for subdirs
From: Natanael Copa <natanael.copa@gmail.com>
To: Mike Frysinger <vapier@gentoo.org>
In-Reply-To: <200705021754.36449.vapier@gentoo.org>
References: <200705021754.36449.vapier@gentoo.org>
Date: Thu, 03 May 2007 08:29:51 +0200
Message-Id: <1178173791.18554.20.camel@localhost>
Mime-Version: 1.0
X-Mailer: Evolution 2.8.3 
Cc: busybox@busybox.net
X-BeenThere: busybox@busybox.net
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Discussion and development of BusyBox <busybox.busybox.net>
List-Unsubscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox>,
	<mailto:busybox-request@busybox.net?subject=unsubscribe>
List-Archive: <http://busybox.net/lists/busybox>
List-Post: <mailto:busybox@busybox.net>
List-Help: <mailto:busybox-request@busybox.net?subject=help>
List-Subscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox>,
	<mailto:busybox-request@busybox.net?subject=subscribe>
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: busybox-bounces@busybox.net
Errors-To: busybox-bounces@busybox.net
Status: RO
X-Status: RC
X-KMail-EncryptionState: N
X-KMail-SignatureState: N
X-KMail-MDN-Sent:  

On Wed, 2007-05-02 at 17:54 -0400, Mike Frysinger wrote:
> there are a few common/important set of device nodes that only work when in 
> the proper subdirectory ... for example, all of ALSA userland requires the 
> sound nodes to be in /dev/snd/ and all of the input device nodes need to be 
> in /dev/input/
> 
> we're using the attached patch by Sonic Zhang in our Blackfin distribution ... 
> it simply changes the syntax from:
> <device regex> <uid>:<gid> <octal perms> [command]
> to:
> <device regex> <uid>:<gid> <octal perms> [subdir] [<@|$|*> command]

Sometimes it is good to be able to rename the device itself too. For
example, zapctl should go to zap/ctl and not zap/zapctl

What about this syntax:
<device regex> <uid>:<gid> <octal perms> [subdir [dest]] [<@|$|*> command]

or:
<device regex> <uid>:<gid> <octal perms> [[subdir/][dest]] [<@|$|*> command]

where this happens if dest is specified:

if last char in param is '/' then
	mkdir -p $param
else
	mkdir -p $(dirname $param)
	MDEV=$(basename $param)
fi
create $MDEV

> the patch isnt 100% correct right now ... i'd like to see what ideas other 
> people have

I use a script, /lib/mdev/subdir_dev:

#!/bin/sh

# scripts that moves devices to the $1/ subdir.

if [ "$ACTION" = remove ] ; then
	mv $1/$MDEV $MDEV
	rmdir $1 2>/dev/null
else
	mkdir -p $1 
	mv $MDEV $1/$2
fi

and the mdev.conf looks like this:

# alsa sound devices
pcm.*		root:audio 0660	*/lib/mdev/subdir_dev snd
...

# zaptel devices
zapctl		root:dialout 0660 */lib/mdev/subdir_dev zap ctl
zaptimer	root:dialout 0660 */lib/mdev/subdir_dev zap timer
...


I copied all my mdev stuff here:
http://dev.alpinelinux.org/~ncopa/mdev/

(I have a script that will differ usb disks from scsi disks and that
will load modules for usb devices (like webcams)

It would be very nice if mdev could handle subdirs and renaming devices
without depending on external scripts.

Natanael Copa

_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox

From vapier@gentoo.org Thu May  3 08:49:55 2007
Delivered-To: vda.linux@gmail.com
Received: by 10.78.52.5 with SMTP id z5cs95583huz;
        Wed, 2 May 2007 23:50:04 -0700 (PDT)
Received: by 10.115.19.16 with SMTP id w16mr565901wai.1178175004001;
        Wed, 02 May 2007 23:50:04 -0700 (PDT)
Return-Path: <busybox-bounces@busybox.net>
Received: from busybox.net (busybox.net [140.211.166.42])
        by mx.google.com with ESMTP id n22si4927866pof.2007.05.02.23.50.03;
        Wed, 02 May 2007 23:50:03 -0700 (PDT)
Received-SPF: pass (google.com: domain of busybox-bounces@busybox.net designates 140.211.166.42 as permitted sender)
Received: from localhost.localdomain (busybox [127.0.0.1])
	by busybox.net (BusyBox.Net Mail Daemon) with ESMTP id F017A485E5;
	Wed,  2 May 2007 23:49:51 -0700 (PDT)
X-Original-To: busybox@busybox.net
Delivered-To: busybox@busybox.net
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	by busybox.net (BusyBox.Net Mail Daemon) with ESMTP id 300FB485DB
	for <busybox@busybox.net>; Wed,  2 May 2007 23:49:45 -0700 (PDT)
Received: from ip6-localhost (localhost [127.0.0.1])
	by smtp.gentoo.org (Postfix) with ESMTP id 26F5D64B14;
	Thu,  3 May 2007 06:49:45 +0000 (UTC)
From: Mike Frysinger <vapier@gentoo.org>
Organization: wh0rd.org
To: Natanael Copa <natanael.copa@gmail.com>
Subject: Re: [patch/rfc] add fourth field to mdev.conf for subdirs
Date: Thu, 3 May 2007 02:49:55 -0400
User-Agent: KMail/1.9.6
References: <200705021754.36449.vapier@gentoo.org>
	<1178173791.18554.20.camel@localhost>
In-Reply-To: <1178173791.18554.20.camel@localhost>
MIME-Version: 1.0
Message-Id: <200705030249.56400.vapier@gentoo.org>
Cc: busybox@busybox.net
X-BeenThere: busybox@busybox.net
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Discussion and development of BusyBox <busybox.busybox.net>
List-Unsubscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox>,
	<mailto:busybox-request@busybox.net?subject=unsubscribe>
List-Archive: <http://busybox.net/lists/busybox>
List-Post: <mailto:busybox@busybox.net>
List-Help: <mailto:busybox-request@busybox.net?subject=help>
List-Subscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox>,
	<mailto:busybox-request@busybox.net?subject=subscribe>
Content-Type: multipart/mixed;
  boundary="===============0396900760=="
Mime-version: 1.0
Sender: busybox-bounces@busybox.net
Errors-To: busybox-bounces@busybox.net
Status: RO
X-Status: RC
X-KMail-EncryptionState: N
X-KMail-SignatureState: N
X-KMail-MDN-Sent:  

--===============0396900760==
Content-Type: multipart/signed;
  boundary="nextPart2265264.3trV7ha51J";
  protocol="application/pgp-signature";
  micalg=pgp-sha1
Content-Transfer-Encoding: 7bit

--nextPart2265264.3trV7ha51J
Content-Type: text/plain;
  charset="iso-8859-6"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

On Thursday 03 May 2007, Natanael Copa wrote:
> On Wed, 2007-05-02 at 17:54 -0400, Mike Frysinger wrote:
> > there are a few common/important set of device nodes that only work when
> > in the proper subdirectory ... for example, all of ALSA userland requir=
es
> > the sound nodes to be in /dev/snd/ and all of the input device nodes ne=
ed
> > to be in /dev/input/
> >
> > we're using the attached patch by Sonic Zhang in our Blackfin
> > distribution ... it simply changes the syntax from:
> > <device regex> <uid>:<gid> <octal perms> [command]
> > to:
> > <device regex> <uid>:<gid> <octal perms> [subdir] [<@|$|*> command]
>
> Sometimes it is good to be able to rename the device itself too. For
> example, zapctl should go to zap/ctl and not zap/zapctl

heh, we account for zapctl as well actually ... i just didnt think noting i=
t=20
would be worthwhile as no one else would recognize it ;)

> What about this syntax:
> <device regex> <uid>:<gid> <octal perms> [subdir [dest]] [<@|$|*> command]
>
> or:
> <device regex> <uid>:<gid> <octal perms> [[subdir/][dest]] [<@|$|*>
> command]

hmm, if we offered subdir and symlink, that'd account for your needs as wel=
l=20
right ?
=2Dmike

--nextPart2265264.3trV7ha51J
Content-Type: application/pgp-signature; name=signature.asc 
Content-Description: This is a digitally signed message part.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.3 (GNU/Linux)

iQIVAwUARjmGFEFjO5/oN/WBAQK3KRAAsWhvOnkLAakuaSMp+zTEjfFzlsd5w0LN
vAmtoEdysST7qLOwGNW/m6YK/WCA4Q4DrY2wNY2yucnXS6u+OIMjXSToTqacfMNk
NhPWzeILOnn2Gbm3n5yV3iCBu+4HoJ9290RbWnMEc9RrB5ZHF3m+NEd6Ck2GL/vk
YPnGnG+KlzhYS8EnSkb6Tej6jOrB9aRWVMQ4Y37B170QqEcx4tI0OSeWFMHECZir
LkAs3eju3+KHMsMw8uPsqyNG2oTrlH+I2hg7Pg6RKgrhIl9Bc8HKG5TS7hgCTycz
qDjB3FlNxg2yVlRgowZX4+pnnLUHwLZAt5ESV2bJcus1yWRije0wU/MlmK1zUbFb
bgimhfSzjn0KAr3jiPFFhf06Z1E6OpKeXnh3kJ08SXD0rVz+7goMxlv/KtDIK6SB
/SyEzA/6GRSLvMwa5oixCDCLZ3OtT+jUZVy/w2xR5PsvhN4E7IdaId3pZwDBP1FU
+5Hic1n7RfVd1yUMLEnWC+aXvpm1ONEWYon+o2+XB/sDKlzp3K0Sa9dwfBKQQq94
cOkPrv9DD2iLGR7nd6dUpad2QmbV238HYeZbSHWWFTw6ABZltu9rJNQoWz2gmXOQ
8n6Hms9xcj8pfmMSYctmx+MCFhLycILh8ly/FLCYl3LWALjKweLOdI7bJXE1XclW
qhuMuKGbof4=
=Dfni
-----END PGP SIGNATURE-----

--nextPart2265264.3trV7ha51J--

--===============0396900760==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox
--===============0396900760==--

From natanael.copa@gmail.com Thu May  3 09:15:43 2007
Delivered-To: vda.linux@gmail.com
Received: by 10.78.52.5 with SMTP id z5cs97272huz;
        Thu, 3 May 2007 00:16:10 -0700 (PDT)
Received: by 10.115.95.1 with SMTP id x1mr547578wal.1178176569534;
        Thu, 03 May 2007 00:16:09 -0700 (PDT)
Return-Path: <busybox-bounces@busybox.net>
Received: from busybox.net (busybox.net [140.211.166.42])
        by mx.google.com with ESMTP id n20si5003667pof.2007.05.03.00.16.08;
        Thu, 03 May 2007 00:16:09 -0700 (PDT)
Received-SPF: pass (google.com: domain of busybox-bounces@busybox.net designates 140.211.166.42 as permitted sender)
Received: from localhost.localdomain (busybox [127.0.0.1])
	by busybox.net (BusyBox.Net Mail Daemon) with ESMTP id B9F9C4807E;
	Thu,  3 May 2007 00:15:53 -0700 (PDT)
X-Original-To: busybox@busybox.net
Delivered-To: busybox@busybox.net
Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.172])
	by busybox.net (BusyBox.Net Mail Daemon) with ESMTP id 5FA1648089
	for <busybox@busybox.net>; Thu,  3 May 2007 00:15:47 -0700 (PDT)
Received: by ug-out-1314.google.com with SMTP id j3so360382ugf
	for <busybox@busybox.net>; Thu, 03 May 2007 00:15:47 -0700 (PDT)
Received: by 10.82.156.12 with SMTP id d12mr3309357bue.1178176547048;
	Thu, 03 May 2007 00:15:47 -0700 (PDT)
Received: from ?192.168.65.211? ( [213.234.126.134])
	by mx.google.com with ESMTP id b33sm2086983ika.2007.05.03.00.15.45;
	Thu, 03 May 2007 00:15:45 -0700 (PDT)
Subject: Re: [patch/rfc] add fourth field to mdev.conf for subdirs
From: Natanael Copa <natanael.copa@gmail.com>
To: Mike Frysinger <vapier@gentoo.org>
In-Reply-To: <200705030249.56400.vapier@gentoo.org>
References: <200705021754.36449.vapier@gentoo.org>
	<1178173791.18554.20.camel@localhost>
	<200705030249.56400.vapier@gentoo.org>
Date: Thu, 03 May 2007 09:15:43 +0200
Message-Id: <1178176543.18554.24.camel@localhost>
Mime-Version: 1.0
X-Mailer: Evolution 2.8.3 
Cc: busybox@busybox.net
X-BeenThere: busybox@busybox.net
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Discussion and development of BusyBox <busybox.busybox.net>
List-Unsubscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox>,
	<mailto:busybox-request@busybox.net?subject=unsubscribe>
List-Archive: <http://busybox.net/lists/busybox>
List-Post: <mailto:busybox@busybox.net>
List-Help: <mailto:busybox-request@busybox.net?subject=help>
List-Subscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox>,
	<mailto:busybox-request@busybox.net?subject=subscribe>
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: busybox-bounces@busybox.net
Errors-To: busybox-bounces@busybox.net
Status: RO
X-Status: RC
X-KMail-EncryptionState: N
X-KMail-SignatureState: N
X-KMail-MDN-Sent:  

On Thu, 2007-05-03 at 02:49 -0400, Mike Frysinger wrote:
> On Thursday 03 May 2007, Natanael Copa wrote:
...
> > What about this syntax:
> > <device regex> <uid>:<gid> <octal perms> [subdir [dest]] [<@|$|*> command]
> >
> > or:
> > <device regex> <uid>:<gid> <octal perms> [[subdir/][dest]] [<@|$|*>
> > command]
> 
> hmm, if we offered subdir and symlink, that'd account for your needs as well 
> right ?

right.

Natanael


_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox

From bugs@busybox.net Thu May  3 20:44:48 2007
Delivered-To: vda.linux@gmail.com
Received: by 10.78.52.5 with SMTP id z5cs157860huz;
        Thu, 3 May 2007 11:44:56 -0700 (PDT)
Received: by 10.114.168.1 with SMTP id q1mr785399wae.1178217895631;
        Thu, 03 May 2007 11:44:55 -0700 (PDT)
Return-Path: <busybox-cvs-bounces@busybox.net>
Received: from busybox.net (busybox.net [140.211.166.42])
        by mx.google.com with ESMTP id m27si1462356pof.2007.05.03.11.44.54;
        Thu, 03 May 2007 11:44:55 -0700 (PDT)
Received-SPF: pass (google.com: domain of busybox-cvs-bounces@busybox.net designates 140.211.166.42 as permitted sender)
Received: from localhost.localdomain (busybox [127.0.0.1])
	by busybox.net (BusyBox.Net Mail Daemon) with ESMTP id 05C0E485B2;
	Thu,  3 May 2007 11:44:54 -0700 (PDT)
X-Original-To: busybox-cvs@busybox.net
Delivered-To: busybox-cvs@busybox.net
Received: by busybox.net (BusyBox.Net Mail Daemon, from userid 33)
	id A9A86485B2; Thu,  3 May 2007 11:44:49 -0700 (PDT)
To: busybox-cvs@busybox.net
Subject: [BusyBox 0001329]: Patch for "util-linux/mdev.c": make it able to
	create symlinks and subdirectories
Date: Thu, 3 May 2007 11:44:48 -0700
From: bugs@busybox.net
Message-ID: <2cb3625163ebd8817cabccd6b3b7e55b@bugs.busybox.net>
X-Priority: 3
X-Mailer: PHPMailer [version 1.72]
MIME-Version: 1.0
X-BeenThere: busybox-cvs@busybox.net
X-Mailman-Version: 2.1.9
Precedence: list
Reply-To: busybox@busybox.net
List-Id: List of all SVN commit messages for BusyBox <busybox-cvs.busybox.net>
List-Unsubscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox-cvs>,
	<mailto:busybox-cvs-request@busybox.net?subject=unsubscribe>
List-Archive: <http://busybox.net/lists/busybox-cvs>
List-Post: <mailto:busybox-cvs@busybox.net>
List-Help: <mailto:busybox-cvs-request@busybox.net?subject=help>
List-Subscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox-cvs>,
	<mailto:busybox-cvs-request@busybox.net?subject=subscribe>
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: busybox-cvs-bounces@busybox.net
Errors-To: busybox-cvs-bounces@busybox.net
Status: RO
X-Status: RC
X-KMail-EncryptionState: N
X-KMail-SignatureState: N
X-KMail-MDN-Sent:  


A NOTE has been added to this issue. 
====================================================================== 
http://busybox.net/bugs/view.php?id=1329 
====================================================================== 
Reported By:                Souf
Assigned To:                BusyBox
====================================================================== 
Project:                    BusyBox
Issue ID:                   1329
Category:                   New Features
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     assigned
====================================================================== 
Date Submitted:             04-29-2007 10:44 PDT
Last Modified:              05-03-2007 11:44 PDT
====================================================================== 
Summary:                    Patch for "util-linux/mdev.c": make it able to
create symlinks and subdirectories
Description: 
This patch adds to mdev.c the ability to create symlinks and
subdirectories:
examples:
stderr -> /proc/self/fd/2

pcmC[0-9]D[0-9]c 0:0 0666 >> /dev/snd/ 0755

modified files:
util-linux/mdev.c
util-linux/Config.in
docs/mdev.txt

The patch corrects also the bug 0001299

I wish that this patch be deeply tested before a possible integration


====================================================================== 

---------------------------------------------------------------------- 
 vapier - 05-02-07 10:57  
---------------------------------------------------------------------- 
you removed support for program execution which is not desirable

i'll post a diff patch to the busybox mailing list we've been using in
Blackfin/uClinux-dist 

---------------------------------------------------------------------- 
 Souf - 05-03-07 11:44  
---------------------------------------------------------------------- 
New patch for mdev.c which restores support for program execution 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
04-29-07 10:44  Souf           New Issue                                    
04-29-07 10:44  Souf           Status                   new => assigned     
04-29-07 10:44  Souf           Assigned To               => BusyBox         
04-29-07 10:44  Souf           File Added: mdev.patch                       
05-02-07 10:57  vapier         Note Added: 0002336                          
05-03-07 11:44  Souf           Note Added: 0002340                          
======================================================================

_______________________________________________
busybox-cvs mailing list
busybox-cvs@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox-cvs

From souf_oued@yahoo.fr Fri May  4 00:36:03 2007
Delivered-To: vda.linux@gmail.com
Received: by 10.78.52.5 with SMTP id z5cs178497huz;
        Thu, 3 May 2007 15:41:30 -0700 (PDT)
Received: by 10.115.18.1 with SMTP id v1mr876103wai.1178232089507;
        Thu, 03 May 2007 15:41:29 -0700 (PDT)
Return-Path: <busybox-bounces@busybox.net>
Received: from busybox.net (busybox.osuosl.org [140.211.166.42])
        by mx.google.com with ESMTP id n22si2275721pof.2007.05.03.15.41.28;
        Thu, 03 May 2007 15:41:29 -0700 (PDT)
Received-SPF: pass (google.com: domain of busybox-bounces@busybox.net designates 140.211.166.42 as permitted sender)
Received: from localhost.localdomain (busybox [127.0.0.1])
	by busybox.net (BusyBox.Net Mail Daemon) with ESMTP id ACCF1485C8;
	Thu,  3 May 2007 15:41:14 -0700 (PDT)
X-Original-To: busybox@busybox.net
Delivered-To: busybox@busybox.net
X-Greylist: delayed 400 seconds by postgrey-1.21 at busybox;
	Thu, 03 May 2007 15:41:11 PDT
Received: from smtp010.mail.ukl.yahoo.com (smtp010.mail.ukl.yahoo.com
	[217.12.11.79])
	by busybox.net (BusyBox.Net Mail Daemon) with SMTP id E4BF9485B1
	for <busybox@busybox.net>; Thu,  3 May 2007 15:41:11 -0700 (PDT)
Received: (qmail 42752 invoked from network); 3 May 2007 22:34:30 -0000
Received: from unknown (HELO ?192.168.0.2?) (souf_oued@82.66.250.26 with plain)
	by smtp010.mail.ukl.yahoo.com with SMTP; 3 May 2007 22:34:30 -0000
X-YMail-OSG: kJS4cGUVM1mJu1EkDGXWf2Ho91yOwRZKOovCjq9XzXk4hVmwPd0QLzxCor75SlN15d7Y9hmo2w--
Subject: [patch] for "util-linux/mdev.c": make it able to create symlinks
	and subdirectories
From: Souf <souf_oued@yahoo.fr>
To: busybox@busybox.net
Content-Type: multipart/mixed;
  boundary="=-rqu79llRgW4+DKoeIHda"
Date: Fri, 04 May 2007 00:36:03 +0200
Message-Id: <1178231763.3252.7.camel@localhost.localdomain>
Mime-Version: 1.0
X-Mailer: Evolution 2.8.3 (2.8.3-2.fc6) 
X-BeenThere: busybox@busybox.net
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Discussion and development of BusyBox <busybox.busybox.net>
List-Unsubscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox>,
	<mailto:busybox-request@busybox.net?subject=unsubscribe>
List-Archive: <http://busybox.net/lists/busybox>
List-Post: <mailto:busybox@busybox.net>
List-Help: <mailto:busybox-request@busybox.net?subject=help>
List-Subscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox>,
	<mailto:busybox-request@busybox.net?subject=subscribe>
Sender: busybox-bounces@busybox.net
Errors-To: busybox-bounces@busybox.net
Status: RO
X-Status: RT
X-KMail-EncryptionState: N
X-KMail-SignatureState: N
X-KMail-MDN-Sent:  


--=-rqu79llRgW4+DKoeIHda
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

This patch adds to mdev.c the ability to create symlinks and
subdirectories:
examples:
stderr -> /proc/self/fd/2

pcmC[0-9]D[0-9]c 0:0 0666 >> /dev/snd/ 0755

modified files:
util-linux/mdev.c
docs/mdev.txt

this patch is for the test before integration

Malek

--=-rqu79llRgW4+DKoeIHda
Content-Disposition: attachment; filename=mdev.patch
Content-Type: text/x-patch; name=mdev.patch; charset=UTF-8
Content-Transfer-Encoding: 7bit

--- busybox-1.5.0/util-linux/mdev.c.orig	2007-04-29 18:46:59.000000000 +0200
+++ busybox-1.5.0/util-linux/mdev.c	2007-05-04 00:20:17.000000000 +0200
@@ -21,12 +21,19 @@ struct mdev_globals
 
 #define bbg mdev_globals
 
+static void mdev_symlink(char *m_target, char *m_link)
+{
+	if (!m_target || !m_link) return;
+	if (symlink(m_target, m_link) && errno != EEXIST)
+		bb_perror_msg_and_die("symlink %s", m_link);
+}
+
 /* mknod in /dev based on a path like "/sys/block/hda/hda1" */
 static void make_device(char *path, int delete)
 {
-	char *device_name;
-	int major, minor, type, len;
-	int mode = 0660;
+	char *device_name, *device_path = NULL;
+	int major, minor, type, len, mk_dir=0;
+	mode_t mode = 0660, mode_path = 0660;
 	uid_t uid = 0;
 	gid_t gid = 0;
 	char *temp = path + strlen(path);
@@ -47,129 +54,160 @@ static void make_device(char *path, int 
 	/* Determine device name, type, major and minor */
 
 	device_name = strrchr(path, '/') + 1;
-	type = path[5]=='c' ? S_IFCHR : S_IFBLK;
+	type = (path[5]=='b') ? S_IFBLK : S_IFCHR;
 
 	/* If we have a config file, look up permissions for this device */
 
 	if (ENABLE_FEATURE_MDEV_CONF) {
-		char *conf, *pos, *end;
-		int line, fd;
+		char *line, *tok_tmp, *tok_line=NULL, **tok = NULL;
+		FILE *file;
+		int i;
 
-		/* mmap the config file */
-		fd = open("/etc/mdev.conf", O_RDONLY);
-		if (fd < 0)
-			goto end_parse;
-		len = xlseek(fd, 0, SEEK_END);
-		conf = mmap(NULL, len, PROT_READ, MAP_PRIVATE, fd, 0);
-		close(fd);
-		if (!conf)
+		file = fopen_or_warn("/etc/mdev.conf", "r");
+		if (file < 0)
 			goto end_parse;
 
-		line = 0;
-		/* Loop through lines in mmaped file*/
-		for (pos=conf; pos-conf<len;) {
-			int field;
-			char *end2;
+		while ((line = xmalloc_getline(file)) != NULL) {
+			char *regex = NULL;
+			regex_t match;
+			regmatch_t off;
+			int result, tok_len = 1;
+			char *tok_id[2], *tok_id_tmp;
+			char *s;
 
-			line++;
-			/* find end of this line */
-			for (end=pos; end-conf<len && *end!='\n'; end++)
-				;
+			tok_line = strdupa(line);
+			if (tok_line[0] == '#' || strlen(tok_line)==0) continue;
 
-			/* Three fields: regex, uid:gid, mode */
-			for (field=0; field < (3 + ENABLE_FEATURE_MDEV_EXEC);
-					field++)
-			{
-				/* Skip whitespace */
-				while (pos<end && isspace(*pos)) pos++;
-				if (pos==end || *pos=='#') break;
-				for (end2=pos;
-					end2<end && !isspace(*end2) && *end2!='#'; end2++)
-					;
+			for (i=0; i<strlen(tok_line); i++) {
+				if (isspace(tok_line[i]) && !isspace(tok_line[i+1]))
+					tok_len++;
+			}
+			tok = (char **) xrealloc(tok, tok_len * sizeof(char *));
 
-				if (field == 0) {
-					/* Regex to match this device */
+			for (i=0; (tok_tmp=strtok(tok_line, " \t")); i++) {
+				tok[i] = tok_tmp;
+				tok_line = NULL;
+			}
 
-					char *regex = strndupa(pos, end2-pos);
-					regex_t match;
-					regmatch_t off;
-					int result;
+			if (!strcmp(tok[1], "->")) {
+				mdev_symlink(tok[2], tok[0]);
+				continue;
+			}
 
-					/* Is this it? */
-					xregcomp(&match,regex, REG_EXTENDED);
-					result = regexec(&match, device_name, 1, &off, 0);
-					regfree(&match);
+			/* Regex to match this device */
+			regex = tok[0];
+			xregcomp(&match,regex, REG_EXTENDED);
+			result = regexec(&match, device_name, 1, &off, 0);
+			regfree(&match);
 
-					/* If not this device, skip rest of line */
-					if (result || off.rm_so
-							|| off.rm_eo != strlen(device_name))
-						break;
-				}
-				if (field == 1) {
-					/* uid:gid */
+			/* If not this device, skip rest of line */
+			if (result || off.rm_so || off.rm_eo != strlen(device_name))
+				continue;
 
-					char *s, *s2;
 
-					/* Find : */
-					for (s=pos; s<end2 && *s!=':'; s++)
-						;
-					if (s == end2) break;
+			for (i=0; (tok_id_tmp=strtok(tok[1], ":")); i++) {
+				if (tok_id_tmp) tok_id[i] = tok_id_tmp;
+				tok[1] = NULL;
+			}
 
-					/* Parse UID */
-					uid = strtoul(pos, &s2, 10);
-					if (s != s2) {
-						struct passwd *pass;
-						pass = getpwnam(strndupa(pos, s-pos));
-						if (!pass) break;
-						uid = pass->pw_uid;
-					}
-					s++;
-					/* parse GID */
-					gid = strtoul(s, &s2, 10);
-					if (end2 != s2) {
-						struct group *grp;
-						grp = getgrnam(strndupa(s, end2-s));
-						if (!grp) break;
-						gid = grp->gr_gid;
-					}
-				}
-				if (field == 2) {
-					/* mode */
+			/* uid:gid */
+			uid = strtoul(tok_id[0], &s, 10);
+			if (tok_id[0] == s) {
+				struct passwd *pass;
+				pass = getpwnam(tok_id[0]);
+				if (!pass) continue;
+				uid = pass->pw_uid;
+			}
 
-					mode = strtoul(pos, &pos, 8);
-					if (pos != end2) break;
+			gid = strtoul(tok_id[1], &s, 10);
+			if (tok_id[1] == s) {
+				struct group *grp;
+				grp = getgrnam(tok_id[1]);
+				if (!grp) continue;
+				gid = grp->gr_gid;
+			}
+
+			/* mode */
+			mode = (mode_t)strtoul(tok[2], &s, 8);
+
+			if (tok_len > 3) {
+#if ENABLE_FEATURE_MDEV_EXEC
+				const char *s2 = "@$*";
+				char *cmd_tmp;
+				unsigned int cmd = 0;
+#endif
+				/* mk_dir */
+				if (!strcmp(tok[3], ">>")) {
+					mk_dir = 1;
+					device_path = strdupa(tok[4]);
+					if (last_char_is(device_path, '/') == NULL)
+						strcat(device_path, "/");
+
+					mode_path = (mode_t)strtoul(tok[5], &s, 8);
 				}
-				if (ENABLE_FEATURE_MDEV_EXEC && field == 3) {
-					// Command to run
-					const char *s = "@$*";
-					const char *s2;
-					s2 = strchr(s, *pos++);
-					if (!s2) {
-						// Force error
-						field = 1;
-						break;
+#if ENABLE_FEATURE_MDEV_EXEC
+				else {
+					if ((cmd_tmp = strpbrk(tok[3], s2))!=NULL) {
+						int cmd_len = strlen(cmd_tmp) == 1 ? 1 : 0;
+
+						cmd = *cmd_tmp;
+
+						if (cmd_len == 1) {
+							command = strdupa(tok[4]);
+						} else {
+							command = strdupa(strrchr(tok[3], cmd_tmp[0])+1);
+						}
+
+						for (i=4+cmd_len; i<tok_len; i++) {
+							strcat(strcat(command, " "), tok[i]);
+						}
 					}
-					if ((s2-s+1) & (1<<delete))
-						command = xstrndup(pos, end-pos);
+					
 				}
 
-				pos = end2;
-			}
+				if (tok_len > 6) {
+					if ((cmd_tmp = strpbrk(tok[6], s2))!=NULL) {
+						int cmd_len = strlen(cmd_tmp) == 1 ? 1 : 0;
 
-			/* Did everything parse happily? */
+						cmd = *cmd_tmp;
 
-			if (field > 2) break;
-			if (field) bb_error_msg_and_die("bad line %d",line);
+						if (cmd_len == 1) {
+							command = xstrdup(tok[7]);
+						} else {
+							command = xstrdup(strrchr(tok[6], cmd_tmp[0])+1);
+						}
 
-			/* Next line */
-			pos = ++end;
+						for (i=7+cmd_len; i<tok_len; i++) {
+							strcat(strcat(command, " "), tok[i]);
+						}
+					}
+				}
+
+				switch (cmd) {
+				case '@':
+					if (delete) command = NULL;
+					break;
+				case '$':
+					if (!delete) command = NULL;
+					break;
+				case '*':
+				default :
+					break;
+				}
+#endif
+			}
 		}
-		munmap(conf, len);
+		fclose(file);
  end_parse:	/* nothing */ ;
 	}
 
 	umask(0);
 	if (!delete) {
+		if (mk_dir) {
+			if (mkdir(device_path, mode_path) && errno != EEXIST)
+				bb_perror_msg_and_die("mkdir %s", device_path);
+			device_name = strcat(device_path, device_name);
+		}
 		if (sscanf(temp, "%d:%d", &major, &minor) != 2) return;
 		if (mknod(device_name, mode | type, makedev(major, minor)) && errno != EEXIST)
 			bb_perror_msg_and_die("mknod %s", device_name);
@@ -179,6 +217,7 @@ static void make_device(char *path, int 
 
 		if (ENABLE_FEATURE_MDEV_CONF) chown(device_name, uid, gid);
 	}
+
 	if (command) {
 		int rc;
 		char *s;
@@ -189,10 +228,25 @@ static void make_device(char *path, int 
 		s[4] = 0;
 		putenv(s);
 		free(s);
-		free(command);
 		if (rc == -1) bb_perror_msg_and_die("cannot run %s", command);
 	}
-	if (delete) unlink(device_name);
+
+	if (delete) {
+		if (device_path) {
+			char *tmp_path;
+
+			tmp_path = strdupa(device_path);
+			device_name = strcat(tmp_path, device_name);
+		}
+
+		unlink(device_name);
+
+		if (device_path) {
+			if (rmdir(device_path) && errno != ENOTEMPTY)
+				bb_perror_msg_and_die("rmdir %s", device_path);
+		}
+	}
+
 }
 
 /* Recursive search of /sys/block or /sys/class.  path must be a writeable
--- busybox-1.5.0/docs/mdev.txt.orig	2007-04-29 17:43:15.000000000 +0200
+++ busybox-1.5.0/docs/mdev.txt	2007-05-04 00:16:02.000000000 +0200
@@ -44,25 +44,42 @@ device nodes if your system needs someth
 660 permissions.
 
 The file has the format:
-	<device regex> <uid>:<gid> <octal permissions>
-For example:
-	hd[a-z][0-9]* 0:3 660
 
-The config file parsing stops at the first matching line.  If no line is
-matched, then the default of 0:0 660 is used.  To set your own default, simply
-create your own total match like so:
-	.* 1:1 777
+    For symlinks:
+	symlink -> target
+    For example:
+	core -> /proc/kcore
+	ram -> ram1
+	stderr -> /proc/self/fd/2
+	stdin -> /proc/self/fd/0
+	stdout -> /proc/self/fd/1
+	...
 
-If you also enable support for executing your own commands, then the file has
-the format:
-	<device regex> <uid>:<gid> <octal permissions> [<@|$|*> <command>]
-The special characters have the meaning:
+    For devices
+	<device regex> <uid>:<gid> <octal permissions> [ [<\>>\> </dev/device/patht> <octal permissions>] ]
+    For example:
+	hd[a-z][0-9]* 0:3 660
+	fd0	0:11 0660
+	event[0-9] 0:0 0600 >> /dev/input 0755
+	pcmC[0-9]D[0-9]c 0:0 0666 >> snd/ 0755
+
+    if you want to execute a special command, then the file has the format:
+	<device regex> <uid>:<gid> <octal permissions> [ [<\>>\> </dev/device/patht> <octal permissions>]] [<@|$|*> <command>] ]
+    The special characters have the meaning:
 	@ Run after creating the device.
 	$ Run before removing the device.
 	* Run both after creating and before removing the device.
 
-The command is executed via the system() function (which means you're giving a
-command to the shell), so make sure you have a shell installed at /bin/sh.
+    For example:
+	urandom 0:0 444 * echo "HI URANDOM !"
+	pcmC[0-9]D[0-9]c 0:0 0666 >> snd 0755 @echo "HELLO PCMC_D_C !"
+	pcmC[0-9]D[0-9]c 0:0 0666 >> /dev/snd 0755 @echo "HELLO PCMC_D_C !"
 
-For your convenience, the shell env var $MDEV is set to the device name.  So if
-the device 'hdc' was matched, MDEV would be set to "hdc".
+    The command is executed via the system() function (which means you're giving a
+    command to the shell), so make sure you have a shell installed at /bin/sh.
+
+    For your convenience, the shell env var $MDEV is set to the device name.  So if
+    the device 'hdc' was matched, MDEV would be set to "hdc".
+
+    For example:
+	pcmC[0-9]D[0-9]c 0:0 0666 >> snd 0755 @echo "HELLO  $MDEV !"

--=-rqu79llRgW4+DKoeIHda
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox
--=-rqu79llRgW4+DKoeIHda--

From bugs@busybox.net Sun May  6 12:19:40 2007
Delivered-To: vda.linux@gmail.com
Received: by 10.78.52.7 with SMTP id z7cs73973huz;
        Sun, 6 May 2007 03:19:47 -0700 (PDT)
Received: by 10.115.93.16 with SMTP id v16mr1740021wal.1178446785896;
        Sun, 06 May 2007 03:19:45 -0700 (PDT)
Return-Path: <busybox-cvs-bounces@busybox.net>
Received: from busybox.net (busybox.net [140.211.166.42])
        by mx.google.com with ESMTP id z20si8026760pod.2007.05.06.03.19.45;
        Sun, 06 May 2007 03:19:45 -0700 (PDT)
Received-SPF: pass (google.com: domain of busybox-cvs-bounces@busybox.net designates 140.211.166.42 as permitted sender)
Received: from localhost.localdomain (busybox [127.0.0.1])
	by busybox.net (BusyBox.Net Mail Daemon) with ESMTP id 9790C48088;
	Sun,  6 May 2007 03:19:44 -0700 (PDT)
X-Original-To: busybox-cvs@busybox.net
Delivered-To: busybox-cvs@busybox.net
Received: by busybox.net (BusyBox.Net Mail Daemon, from userid 33)
	id E894148085; Sun,  6 May 2007 03:19:40 -0700 (PDT)
To: busybox-cvs@busybox.net
Subject: [BusyBox 0001334]: [BUG] mdev does not run command if it does not
	find the "dev" file under /sys
Date: Sun, 6 May 2007 03:19:40 -0700
From: bugs@busybox.net
Message-ID: <a2f284b17c115c760a1b6c5b02aa41ed@bugs.busybox.net>
X-Priority: 3
X-Mailer: PHPMailer [version 1.72]
MIME-Version: 1.0
X-BeenThere: busybox-cvs@busybox.net
X-Mailman-Version: 2.1.9
Precedence: list
Reply-To: busybox@busybox.net
List-Id: List of all SVN commit messages for BusyBox <busybox-cvs.busybox.net>
List-Unsubscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox-cvs>,
	<mailto:busybox-cvs-request@busybox.net?subject=unsubscribe>
List-Archive: <http://busybox.net/lists/busybox-cvs>
List-Post: <mailto:busybox-cvs@busybox.net>
List-Help: <mailto:busybox-cvs-request@busybox.net?subject=help>
List-Subscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox-cvs>,
	<mailto:busybox-cvs-request@busybox.net?subject=subscribe>
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: busybox-cvs-bounces@busybox.net
Errors-To: busybox-cvs-bounces@busybox.net
Status: RO
X-Status: RC
X-KMail-EncryptionState: N
X-KMail-SignatureState: N
X-KMail-MDN-Sent:  


The following issue has been SUBMITTED. 
====================================================================== 
http://busybox.net/bugs/view.php?id=1334 
====================================================================== 
Reported By:                landau
Assigned To:                BusyBox
====================================================================== 
Project:                    BusyBox
Issue ID:                   1334
Category:                   Other
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     assigned
====================================================================== 
Date Submitted:             05-06-2007 03:19 PDT
Last Modified:              05-06-2007 03:19 PDT
====================================================================== 
Summary:                    [BUG] mdev does not run command if it does not find
the "dev" file under /sys
Description: 
If mdev does not find a dev file under the appropriate branch in /sys, it
quits without executing a command (if one is present).
The attached patch fixes that. If dev does not exist, then no device file
in /dev is created (of course!), but command, if present, is executed.
This is very handy for firmware loading, since the driver may not expose
any device files (e.g. the driver is used by other drivers and not by
userspace) and still require a firmware loaded to its device.

The patch applies to svn trunk rev 18563.
It shouldn't interfere with the circulating patch which adds symlink and
directory support, but I have not verified this.
====================================================================== 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
05-06-07 03:19  landau         New Issue                                    
05-06-07 03:19  landau         Status                   new => assigned     
05-06-07 03:19  landau         Assigned To               => BusyBox         
05-06-07 03:19  landau         File Added: mdev.patch                       
======================================================================

_______________________________________________
busybox-cvs mailing list
busybox-cvs@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox-cvs

From souf_oued@yahoo.fr Wed May  9 23:46:02 2007
Delivered-To: vda.linux@gmail.com
Received: by 10.78.52.7 with SMTP id z7cs101300huz;
        Wed, 9 May 2007 14:44:46 -0700 (PDT)
Received: by 10.35.41.8 with SMTP id t8mr1735764pyj.1178747086030;
        Wed, 09 May 2007 14:44:46 -0700 (PDT)
Return-Path: <busybox-bounces@busybox.net>
Received: from busybox.net (busybox.net [140.211.166.42])
        by mx.google.com with ESMTP id y45si14087450pyg.2007.05.09.14.44.43;
        Wed, 09 May 2007 14:44:46 -0700 (PDT)
Received-SPF: pass (google.com: domain of busybox-bounces@busybox.net designates 140.211.166.42 as permitted sender)
Received: from localhost.localdomain (busybox [127.0.0.1])
	by busybox.net (BusyBox.Net Mail Daemon) with ESMTP id 049A14800D;
	Wed,  9 May 2007 14:44:30 -0700 (PDT)
X-Original-To: busybox@busybox.net
Delivered-To: busybox@busybox.net
Received: from smtp003.mail.ukl.yahoo.com (smtp003.mail.ukl.yahoo.com
	[217.12.11.34])
	by busybox.net (BusyBox.Net Mail Daemon) with SMTP id C09444800B
	for <busybox@busybox.net>; Wed,  9 May 2007 14:44:26 -0700 (PDT)
Received: (qmail 87484 invoked from network); 9 May 2007 21:44:25 -0000
Received: from unknown (HELO ?192.168.0.2?) (souf_oued@82.66.250.26 with plain)
	by smtp003.mail.ukl.yahoo.com with SMTP; 9 May 2007 21:44:24 -0000
X-YMail-OSG: c2RE6LUVM1lIYkCei8dfL0PpZD6BZqeNjfORX3lfMrAuIczXxtpaKwMmrINawek7furS58vfTw--
Subject: [MDEV] mdev and CONFIG_SYSFS_DEPRECATED
From: Souf <souf_oued@yahoo.fr>
To: busybox@busybox.net
Content-Type: multipart/mixed;
  boundary="=-9jAROVjxIzSz5iuR+0q8"
Date: Wed, 09 May 2007 23:46:02 +0200
Message-Id: <1178747163.6603.3.camel@localhost.localdomain>
Mime-Version: 1.0
X-Mailer: Evolution 2.8.3 (2.8.3-2.fc6) 
X-BeenThere: busybox@busybox.net
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Discussion and development of BusyBox <busybox.busybox.net>
List-Unsubscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox>,
	<mailto:busybox-request@busybox.net?subject=unsubscribe>
List-Archive: <http://busybox.net/lists/busybox>
List-Post: <mailto:busybox@busybox.net>
List-Help: <mailto:busybox-request@busybox.net?subject=help>
List-Subscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox>,
	<mailto:busybox-request@busybox.net?subject=subscribe>
Sender: busybox-bounces@busybox.net
Errors-To: busybox-bounces@busybox.net
Status: RO
X-Status: RT
X-KMail-EncryptionState: N
X-KMail-SignatureState: N
X-KMail-MDN-Sent:  


--=-9jAROVjxIzSz5iuR+0q8
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi all,
I rewrote mdev so that it can work with or without CONFIG_SYSFS_DEPRECATED in the kernel,
this rewriting implies a minor modification of the syntax of mdev.config
New the mdev can:
1- create symlinks
        <symlink> -> <target>
        stderr -> /proc/self/fd/2
        XOR -> null

2- create (sub-)directories
        <(sub-)directory> <octal permissions>
        bus/usb/001 0755
        disk/by-id 0755

3- create a device in a (sub-)directory
        <device regex> <uid>:<gid> <octal permissions> [</>>/>
<(sub-)directory> <octal permissions>]
        seq 0:0 0666 >> snd 0755
        pcmC[0-9]D[0-9]p 0:0 0666 >> snd 0755
        event[0-9] 0:0 0600 >> input 0755

4- execute an command
        <device regex> <uid>:<gid> <octal permissions> [</>>/>
<(sub-)directory> <octal permissions>] [<@|$|*> <command>]
        controlC[0-9] 0:0 0666 >> snd 0755  @ echo "hello $MDEV"
        seq     0:0 0666 $echo "good bye $MDEV"
        timer 0:0 0666 >> snd 0755 * echo "Hi $MDEV"    

        @ Run after creating the device.
        $ Run before removing the device.
        * Run both after creating and before removing the device.

5- work with or without CONFIG_SYSFS_DEPRECATED

I awaits your reactions and your ideas

Regards

Malek


--=-9jAROVjxIzSz5iuR+0q8
Content-Disposition: attachment; filename=mdev.c
Content-Type: text/x-csrc; name=mdev.c; charset=UTF-8
Content-Transfer-Encoding: 7bit

/* vi: set sw=4 ts=4: */
/*
 *
 * mdev - Mini udev for busybox
 *
 * Copyright 2005 Rob Landley <rob@landley.net>
 * Copyright 2005 Frank Sorenson <frank@tuxrocks.com>
 *
 * Licensed under GPL version 2, see file LICENSE in this tarball for details.
 */

#include "busybox.h"
#include "xregex.h"

#define DEV_PATH	"/dev"

struct mdev_globals
{
	int root_major, root_minor;
} mdev_globals;

#define bbg mdev_globals

static void mdev_symlink(char *m_target, char *m_link)
{
	if (!m_target || !m_link) return;
	if (symlink(m_target, m_link) && errno != EEXIST)
		bb_perror_msg_and_die("symlink %s", m_link);
}

/* mknod in /dev based on a path like "/sys/block/hda/hda1" */
static void make_device(char *path, int delete)
{
	char *device_name, *device_path = NULL;
	int major, minor, type, len, mk_dir=0;
	mode_t mode = 0660, mode_path = 0660;
	uid_t uid = 0;
	gid_t gid = 0;
	char *temp = path + strlen(path);
	char *command = NULL;

	/* Try to read major/minor string.  Note that the kernel puts \n after
	 * the data, so we don't need to worry about null terminating the string
	 * because sscanf() will stop at the first nondigit, which \n is.  We
	 * also depend on path having writeable space after it. */

	if (!delete) {
		strcat(path, "/dev");
		len = open_read_close(path, temp + 1, 64);
		*temp++ = 0;
		if (len < 1) return;
	}

	/* Determine device name, type, major and minor */

	device_name = strrchr(path, '/') + 1;
	type = (path[5]=='b') ? S_IFBLK : S_IFCHR;

	/* If we have a config file, look up permissions for this device */

	if (ENABLE_FEATURE_MDEV_CONF) {
		char *line, *tok_tmp, *tok_line=NULL, **tok = NULL;
		FILE *file;
		int i;

		file = fopen_or_warn("/etc/mdev.conf", "r");
		if (file < 0)
			goto end_parse;

		while ((line = xmalloc_getline(file)) != NULL) {
			char *regex = NULL;
			regex_t match;
			regmatch_t off;
			int result, tok_len = 1;
			char *tok_id[2], *tok_id_tmp;
			char *s;

			tok_line = strdupa(line);
			if (tok_line[0] == '#' || strlen(tok_line)==0) continue;

			for (i=0; i<strlen(tok_line); i++) {
				if (isspace(tok_line[i]) && !isspace(tok_line[i+1]))
					tok_len++;
			}
			tok = (char **) xrealloc(tok, tok_len * sizeof(char *));

			for (i=0; (tok_tmp=strtok(tok_line, " \t")); i++) {
				tok[i] = tok_tmp;
				tok_line = NULL;
			}

			if (tok_len == 2) {
				mode_path = (mode_t)strtoul(tok[1], &s, 8);
				bb_make_directory(tok[0], mode_path, FILEUTILS_RECUR);
				continue;
			}

			if (!strcmp(tok[1], "->")) {
				mdev_symlink(tok[2], tok[0]);
				continue;
			}

			/* Regex to match this device */
			regex = tok[0];
			xregcomp(&match,regex, REG_EXTENDED);
			result = regexec(&match, device_name, 1, &off, 0);
			regfree(&match);

			/* If not this device, skip rest of line */
			if (result || off.rm_so || off.rm_eo != strlen(device_name))
				continue;


			for (i=0; (tok_id_tmp=strtok(tok[1], ":")); i++) {
				if (tok_id_tmp) tok_id[i] = tok_id_tmp;
				tok[1] = NULL;
			}

			/* uid:gid */
			uid = strtoul(tok_id[0], &s, 10);
			if (tok_id[0] == s) {
				struct passwd *pass;
				pass = getpwnam(tok_id[0]);
				if (!pass) continue;
				uid = pass->pw_uid;
			}

			gid = strtoul(tok_id[1], &s, 10);
			if (tok_id[1] == s) {
				struct group *grp;
				grp = getgrnam(tok_id[1]);
				if (!grp) continue;
				gid = grp->gr_gid;
			}

			/* mode */
			mode = (mode_t)strtoul(tok[2], &s, 8);

			if (tok_len > 3) {
#if ENABLE_FEATURE_MDEV_EXEC
				const char *s2 = "@$*";
				char *cmd_tmp;
				unsigned int cmd = 0;
#endif
				/* mk_dir */
				if (!strcmp(tok[3], ">>")) {
					mk_dir = 1;
					device_path = strdupa(tok[4]);
					if (last_char_is(device_path, '/') == NULL)
						strcat(device_path, "/");

					mode_path = (mode_t)strtoul(tok[5], &s, 8);
				}
#if ENABLE_FEATURE_MDEV_EXEC
				else {
					if ((cmd_tmp = strpbrk(tok[3], s2))!=NULL) {
						int cmd_len = strlen(cmd_tmp) == 1 ? 1 : 0;

						cmd = *cmd_tmp;

						if (cmd_len == 1) {
							command = strdupa(tok[4]);
						} else {
							command = strdupa(strrchr(tok[3], cmd_tmp[0])+1);
						}

						for (i=4+cmd_len; i<tok_len; i++) {
							strcat(strcat(command, " "), tok[i]);
						}
					}
					
				}

				if (tok_len > 6) {
					if ((cmd_tmp = strpbrk(tok[6], s2))!=NULL) {
						int cmd_len = strlen(cmd_tmp) == 1 ? 1 : 0;

						cmd = *cmd_tmp;

						if (cmd_len == 1) {
							command = xstrdup(tok[7]);
						} else {
							command = xstrdup(strrchr(tok[6], cmd_tmp[0])+1);
						}

						for (i=7+cmd_len; i<tok_len; i++) {
							strcat(strcat(command, " "), tok[i]);
						}
					}
				}

				switch (cmd) {
				case '@':
					if (delete) command = NULL;
					break;
				case '$':
					if (!delete) command = NULL;
					break;
				case '*':
				default :
					break;
				}
#endif
			}
			free(line);
		}
		fclose(file);
 end_parse:	/* nothing */ ;
	}

	umask(0);
	if (!delete) {
		if (mk_dir) {
			bb_make_directory(device_path, mode_path, FILEUTILS_RECUR);
			device_name = strcat(device_path, device_name);
		}
		if (sscanf(temp, "%d:%d", &major, &minor) != 2) return;
		if (mknod(device_name, mode | type, makedev(major, minor)) && errno != EEXIST)
			bb_perror_msg_and_die("mknod %s", device_name);

		if (major == bbg.root_major && minor == bbg.root_minor)
			symlink(device_name, "root");

		if (ENABLE_FEATURE_MDEV_CONF) chown(device_name, uid, gid);
	}

	if (command) {
		int rc;
		char *s;

		s = xasprintf("MDEV=%s", device_name);
		putenv(s);
		rc = system(command);
		s[4] = 0;
		putenv(s);
		free(s);
		if (rc == -1) bb_perror_msg_and_die("cannot run %s", command);
	}

	if (delete) {
		if (device_path) {
			char *tmp_path;

			tmp_path = strdupa(device_path);
			device_name = strcat(tmp_path, device_name);
		}

		unlink(device_name);

		if (device_path) {
//			if (rmdir(device_path) && errno != ENOTEMPTY)
//				bb_perror_msg_and_die("rmdir %s", device_path);
			remove_file(device_path, FILEUTILS_FORCE | FILEUTILS_RECUR);
		}
	}

}

/* Recursive search of /sys/block or /sys/class.  path must be a writeable
 * buffer of size PATH_MAX containing the directory string to start at. */

static int fileAction(const char *fileName, struct stat *statbuf, void *userData, int depth)
{
	char *last;

	last = bb_get_last_path_component((char *)fileName);

	if(!strcmp(last, "subsystem")) return FALSE;

	if (S_ISLNK(statbuf->st_mode)) {
		char *link_path, *new_path, *tmp_link;
		RESERVE_CONFIG_BUFFER(device_path, PATH_MAX);

		tmp_link = xmalloc_readlink_or_warn(fileName);
		link_path = strdupa(tmp_link);
		free(tmp_link);
		new_path = link_path;

		while (!strncmp(new_path, "../", 3)) {
			new_path = new_path + 3;
		}

		sprintf(device_path, "/sys/%s", new_path);
		make_device(device_path, 0);
		free(device_path);
		return TRUE;
	}

	if (!strcmp(last, "dev")) {
		char *tmp_name;

		tmp_name = strndupa(fileName, strlen(fileName) - 4);
		make_device(tmp_name, 0);
		return TRUE;
	}

	return FALSE;
}

int mdev_main(int argc, char **argv);
int mdev_main(int argc, char **argv)
{
	char *action;
	char *env_path;
	RESERVE_CONFIG_BUFFER(temp,PATH_MAX);

	xchdir(DEV_PATH);

	/* Scan */

	if (argc == 2 && !strcmp(argv[1],"-s")) {
		struct stat st;

		xstat("/", &st);
		bbg.root_major = major(st.st_dev);
		bbg.root_minor = minor(st.st_dev);
		strcpy(temp,"/sys/block");
		recursive_action(temp, ACTION_RECURSE, fileAction, 0, NULL, 0);
		strcpy(temp,"/sys/class");
		recursive_action(temp, ACTION_RECURSE, fileAction, 0, NULL, 0);

	/* Hotplug */

	} else {
		action = getenv("ACTION");
		env_path = getenv("DEVPATH");
		if (!action || !env_path)
			bb_show_usage();

		sprintf(temp, "/sys%s", env_path);
		if (!strcmp(action, "add")) make_device(temp,0);
		else if (!strcmp(action, "remove")) make_device(temp,1);
	}

	if (ENABLE_FEATURE_CLEAN_UP) RELEASE_CONFIG_BUFFER(temp);
	return 0;
}

--=-9jAROVjxIzSz5iuR+0q8
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox
--=-9jAROVjxIzSz5iuR+0q8--

From souf_oued@yahoo.fr Fri May 18 19:47:06 2007
Delivered-To: vda.linux@gmail.com
Received: by 10.78.52.7 with SMTP id z7cs207781huz;
        Fri, 18 May 2007 10:51:05 -0700 (PDT)
Received: by 10.114.169.2 with SMTP id r2mr988295wae.1179510664666;
        Fri, 18 May 2007 10:51:04 -0700 (PDT)
Return-Path: <busybox-bounces@busybox.net>
Received: from busybox.net (busybox.net [140.211.166.42])
        by mx.google.com with ESMTP id q18si5513572pog.2007.05.18.10.51.03;
        Fri, 18 May 2007 10:51:04 -0700 (PDT)
Received-SPF: pass (google.com: domain of busybox-bounces@busybox.net designates 140.211.166.42 as permitted sender)
Received: from localhost.localdomain (busybox [127.0.0.1])
	by busybox.net (BusyBox.Net Mail Daemon) with ESMTP id 9880C4808A;
	Fri, 18 May 2007 10:45:50 -0700 (PDT)
X-Original-To: busybox@busybox.net
Delivered-To: busybox@busybox.net
Received: from smtp009.mail.ukl.yahoo.com (smtp009.mail.ukl.yahoo.com
	[217.12.11.63])
	by busybox.net (BusyBox.Net Mail Daemon) with SMTP id 37DCC48020
	for <busybox@busybox.net>; Fri, 18 May 2007 10:45:22 -0700 (PDT)
Received: (qmail 59003 invoked from network); 18 May 2007 17:45:01 -0000
Received: from unknown (HELO ?192.168.0.2?) (souf_oued@82.66.250.26 with plain)
	by smtp009.mail.ukl.yahoo.com with SMTP; 18 May 2007 17:45:00 -0000
X-YMail-OSG: .vyR0xgVM1lpx158h83f_9h0Ht0qNMdKN9cpzb.03LKZn1jqv3Sdupa.gnhgxxiFNtHz2M3VkfOjfNZ9zfPbHUTwYAb5B3miL4iPmeh8MUqvuLHUt8BeNGM7XD2B4dxlD1WGPpE-
Subject: Re: [MDEV] mdev and CONFIG_SYSFS_DEPRECATED
From: Souf <souf_oued@yahoo.fr>
To: busybox@busybox.net
In-Reply-To: <1179491930.543.26.camel@localhost>
References: <1178747163.6603.3.camel@localhost.localdomain>
	<1179491930.543.26.camel@localhost>
Content-Type: multipart/mixed;
  boundary="=-IKV0xPYW4f2tIdjLBJ2S"
Date: Fri, 18 May 2007 19:47:06 +0200
Message-Id: <1179510426.3200.3.camel@localhost.localdomain>
Mime-Version: 1.0
X-Mailer: Evolution 2.8.3 (2.8.3-2.fc6) 
X-BeenThere: busybox@busybox.net
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Discussion and development of BusyBox <busybox.busybox.net>
List-Unsubscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox>,
	<mailto:busybox-request@busybox.net?subject=unsubscribe>
List-Archive: <http://busybox.net/lists/busybox>
List-Post: <mailto:busybox@busybox.net>
List-Help: <mailto:busybox-request@busybox.net?subject=help>
List-Subscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox>,
	<mailto:busybox-request@busybox.net?subject=subscribe>
Sender: busybox-bounces@busybox.net
Errors-To: busybox-bounces@busybox.net
Status: RO
X-Status: RT
X-KMail-EncryptionState: N
X-KMail-SignatureState: N
X-KMail-MDN-Sent:  


--=-IKV0xPYW4f2tIdjLBJ2S
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Le vendredi 18 mai 2007 à 14:38 +0200, Natanael Copa a écrit :
> On Wed, 2007-05-09 at 23:46 +0200, Souf wrote:
> > Hi all,
> > I rewrote mdev so that it can work with or without CONFIG_SYSFS_DEPRECATED in the kernel,
> > this rewriting implies a minor modification of the syntax of mdev.config
> > New the mdev can:
> > 1- create symlinks
> >         <symlink> -> <target>
> >         stderr -> /proc/self/fd/2
> >         XOR -> null
> > 
> > 2- create (sub-)directories
> >         <(sub-)directory> <octal permissions>
> >         bus/usb/001 0755
> >         disk/by-id 0755
> > 
> > 3- create a device in a (sub-)directory
> >         <device regex> <uid>:<gid> <octal permissions> [</>>/>
> > <(sub-)directory> <octal permissions>]
> >         seq 0:0 0666 >> snd 0755
> >         pcmC[0-9]D[0-9]p 0:0 0666 >> snd 0755
> >         event[0-9] 0:0 0600 >> input 0755
> > 
> > 4- execute an command
> >         <device regex> <uid>:<gid> <octal permissions> [</>>/>
> > <(sub-)directory> <octal permissions>] [<@|$|*> <command>]
> >         controlC[0-9] 0:0 0666 >> snd 0755  @ echo "hello $MDEV"
> >         seq     0:0 0666 $echo "good bye $MDEV"
> >         timer 0:0 0666 >> snd 0755 * echo "Hi $MDEV"    
> > 
> >         @ Run after creating the device.
> >         $ Run before removing the device.
> >         * Run both after creating and before removing the device.
> 
> Is this new? Isnt that how current mdev works?
> 

I do not believe that the current medev is able to create symlinks,
neither (sub-)directories, nor devices in (sub-)directories. I agree for
command execution but it is not the same code.
In addition to that, I used libbb to parse mdev.conf and create devs:
xmalloc_getline()
last_char_is()
recursive_action()
bb_make_directory()
remove_file()
bb_get_last_path_component()
xmalloc_readlink_or_warn()

> > 5- work with or without CONFIG_SYSFS_DEPRECATED
> 
> I just came across this one while upgrading to 2.6.20. This should be
> fixed even if the rest is rejected.

I rectify: 
5- work with AND without CONFIG_SYSFS_DEPRECATED

> Havent looked at the code too much yet, but I definitively like the idea
> of letting mdev create devs in subdirs.
> 
> I wonder if it might be worth having dir creation as a config option?
Done, I added 2 options of configuration:
FEATURE_MDEV_MKDIR
FEATURE_MDEV_SYMLINK

This mdev works with busybox >= svn18362

Thanks

Malek


--=-IKV0xPYW4f2tIdjLBJ2S
Content-Disposition: attachment; filename=mdev.patch
Content-Type: text/x-patch; name=mdev.patch; charset=UTF-8
Content-Transfer-Encoding: 7bit

--- busybox/util-linux/Config.in.orig	2007-05-18 09:20:18.000000000 +0200
+++ busybox/util-linux/Config.in	2007-05-18 16:47:31.000000000 +0200
@@ -294,6 +294,26 @@ config FEATURE_MDEV_EXEC
 
 	  For more information, please see docs/mdev.txt
 
+config FEATURE_MDEV_MKDIR
+	bool "Support sub-dir creation"
+	default n
+	depends on FEATURE_MDEV_CONF
+	help
+	  This option allows mdev to create sub-directories in /dev,
+	  for example:
+		/dev/bus/usb/001/
+		/dev/disk/by-label/
+
+config FEATURE_MDEV_SYMLINK
+	bool "Support symlinks creation"
+	default n
+	depends on FEATURE_MDEV_CONF
+	help
+	  This option allows mdev to create symlinks in /dev,
+	  for example:
+		ram -> ram1
+		stderr -> /proc/self/fd/2
+
 config MKSWAP
 	bool "mkswap"
 	default n
--- busybox/util-linux/mdev.c.orig	2007-05-18 09:20:18.000000000 +0200
+++ busybox/util-linux/mdev.c	2007-05-18 17:01:01.000000000 +0200
@@ -24,9 +24,9 @@ struct mdev_globals
 /* mknod in /dev based on a path like "/sys/block/hda/hda1" */
 static void make_device(char *path, int delete)
 {
-	char *device_name;
-	int major, minor, type, len;
-	int mode = 0660;
+	char *device_name, *device_path = NULL;
+	int major, minor, type, len, mk_dir=0;
+	mode_t mode = 0660, mode_path = 0660;
 	uid_t uid = 0;
 	gid_t gid = 0;
 	char *temp = path + strlen(path);
@@ -47,129 +47,167 @@ static void make_device(char *path, int 
 	/* Determine device name, type, major and minor */
 
 	device_name = strrchr(path, '/') + 1;
-	type = path[5]=='c' ? S_IFCHR : S_IFBLK;
+	type = (path[5]=='b') ? S_IFBLK : S_IFCHR;
 
 	/* If we have a config file, look up permissions for this device */
 
 	if (ENABLE_FEATURE_MDEV_CONF) {
-		char *conf, *pos, *end;
-		int line, fd;
+		char *line, *tok_tmp, *tok_line=NULL, **tok = NULL;
+		FILE *file;
+		int i;
 
-		/* mmap the config file */
-		fd = open("/etc/mdev.conf", O_RDONLY);
-		if (fd < 0)
-			goto end_parse;
-		len = xlseek(fd, 0, SEEK_END);
-		conf = mmap(NULL, len, PROT_READ, MAP_PRIVATE, fd, 0);
-		close(fd);
-		if (!conf)
+		file = fopen_or_warn("/etc/mdev.conf", "r");
+		if (file < 0)
 			goto end_parse;
 
-		line = 0;
-		/* Loop through lines in mmaped file*/
-		for (pos=conf; pos-conf<len;) {
-			int field;
-			char *end2;
+		while ((line = xmalloc_getline(file)) != NULL) {
+			char *regex = NULL;
+			regex_t match;
+			regmatch_t off;
+			int result, tok_len = 1;
+			char *tok_id[2], *tok_id_tmp;
+			char *s;
 
-			line++;
-			/* find end of this line */
-			for (end=pos; end-conf<len && *end!='\n'; end++)
-				;
+			tok_line = strdupa(line);
+			if (tok_line[0] == '#' || strlen(tok_line)==0) continue;
 
-			/* Three fields: regex, uid:gid, mode */
-			for (field=0; field < (3 + ENABLE_FEATURE_MDEV_EXEC);
-					field++)
-			{
-				/* Skip whitespace */
-				while (pos<end && isspace(*pos)) pos++;
-				if (pos==end || *pos=='#') break;
-				for (end2=pos;
-					end2<end && !isspace(*end2) && *end2!='#'; end2++)
-					;
+			for (i=0; i<strlen(tok_line); i++) {
+				if (isspace(tok_line[i]) && !isspace(tok_line[i+1]))
+					tok_len++;
+			}
+			tok = (char **) xrealloc(tok, tok_len * sizeof(char *));
 
-				if (field == 0) {
-					/* Regex to match this device */
+			for (i=0; (tok_tmp=strtok(tok_line, " \t")); i++) {
+				tok[i] = tok_tmp;
+				tok_line = NULL;
+			}
 
-					char *regex = strndupa(pos, end2-pos);
-					regex_t match;
-					regmatch_t off;
-					int result;
+			if (tok_len == 2 && ENABLE_FEATURE_MDEV_MKDIR) {
+				mode_path = (mode_t)strtoul(tok[1], &s, 8);
+				bb_make_directory(tok[0], mode_path, FILEUTILS_RECUR);
+				continue;
+			}
 
-					/* Is this it? */
-					xregcomp(&match,regex, REG_EXTENDED);
-					result = regexec(&match, device_name, 1, &off, 0);
-					regfree(&match);
+			if (!strcmp(tok[1], "->") && ENABLE_FEATURE_MDEV_SYMLINK) {
+				if (symlink(tok[2], tok[0]) && errno != EEXIST)
+					bb_perror_msg_and_die("symlink %s", tok[0]);
+				continue;
+			}
 
-					/* If not this device, skip rest of line */
-					if (result || off.rm_so
-							|| off.rm_eo != strlen(device_name))
-						break;
-				}
-				if (field == 1) {
-					/* uid:gid */
+			/* Regex to match this device */
+			regex = tok[0];
+			xregcomp(&match,regex, REG_EXTENDED);
+			result = regexec(&match, device_name, 1, &off, 0);
+			regfree(&match);
 
-					char *s, *s2;
+			/* If not this device, skip rest of line */
+			if (result || off.rm_so || off.rm_eo != strlen(device_name))
+				continue;
 
-					/* Find : */
-					for (s=pos; s<end2 && *s!=':'; s++)
-						;
-					if (s == end2) break;
 
-					/* Parse UID */
-					uid = strtoul(pos, &s2, 10);
-					if (s != s2) {
-						struct passwd *pass;
-						pass = getpwnam(strndupa(pos, s-pos));
-						if (!pass) break;
-						uid = pass->pw_uid;
-					}
-					s++;
-					/* parse GID */
-					gid = strtoul(s, &s2, 10);
-					if (end2 != s2) {
-						struct group *grp;
-						grp = getgrnam(strndupa(s, end2-s));
-						if (!grp) break;
-						gid = grp->gr_gid;
-					}
-				}
-				if (field == 2) {
-					/* mode */
+			for (i=0; (tok_id_tmp=strtok(tok[1], ":")); i++) {
+				if (tok_id_tmp) tok_id[i] = tok_id_tmp;
+				tok[1] = NULL;
+			}
 
-					mode = strtoul(pos, &pos, 8);
-					if (pos != end2) break;
+			/* uid:gid */
+			uid = strtoul(tok_id[0], &s, 10);
+			if (tok_id[0] == s) {
+				struct passwd *pass;
+				pass = getpwnam(tok_id[0]);
+				if (!pass) continue;
+				uid = pass->pw_uid;
+			}
+
+			gid = strtoul(tok_id[1], &s, 10);
+			if (tok_id[1] == s) {
+				struct group *grp;
+				grp = getgrnam(tok_id[1]);
+				if (!grp) continue;
+				gid = grp->gr_gid;
+			}
+
+			/* mode */
+			mode = (mode_t)strtoul(tok[2], &s, 8);
+
+			if (tok_len > 3) {
+#if ENABLE_FEATURE_MDEV_EXEC
+				const char *s2 = "@$*";
+				char *cmd_tmp;
+				unsigned int cmd = 0;
+#endif
+				/* mk_dir */
+				if (!strcmp(tok[3], ">>")) {
+					mk_dir = 1;
+					device_path = strdupa(tok[4]);
+					if (last_char_is(device_path, '/') == NULL)
+						strcat(device_path, "/");
+
+					mode_path = (mode_t)strtoul(tok[5], &s, 8);
 				}
-				if (ENABLE_FEATURE_MDEV_EXEC && field == 3) {
-					// Command to run
-					const char *s = "@$*";
-					const char *s2;
-					s2 = strchr(s, *pos++);
-					if (!s2) {
-						// Force error
-						field = 1;
-						break;
+#if ENABLE_FEATURE_MDEV_EXEC
+				else {
+					if ((cmd_tmp = strpbrk(tok[3], s2))!=NULL) {
+						int cmd_len = strlen(cmd_tmp) == 1 ? 1 : 0;
+
+						cmd = *cmd_tmp;
+
+						if (cmd_len == 1) {
+							command = strdupa(tok[4]);
+						} else {
+							command = strdupa(strrchr(tok[3], cmd_tmp[0])+1);
+						}
+
+						for (i=4+cmd_len; i<tok_len; i++) {
+							strcat(strcat(command, " "), tok[i]);
+						}
 					}
-					if ((s2-s+1) & (1<<delete))
-						command = xstrndup(pos, end-pos);
+					
 				}
 
-				pos = end2;
-			}
+				if (tok_len > 6) {
+					if ((cmd_tmp = strpbrk(tok[6], s2))!=NULL) {
+						int cmd_len = strlen(cmd_tmp) == 1 ? 1 : 0;
 
-			/* Did everything parse happily? */
+						cmd = *cmd_tmp;
 
-			if (field > 2) break;
-			if (field) bb_error_msg_and_die("bad line %d",line);
+						if (cmd_len == 1) {
+							command = xstrdup(tok[7]);
+						} else {
+							command = xstrdup(strrchr(tok[6], cmd_tmp[0])+1);
+						}
 
-			/* Next line */
-			pos = ++end;
+						for (i=7+cmd_len; i<tok_len; i++) {
+							strcat(strcat(command, " "), tok[i]);
+						}
+					}
+				}
+
+				switch (cmd) {
+				case '@':
+					if (delete) command = NULL;
+					break;
+				case '$':
+					if (!delete) command = NULL;
+					break;
+				case '*':
+				default :
+					break;
+				}
+#endif
+			}
+			free(line);
 		}
-		munmap(conf, len);
+		fclose(file);
  end_parse:	/* nothing */ ;
 	}
 
 	umask(0);
 	if (!delete) {
+		if (mk_dir) {
+			bb_make_directory(device_path, mode_path, FILEUTILS_RECUR);
+			device_name = strcat(device_path, device_name);
+		}
 		if (sscanf(temp, "%d:%d", &major, &minor) != 2) return;
 		if (mknod(device_name, mode | type, makedev(major, minor)) && errno != EEXIST)
 			bb_perror_msg_and_die("mknod %s", device_name);
@@ -179,6 +217,7 @@ static void make_device(char *path, int 
 
 		if (ENABLE_FEATURE_MDEV_CONF) chown(device_name, uid, gid);
 	}
+
 	if (command) {
 		int rc;
 		char *s;
@@ -189,45 +228,65 @@ static void make_device(char *path, int 
 		s[4] = 0;
 		putenv(s);
 		free(s);
-		free(command);
 		if (rc == -1) bb_perror_msg_and_die("cannot run %s", command);
 	}
-	if (delete) unlink(device_name);
+
+	if (delete) {
+		if (device_path) {
+			char *tmp_path;
+
+			tmp_path = strdupa(device_path);
+			device_name = strcat(tmp_path, device_name);
+		}
+
+		unlink(device_name);
+
+		if (device_path) {
+			remove_file(device_path, FILEUTILS_FORCE | FILEUTILS_RECUR);
+		}
+	}
+
 }
 
 /* Recursive search of /sys/block or /sys/class.  path must be a writeable
  * buffer of size PATH_MAX containing the directory string to start at. */
 
-static void find_dev(char *path)
+static int fileAction(const char *fileName, struct stat *statbuf, void *userData, int depth)
 {
-	DIR *dir;
-	size_t len = strlen(path);
-	struct dirent *entry;
+	char *last;
 
-	dir = opendir(path);
-	if (dir == NULL)
-		return;
+	last = bb_get_last_path_component((char *)fileName);
 
-	while ((entry = readdir(dir)) != NULL) {
-		struct stat st;
+	if(!strcmp(last, "subsystem")) return FALSE;
 
-		/* Skip "." and ".." (also skips hidden files, which is ok) */
+	if (S_ISLNK(statbuf->st_mode)) {
+		char *link_path, *new_path, *tmp_link;
+		RESERVE_CONFIG_BUFFER(device_path, PATH_MAX);
 
-		if (entry->d_name[0] == '.')
-			continue;
+		tmp_link = xmalloc_readlink_or_warn(fileName);
+		link_path = strdupa(tmp_link);
+		free(tmp_link);
+		new_path = link_path;
 
-		// uClibc doesn't fill out entry->d_type reliably. so we use lstat().
+		while (!strncmp(new_path, "../", 3)) {
+			new_path = new_path + 3;
+		}
 
-		snprintf(path+len, PATH_MAX-len, "/%s", entry->d_name);
-		if (!lstat(path, &st) && S_ISDIR(st.st_mode)) find_dev(path);
-		path[len] = 0;
+		sprintf(device_path, "/sys/%s", new_path);
+		make_device(device_path, 0);
+		free(device_path);
+		return TRUE;
+	}
 
-		/* If there's a dev entry, mknod it */
+	if (!strcmp(last, "dev")) {
+		char *tmp_name;
 
-		if (!strcmp(entry->d_name, "dev")) make_device(path, 0);
+		tmp_name = strndupa(fileName, strlen(fileName) - 4);
+		make_device(tmp_name, 0);
+		return TRUE;
 	}
 
-	closedir(dir);
+	return FALSE;
 }
 
 int mdev_main(int argc, char **argv);
@@ -248,9 +307,9 @@ int mdev_main(int argc, char **argv)
 		bbg.root_major = major(st.st_dev);
 		bbg.root_minor = minor(st.st_dev);
 		strcpy(temp,"/sys/block");
-		find_dev(temp);
+		recursive_action(temp, ACTION_RECURSE, fileAction, 0, NULL, 0);
 		strcpy(temp,"/sys/class");
-		find_dev(temp);
+		recursive_action(temp, ACTION_RECURSE, fileAction, 0, NULL, 0);
 
 	/* Hotplug */
 

--=-IKV0xPYW4f2tIdjLBJ2S
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox
--=-IKV0xPYW4f2tIdjLBJ2S--

From solar@gentoo.org Fri May 18 20:02:02 2007
Delivered-To: vda.linux@gmail.com
Received: by 10.78.52.7 with SMTP id z7cs208372huz;
        Fri, 18 May 2007 11:04:37 -0700 (PDT)
Received: by 10.64.143.12 with SMTP id q12mr6893208qbd.1179511476617;
        Fri, 18 May 2007 11:04:36 -0700 (PDT)
Return-Path: <busybox-bounces@busybox.net>
Received: from busybox.net (busybox.net [140.211.166.42])
        by mx.google.com with ESMTP id f13si4267832qba.2007.05.18.11.04.35;
        Fri, 18 May 2007 11:04:36 -0700 (PDT)
Received-SPF: pass (google.com: domain of busybox-bounces@busybox.net designates 140.211.166.42 as permitted sender)
Received: from localhost.localdomain (busybox [127.0.0.1])
	by busybox.net (BusyBox.Net Mail Daemon) with ESMTP id 4B888480A1;
	Fri, 18 May 2007 11:02:52 -0700 (PDT)
X-Original-To: busybox@busybox.net
Delivered-To: busybox@busybox.net
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	by busybox.net (BusyBox.Net Mail Daemon) with ESMTP id A163B48089
	for <busybox@busybox.net>; Fri, 18 May 2007 11:02:25 -0700 (PDT)
Received: from onyx.private.gni.com (wall.sjc2.gni.com [69.80.192.42])
	(using TLSv1 with cipher RC4-MD5 (128/128 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTP id 6704864DE0;
	Fri, 18 May 2007 18:02:04 +0000 (UTC)
Subject: Re: [MDEV] mdev and CONFIG_SYSFS_DEPRECATED
From: Ned Ludd <solar@gentoo.org>
To: Souf <souf_oued@yahoo.fr>
In-Reply-To: <1179510426.3200.3.camel@localhost.localdomain>
References: <1178747163.6603.3.camel@localhost.localdomain>
	<1179491930.543.26.camel@localhost>
	<1179510426.3200.3.camel@localhost.localdomain>
Organization: Gentoo Linux
Date: Fri, 18 May 2007 11:02:02 -0700
Message-Id: <1179511322.12689.6.camel@onyx.private.gni.com>
Mime-Version: 1.0
X-Mailer: Evolution 2.6.2 
Cc: busybox@busybox.net
X-BeenThere: busybox@busybox.net
X-Mailman-Version: 2.1.9
Precedence: list
Reply-To: solar@gentoo.org
List-Id: Discussion and development of BusyBox <busybox.busybox.net>
List-Unsubscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox>,
	<mailto:busybox-request@busybox.net?subject=unsubscribe>
List-Archive: <http://busybox.net/lists/busybox>
List-Post: <mailto:busybox@busybox.net>
List-Help: <mailto:busybox-request@busybox.net?subject=help>
List-Subscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox>,
	<mailto:busybox-request@busybox.net?subject=subscribe>
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Sender: busybox-bounces@busybox.net
Errors-To: busybox-bounces@busybox.net
Status: RO
X-Status: RC
X-KMail-EncryptionState: N
X-KMail-SignatureState: N
X-KMail-MDN-Sent:  

On Fri, 2007-05-18 at 19:47 +0200, Souf wrote:
> Le vendredi 18 mai 2007 =E0 14:38 +0200, Natanael Copa a =E9crit :
> > On Wed, 2007-05-09 at 23:46 +0200, Souf wrote:
> > > Hi all,
> > > I rewrote mdev so that it can work with or without CONFIG_SYSFS_DEPRE=
CATED in the kernel,
> > > this rewriting implies a minor modification of the syntax of mdev.con=
fig

It would be ideal not to alter the syntax of mdev.conf in anyway that =

people who already have established working configs will be forced to =

upgrade. Doing just that sort of the thing is why many of us dislike =

udev with it's ever changing code base.


> > > New the mdev can:
> > > 1- create symlinks
> > >         <symlink> -> <target>
> > >         stderr -> /proc/self/fd/2
> > >         XOR -> null
> > > =

> > > 2- create (sub-)directories
> > >         <(sub-)directory> <octal permissions>
> > >         bus/usb/001 0755
> > >         disk/by-id 0755
> > > =

> > > 3- create a device in a (sub-)directory
> > >         <device regex> <uid>:<gid> <octal permissions> [</>>/>
> > > <(sub-)directory> <octal permissions>]
> > >         seq 0:0 0666 >> snd 0755
> > >         pcmC[0-9]D[0-9]p 0:0 0666 >> snd 0755
> > >         event[0-9] 0:0 0600 >> input 0755
> > > =

> > > 4- execute an command
> > >         <device regex> <uid>:<gid> <octal permissions> [</>>/>
> > > <(sub-)directory> <octal permissions>] [<@|$|*> <command>]
> > >         controlC[0-9] 0:0 0666 >> snd 0755  @ echo "hello $MDEV"
> > >         seq     0:0 0666 $echo "good bye $MDEV"
> > >         timer 0:0 0666 >> snd 0755 * echo "Hi $MDEV"    =

> > > =

> > >         @ Run after creating the device.
> > >         $ Run before removing the device.
> > >         * Run both after creating and before removing the device.
> > =

> > Is this new? Isnt that how current mdev works?
> > =

> =

> I do not believe that the current medev is able to create symlinks,
> neither (sub-)directories, nor devices in (sub-)directories. I agree for
> command execution but it is not the same code.

I've done most of what your doing simply in the mdev.conf when creating =

the "null" device, events and such. It's hackish but I think the end =

result is probably smaller than additional compiled binary code.

> In addition to that, I used libbb to parse mdev.conf and create devs:
> xmalloc_getline()
> last_char_is()
> recursive_action()
> bb_make_directory()
> remove_file()
> bb_get_last_path_component()
> xmalloc_readlink_or_warn()
> =



> > > 5- work with or without CONFIG_SYSFS_DEPRECATED
> > =

> > I just came across this one while upgrading to 2.6.20. This should be
> > fixed even if the rest is rejected.
> =

> I rectify: =

> 5- work with AND without CONFIG_SYSFS_DEPRECATED

Yeah we want that part which checks for the symlinks.

> > Havent looked at the code too much yet, but I definitively like the idea
> > of letting mdev create devs in subdirs.
> > =

> > I wonder if it might be worth having dir creation as a config option?
> Done, I added 2 options of configuration:
> FEATURE_MDEV_MKDIR
> FEATURE_MDEV_SYMLINK
> =

> This mdev works with busybox >=3D svn18362
> =

> Thanks
> =

> Malek
> =

> _______________________________________________
> busybox mailing list
> busybox@busybox.net
> http://busybox.net/cgi-bin/mailman/listinfo/busybox
-- =

Ned Ludd <solar@gentoo.org>
Gentoo Linux

_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox

From souf_oued@yahoo.fr Fri May 18 20:45:51 2007
Delivered-To: vda.linux@gmail.com
Received: by 10.78.52.7 with SMTP id z7cs210381huz;
        Fri, 18 May 2007 11:44:06 -0700 (PDT)
Received: by 10.35.57.2 with SMTP id j2mr3183018pyk.1179513846148;
        Fri, 18 May 2007 11:44:06 -0700 (PDT)
Return-Path: <busybox-bounces@busybox.net>
Received: from busybox.net (busybox.net [140.211.166.42])
        by mx.google.com with ESMTP id f57si9602909pyh.2007.05.18.11.44.05;
        Fri, 18 May 2007 11:44:06 -0700 (PDT)
Received-SPF: pass (google.com: domain of busybox-bounces@busybox.net designates 140.211.166.42 as permitted sender)
Received: from localhost.localdomain (busybox [127.0.0.1])
	by busybox.net (BusyBox.Net Mail Daemon) with ESMTP id 28ED04856E;
	Fri, 18 May 2007 11:43:50 -0700 (PDT)
X-Original-To: busybox@busybox.net
Delivered-To: busybox@busybox.net
Received: from smtp006.mail.ukl.yahoo.com (smtp006.mail.ukl.yahoo.com
	[217.12.11.95])
	by busybox.net (BusyBox.Net Mail Daemon) with SMTP id DA89A48567
	for <busybox@busybox.net>; Fri, 18 May 2007 11:43:45 -0700 (PDT)
Received: (qmail 72187 invoked from network); 18 May 2007 18:43:44 -0000
Received: from unknown (HELO ?192.168.0.2?) (souf_oued@82.66.250.26 with plain)
	by smtp006.mail.ukl.yahoo.com with SMTP; 18 May 2007 18:43:44 -0000
X-YMail-OSG: 6CO0W6IVM1mk4uqZxH10DpiFBDyCt86trmnO8ZWLKWy5eYO87iTxuhiR5YzVG3CHDFEnI_hk6Jjb.Dt_dDL7GRo-
Subject: Re: [MDEV] mdev and CONFIG_SYSFS_DEPRECATED
From: Souf <souf_oued@yahoo.fr>
To: solar@gentoo.org
In-Reply-To: <1179511322.12689.6.camel@onyx.private.gni.com>
References: <1178747163.6603.3.camel@localhost.localdomain>
	<1179491930.543.26.camel@localhost>
	<1179510426.3200.3.camel@localhost.localdomain>
	<1179511322.12689.6.camel@onyx.private.gni.com>
Content-Type: multipart/mixed;
  boundary="=-JUuYxkhJBPcRxXIPJWU5"
Date: Fri, 18 May 2007 20:45:51 +0200
Message-Id: <1179513951.3397.13.camel@localhost.localdomain>
Mime-Version: 1.0
X-Mailer: Evolution 2.8.3 (2.8.3-2.fc6) 
Cc: busybox@busybox.net
X-BeenThere: busybox@busybox.net
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Discussion and development of BusyBox <busybox.busybox.net>
List-Unsubscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox>,
	<mailto:busybox-request@busybox.net?subject=unsubscribe>
List-Archive: <http://busybox.net/lists/busybox>
List-Post: <mailto:busybox@busybox.net>
List-Help: <mailto:busybox-request@busybox.net?subject=help>
List-Subscribe: <http://busybox.net/cgi-bin/mailman/listinfo/busybox>,
	<mailto:busybox-request@busybox.net?subject=subscribe>
Sender: busybox-bounces@busybox.net
Errors-To: busybox-bounces@busybox.net
Status: RO
X-Status: RT
X-KMail-EncryptionState: N
X-KMail-SignatureState: N
X-KMail-MDN-Sent:  


--=-JUuYxkhJBPcRxXIPJWU5
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

Le vendredi 18 mai 2007 à 11:02 -0700, Ned Ludd a écrit :

> It would be ideal not to alter the syntax of mdev.conf in anyway that 
> people who already have established working configs will be forced to 
> upgrade. Doing just that sort of the thing is why many of us dislike 
> udev with it's ever changing code base.

The syntax of mdev.con was not altered, what exists continuous perfectly
to work but it there optional additions, I attached my mdev.conf

> > I rectify: 
> > 5- work with AND without CONFIG_SYSFS_DEPRECATED
> 
> Yeah we want that part which checks for the symlinks.

you had it in the preceding message.
http://busybox.net/lists/busybox/attachments/20070518/845f1b6f/attachment-0001.bin

Thanks.

Malek

--=-JUuYxkhJBPcRxXIPJWU5
Content-Disposition: attachment; filename=mdev.conf
Content-Type: text/plain; name=mdev.conf; charset=utf-8
Content-Transfer-Encoding: 7bit

# /etc/mdev.conf

#create symlinks
# NO COMMAND WITH SYMLINK
#<symlink> -> <target>
MAKEDEV -> /sbin/MAKEDEV
core -> /proc/kcore
fd -> /proc/self/fd
ram -> ram1
stderr -> /proc/self/fd/2
stdin -> /proc/self/fd/0
stdout -> /proc/self/fd/1
vbi -> vbi0
video -> video0
log -> /tmp/log
XOR -> null

#create (sub-)directories
# NO COMMAND WITH SUBDIRS
#<(sub-)directory> <octal permissions>
pts 755
shm 777

#Create a simple device
#<device regex> <uid>:<gid> <octal permissions>
sda 0:0 0640
sda[0-9] 0:0 0640

null 0:0 777
zero 0:0 666

#Create a simple device with command
#<device regex> <uid>:<gid> <octal permissions> [<@|$|*> <command>]
rtc 0:0 644 @echo "HELLO $MDEV"
urandom 0:0 444 @ echo "HELLO $MDEV"
console 0:5 0600
fd0 0:11 0660
kmem 0:9 000
mem 0:9 0640
port 0:9 0640
ptmx 0:5 0666

tty 0:5 0666
tty[0-9]* 0:5 0660
ttyS* 0:20 660

fb0 0:5 0640

mtd[0-9] 0:0 640

#Create a device in a (sub-)directory
#<device regex> <uid>:<gid> <octal permissions> [</>>/><(sub-)directory> <octal permissions>]
tun 0:0 660 >> net 755

event[0-9] 0:0 0600 >> input 0755
mice 0:0 0600 >> input 0755
mouse[0-9] 0:0 0600 >> input 0755

#<device regex> <uid>:<gid> <octal permissions> [</>>/><(sub-)directory> <octal permissions>] [<@|$|*> <command>]

seq 0:0 0666 >> snd 755 @echo "HELLO $MDEV"
timer 0:0 0666 >> snd 755	@ echo "HELLO $MDEV"
pcmC[0-9]D[0-9]p 0:0 0666 >> snd 755 $echo "GOOD BYE $MDEV"
pcmC[0-9]D[0-9]c 0:0 0666 >> snd 755 $ echo "GOOD BYE $MDEV"
controlC[0-9] 0:0 0666 >> snd 755 * echo "HI $MDEV"

--=-JUuYxkhJBPcRxXIPJWU5
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox
--=-JUuYxkhJBPcRxXIPJWU5--

