From: Stef Coene Date: Tue, 06 Apr 2004 22:57:06 +0000 Subject: Hotplug script questions Message-Id: <200404070057.06780.stef.coene@docum.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: linux-hotplug@vger.kernel.org Hi, I had a problem with the hotplug scripts (debian unstable). I wanted to=20 change the permissions of my usb camera so a non-root user can use the=20 device. I contacted the debian maintainer, but I realized my remarks can be the=20 interested of everybody. So, sorry if some of this is debian specific. I = also tried to search the archives for similar posts, but I couldn't find an= y. I started digging around in the hotplug scripts and I have the following=20 remakrs: - This is a documentation update. If you want to run a script when an usb = device is connected, you have to create a file in /etc/hotplug/usb with the= =20 extension username. The layout of that file is good documented, but the=20 first column has not to be a module name, but it can be the name of the=20 script. When there is a match and the first column is a script and the=20 script is found in /etc/hotplug/usb, the script is executed. As example: /proc/bus/usb/devices P: Vendor 96 ProdIDA02 Rev=3D 1.00 /etc/hotplug/usb/medion.usermap medion.sh 0x000 0x0d96 0x4102 0x01000x00 00 0x0000 0x00 0x00 0x00 0x00 0= x00=20 0x00 /etc/hotplug/usb/medion.sh chmod 777 $DEVICE - For the above, there is one problem. If you connect the device after the= =20 system is booted, the DEVICE variable is known and can be used to change th= e=20 for instance the ownership of the device so non-root users can use the devi= ce=20 (see previous example). But if the device is connected at boot time, the=20 device onder /proc is not know, only the device name onder /sys. I tried t= o=20 create a script that can match the /proc device name with the information=20 found under /sys, but I didn't succeed (actually, I didn't tried very hard). If /sys/bus does not exists, all devices in /proc are processed in usb.rc a= nd=20 the problem does not exists. - In usb.agent on line 445, "MODPROBE=3D:" I can understand that this is done because usb devices never requires to lo= ad=20 a module (is this really so, what about usb nics's ?, I dont' have any). S= o,=20 after processing the usb devices, MODPROBE points not to the modprobe=20 executable and no module loading is possible. That's fine, because the usb= =20 devices are processed last by the init script, so pci and the other scripts= =20 can use MODPROBE. But what if I create a xyz.rc file in /etc/hotplug for=20 some custom made devices? It will be processed after the usb stuff so=20 MODPROBE can not be used. I think it's best to just remove the MODPROBE=3D: line. It's not a problem= when=20 the script tries to load the usb driver as a module. I also have some questions about the load_drivers function in=20 hotplug.functions: - variable LOADED: why ??? As far as I understand, this is not needed. I = think it's better if checking the driver can be done like this (this also=20 removes the needed of the LOADED variable): Procedure to load a driver: if driver=3Dblacklisted then do nothing if driver is alread loaded then do nothing if driver is module and can be loaded: ok if driver is also a script: execute script (This can be needed if = you=20 load a module and a script with the same name as the module exists, can be = handy to change permissions). Maybe it's needed that this is also neede fo= r=20 the previous situation: You connect a device, module is loaded, script is=20 executed, you disconnect the device, module is NOT unloaded, you reconnect = the device, script needs to be executed again, but the module is already=20 loaded. elsif driver is script: execute script else print error - In each step, a nice printout on the console is needed, also when a scrip= t=20 is executed. A better form would be: : Example output: Starting hotplug subsystem: input net pci ignore pci display device on 00:02.0 ignore pci display device on 00:02.1 bcm5700: already loaded yenta_socket: already loaded orinoco_pci: blacklisted, not loaded usb medion.sh: script executed done I can post some patches, but first I want to discuss my changes. Stef --=20 stef.coene@docum.org =A0"Using Linux as bandwidth manager" =A0 =A0 =A0http://www.docum.org/ ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id638&op=CCk _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel