[sane-devel] [RFC] Hotplug proposal -- migrating to hotplug hooks (hotplug & hotplug-ng compatible)
Gerhard Jaeger
gerhard@gjaeger.de
Thu, 17 Feb 2005 09:33:11 +0100
Hi,
On Tuesday 15 February 2005 19:47, Julien BLACHE wrote:
> Hi,
>
> With hotplug-ng dropping support for the way we're using it as of now,
> there's a need to revamp the hotplug stuff we use.
>
> First of all, recent versions of hotplug also support hooks, so the
> proposed solution would be backward-compatible to a certain degree.
>
> The idea basically is to build a simple database (simpler than the
> usermap file) of the supported scanners, and, while doing so, adding
> some features to the hotplug stuff.
I currently didn't check, how the libsane.usermap has been created,
but I think this should work somehow "automagically"...
>
> Database layout:
> ----------------
>
> The database would be installed under $sysconfdir/sane.d/hotplug.
>
> The idea is to have one file per USB vendor ID; this file would
> contain one line (plus comments) per known scanner product ID.
>
> Now, we have the possibility to add some nice features, by adding
> fields to this file, like:
>
> # PID Ownership Perms [Optional: user-defined script]
> 0xPPPP root:scanner 0660 [/usr/local/bin/scanner-foo.sh]
>
> This would solve complaint #1: as of now, it's not possible to have
> different scanners owned by different users (where different means
> different PID and/or VID, because we can't do much more...)
>
>
> Hotplug script:
> ---------------
>
> The hook gets the device number (DEVNUM) and bus number (BUSNUM) from
> the environment.
>
> It's now easy to get the DEVVID and DEVPID for the device, then look
> for $sysconfdir/sane.d/hotplug/$DEVVID, and, if it exists, to grep for
> ^$DEVPID, then apply the corresponding ownership and permissions, and
> run the user-specified script if it exists.
>
>
> User script:
> -----------
>
> The user script would be called with DEVNUM, BUSNUM, DEVVID and DEVPID
> in the environment.
>
> I'm going to play with this next week, and this will probably make it
> into the next revision of the Debian package, and to the CVS :)
Hmmm, go ahead, but it should remain somewhat compatible to the current
hotplug stuff...
Ciao,
Gerhard