Re: How do I choose an arbitrary minor number for my tty device?

From: Kay Sievers
Date: Wed Dec 01 2010 - 04:54:54 EST


On Wed, Dec 1, 2010 at 02:00, Greg KH <greg@xxxxxxxxx> wrote:
> On Tue, Nov 30, 2010 at 01:33:52PM -0600, Timur Tabi wrote:
>> Greg KH wrote:
>> >>> > > When this function is called, userspace had better know exactly what is
>> >>> > > going on as it can get confused due to the lack of uevents happening.
>> >> >
>> >> > Thanks for the explanation, but I'm just concerned that you'll add a comment
>> >> > that says, "don't call this function". ÂA quick grep will show that there are
>> >> > users of this function, and we'll have this exact conversation all over again.
>> > Care to turn the above into a patch? ÂI'll be glad to apply that as well
>>
>> One question: why are uevents not happening?
>
> What uevent would describe this? ÂUserspace asked for the rename to
> happen, so it better be aware that it did.
>
> We don't want to do a "remove" and then "add" sequence of events, that
> would confuse everyone.

A bit more details:

First: never rename anything! :)

It's racy at many levels, symlinks and other stuff are not replaced
atomically, you get a "move" uevent", but it's not easy to connect the
event to the old and new device. Device nodes are not renamed at all,
there isn't even support for that in the kernel now.

In the meantime during renaming, your target name might be taken by
another driver, creating conflicts. Or the old name is taken directly
after you renamed it -- then you get events for the same DEVPATH,
before you even seet the "move" event. It's just a mess, and nothing
new should ever rely on kernel device renaming. Besides that it's not
even implemented now for other things than (driver-core wise very
simple) network devices.

We are currently about to change network renaming in udev to
completely disallow renaming of devices in the same namespace as the
kernel uses, because we can't solve the problems properly, that arise
with swapping names of multiple interfaces without races. Means,
renaming of eth[0-9]* will only be allowed to some other name than
eth[0-9]*, for the mentioned reasons.

Make up a "real" name in the driver before you register anything, or
add some other attributes for userspace to find the device, or use
udev to add symlinks -- but never rename kernel devices later, it's a
complete mess. We don't even want to get into that and try to
implement the missing pieces in the core. We really have other pieces
to fix in the driver core mess. :)

Kay
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/