Using udev to collect device information
I am working on a project that maintains a list of active hardware on a
machine and we want to make it hotplug "aware". Making udev call our
process for adding or removing an entry to or from our list each time hardware is added or removed seems easy enough, but I have several questions:
1. Our system will be thread safe, but if we are calling the hotplug updater each time a device is added or removed with the rules:
ACTION="add" RUN+="/usr/sbin/program"
and
ACTION="remove" RUN+="/usr/sbin/program"
Are we going to cause serious slow downs for the rest of the system if we are flooded with adds/removes? The program that we will be running won't be terribly slow but it will include some disk IO.
2. How can I pass information about the event, things like what device is being added/removed into the program being called? Does udev provide any of this information during rule execution (I assume that udev has it, I just need to know where to get it)?
Sorry if this is a gross abuse of udev, but we are looking to plug into a "hotplug" like system without requiring our users to install the linux-hotplug system so if there is a better way to accomplish the same thing please let me know.
Thanks for your help!
Signature · 12 lines
Eric Munson [email protected] 503.578.3104 T/L 775.3104 Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642 _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net [email protected] https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 6 lines · Eric Munson
I am working on a project that maintains a list of active hardware on a
machine and we want to make it hotplug "aware". Making udev call our
process for adding or removing an entry to or from our list each time hardware is added or removed seems easy enough, but I have several questions:
Quoted 8 lines
1. Our system will be thread safe, but if we are calling the hotplug updater each time a device is added or removed with the rules:
ACTION="add" RUN+="/usr/sbin/program"
and
ACTION="remove" RUN+="/usr/sbin/program"
Are we going to cause serious slow downs for the rest of the system if we are flooded with adds/removes? The program that we will be running won't be terribly slow but it will include some disk IO.
It all depends on what your /usr/sbin/program does, we can't answer that for you.
Quoted 9 lines
2. How can I pass information about the event, things like what device is being added/removed into the program being called? Does udev provide any of this information during rule execution (I assume that udev has it, I just need to know where to get it)?
Sorry if this is a gross abuse of udev, but we are looking to plug into a "hotplug" like system without requiring our users to install the linux-hotplug system so if there is a better way to accomplish the same thing please let me know.
No, this is a fine way. But why not just hook into HAL? It already does all of this for you, and you can get it to send you DBUS messages for any new device in the system.
Or, if you don't like how HAL works, you should at least look into how it ties into udev, as that sounds like the same exact way you want to do things. But don't reinvent the wheel if you don't have to.
thanks,
greg k-h
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 24 lines · Greg KH
Quoted 6 lines · Eric Munson
I am working on a project that maintains a list of active hardware on a
machine and we want to make it hotplug "aware". Making udev call our
process for adding or removing an entry to or from our list each time hardware is added or removed seems easy enough, but I have several questions:Quoted 8 lines
1. Our system will be thread safe, but if we are calling the hotplug updater each time a device is added or removed with the rules:
ACTION="add" RUN+="/usr/sbin/program"
and
ACTION="remove" RUN+="/usr/sbin/program"
Are we going to cause serious slow downs for the rest of the system if we are flooded with adds/removes? The program that we will be running won't be terribly slow but it will include some disk IO.It all depends on what your
/usr/sbin/programdoes, we can't answer that for you.Quoted 5 lines
2. How can I pass information about the event, things like what device is being added/removed into the program being called? Does udev provide any of this information during rule execution (I assume that udev has it, I just need to know where to get it)?
Quoted 8 lines
Quoted 4 lines
Sorry if this is a gross abuse of udev, but we are looking to plug into a "hotplug" like system without requiring our users to install the linux-hotplug system so if there is a better way to accomplish the same thing please let me know.
No, this is a fine way. But why not just hook into HAL? It already does all of this for you, and you can get it to send you DBUS messages for any new device in the system.
Right, HAL already keeps a nice list for most of the interesting things. It also tells you for a lot of devices what you can do with the device. You may want to look at it, if it matches your requirements. Just run "lshal" on a recent system.
Quoted 3 lines
Or, if you don't like how HAL works, you should at least look into how it ties into udev, as that sounds like the same exact way you want to do things. But don't reinvent the wheel if you don't have to.
HAL tells udev to pass the complete events to an abstract namespace socket (man 7 unix):
RUN+="socket:/org/freedesktop/hal/udev_event"
On the socket, you get a message like this: <action>@<devpath>\0[<key>=<value>\0, ...]
recv(3, "add@/class/input/input6/mouse2\0UDEV_LOG=3\0ACTIONd\0 DEVPATH=/class/input/input6/mouse2\0SUBSYSTEM=input\0 SEQNUM18\0PHYSDEVPATH=/devices/pci0000:00/0000:00:1d.1/usb2/2-2/2-2:1.0\0
Kay
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel