mdev accidently erases previously created nodes while trying to rename nodes
Jean Wolter
jw5 at os.inf.tu-dresden.de
Wed Jun 17 20:28:18 UTC 2009
Denys Vlasenko <vda.linux at googlemail.com> writes:
> On Wed, Jun 17, 2009 at 3:52 PM, Jean Wolter<jw5 at os.inf.tu-dresden.de> wrote:
>> while using mdev to create device nodes for the capi subsystem mdev
>> accidently deletes a previously created node. Assume the following
>> lines in mdev.conf:
>>
>> capi 0:0 0660 =capi20
>> capi([0-9]) 0:0 0660 =capi20.0%1
>> capi([0-9]*) 0:0 0660 =capi20.%1
>>
>> After loading the capi module the kernel generate a number of hotplug
>> events, starting with capi, followed by capi0-capi32. mdev creates
>> /dev/capi, and renames it to /dev/capi20.
>
> This seems to be ok.
>
>> When the event "add tty /class/tty/capi0" comes in, mdev executes
>>
>> unlink /dev/capi20
>> mknod /dev/capi20
>> rename(/dev/capi20,/dev/capi20.20)
>>
>> and erases the original /dev/capi20 device while doing this.
>
> This is the corresponding code:
>
> /* "Execute" the line we found */
> if (!delete && major >= 0) {
> if (ENABLE_FEATURE_MDEV_RENAME)
> unlink(device_name);
>
> You say that /dev/capi20 is unlinked. Why? In event
> "add tty /class/tty/capi0" device_name == "capi0",
> thus unlink(device_name) won't delete "capi20". I'm confused.
You have every right to be confused. The events start with "add tty
/class/tty/capi0" up to /claas/tty/capi32. In the middle of this
sequence there is the event "add tty /class/tty/capi20"
device_name="capi20". busybox is configured with
ENABLE_FEATURE_MDEV_RENAME, so the first thing happens is an
unlink(device_name); in this case unlink("capi20").
regards,
Jean
More information about the busybox
mailing list