On Tue, Sep 03, 2019 at 06:35:30PM -0700, Sagi Grimberg wrote: > > > > Still don't understand how this is ok... > > > > > > I have /dev/nvme0 represents a network endpoint that I would discover > > > from, it is raising me an event to do a discovery operation (namely to > > > issue an ioctl to it) so my udev code calls a systemd script. > > > > > > By the time I actually get to do that, /dev/nvme0 represents now a new > > > network endpoint (where the event is no longer relevant to). I would > > > rather the discovery to explicitly fail than to give me something > > > different, so we pass some arguments that we verify in the operation. > > > > > > Its a stretch case, but it was raised by people as a potential issue. > > > > Ok, and how do you handle this same thing for something like /dev/sda ? > > (hint, it isn't new, and is something we solved over a decade ago) > > > > If you worry about stuff like this, use a persistant device naming > > scheme and have your device node be pointed to by a symlink. Create > > that symlink by using the information in the initial 'ADD' uevent. > > > > That way, when userspace opens the device node, it "knows" exactly which > > one it opens. It sounds like you have a bunch of metadata to describe > > these uniquely, so pass that in the ADD event, not in some other crazy > > non-standard manner. > > We could send these variables when adding the device and then validating > them using a rich-text-explanatory symlink. Seems slightly backwards to > me, but that would work too.
That's the way the driver model is expected to work, instead of having to do crazy device-specific stuff. > We create the char device using device_add (in nvme_init_subsystem), > I didn't find any way to append env variables to that ADD uevent. You do that in your uevent or dev_uevent callback like all other subsystems. Nothing "new" to do here, again, it's been working fine for everyone else for well over a decade now :) thanks, greg k-h