linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Hotplug script questions
@ 2004-04-06 22:57 Stef Coene
  0 siblings, 0 replies; only message in thread
From: Stef Coene @ 2004-04-06 22:57 UTC (permalink / raw)
  To: linux-hotplug

Hi,

I had a problem with the hotplug scripts (debian unstable).  I wanted to 
change the permissions of my usb camera so a non-root user can use the 
device.
I contacted the debian maintainer, but I realized my remarks can be the 
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 any.

I started digging around in the hotplug scripts and I have the following 
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 
extension username.  The layout of that file is good documented, but the 
first column has not to be a module name, but it can be the name of the 
script.  When there is a match and the first column is a script and the 
script is found in /etc/hotplug/usb, the script is executed.

As example:
/proc/bus/usb/devices
  P:  Vendor
96 ProdIDA02 Rev= 1.00
/etc/hotplug/usb/medion.usermap
   medion.sh 0x000 0x0d96 0x4102 0x01000x00 00 0x0000 0x00 0x00 0x00 0x00 0x00 
0x00
/etc/hotplug/usb/medion.sh
  chmod 777 $DEVICE

- For the above, there is one problem.  If you connect the device after the 
system is booted, the DEVICE variable is known and can be used to change the 
for instance the ownership of the device so non-root users can use the device 
(see previous example).  But if the device is connected at boot time, the 
device onder /proc is not know, only the device name onder /sys.  I tried to 
create a script that can match the /proc device name with the information 
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 and 
the problem does not exists.

- In usb.agent on line 445, "MODPROBE=:"
I can understand that this is done because usb devices never requires to load 
a module (is this really so, what about usb nics's ?, I dont' have any).  So, 
after processing the usb devices, MODPROBE points not to the modprobe 
executable and no module loading is possible.  That's fine, because the usb 
devices are processed last by the init script, so pci and the other scripts 
can use MODPROBE.  But what if I create a xyz.rc file in /etc/hotplug for 
some custom made devices?  It will be processed after the usb stuff so 
MODPROBE can not be used.
I think it's best to just remove the MODPROBE=: line.  It's not a problem when 
the script tries to load the usb driver as a module.

I also have some questions about the load_drivers function in 
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 
removes the needed of the LOADED variable):

   Procedure to load a driver:
      if driver=blacklisted 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 
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 for 
the previous situation: You connect a device, module is loaded, script is 
executed, you disconnect the device, module is NOT unloaded, you reconnect 
the device, script needs to be executed again, but the module is already 
loaded.
      elsif driver is script: execute script
      else print error

- In each step, a nice printout on the console is needed, also when a script 
is executed.  A better form would be:
<module name>: <message>

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

-- 
stef.coene@docum.org
 "Using Linux as bandwidth manager"
     http://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\x1470&alloc_id638&opÌk
_______________________________________________
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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-04-06 22:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-06 22:57 Hotplug script questions Stef Coene

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).