[systemd-devel] udev event on usb unpluged
christophe.jalady at free.fr
christophe.jalady at free.fr
Wed Aug 26 00:35:44 PDT 2015
>> I am not sure about what you mean here. Do you mean that you can't see
> any remove event with `udevadm monitor` when you unplug the "cable"?
yes, my script never receive the "remove" event (_but_ receive the "add" event).
>> Also do you really mean a "usb cable" without any device connected to
> it on the other end?
No, the cable is connected to another device. So I want the "remove" event when the cable is unplugged from one of the device (my device or the other one).
> Unless you have a very specific to match with, I wonder if it's a good
> idea to unload the module by a remove event,
> ...what if there are two "cables"/devices using the module?
Well, my setup is really specific (small robotic device), so it safe to consider only one cable connected.
>Also it seems to be g_mass_storage is just the module for setting up
>dummy or emulating an mass storage device. Why would you want it to
>depend on a usb "cable"/device?
This is the bigger picture:
My device is a small robotic device. To send a file on it, I that users just copy files like they do with mass-storage usb-key.
So: On usb-plugged: I load the module k_mass_storage: the other device see a new mass-storage device appearing, copy files and then umount/unplugged the cable.
When the cable is unplugged, I want to trigger an action on my device (processing the files copied).
Christophe
----- Mail original -----
De: "Tom Yan" <tom.ty89 at gmail.com>
À: "christophe jalady" <christophe.jalady at free.fr>
Cc: "systemd" <systemd-devel at lists.freedesktop.org>
Envoyé: Mercredi 26 Août 2015 04:37:40
Objet: Re: [systemd-devel] udev event on usb unpluged
Also it seems to be g_mass_storage is just the module for setting up
dummy or emulating an mass storage device. Why would you want it to
depend on a usb "cable"/device?
On 26 August 2015 at 11:21, Tom Yan <tom.ty89 at gmail.com> wrote:
> I am not sure about what you mean here. Do you mean that you can't see
> any remove event with `udevadm monitor` when you unplug the "cable"?
> Also do you really mean a "usb cable" without any device connected to
> it on the other end?
>
> By the way the rule you set up is so broad that the script will
> basically be run on every boot or udevadm trigger.
>
> Unless you have a very specific to match with, I wonder if it's a good
> idea to unload the module by a remove event, because, for example,
> what if there are two "cables"/devices using the module?
>
> On 26 August 2015 at 04:17, <christophe.jalady at free.fr> wrote:
>> Hi,
>>
>> I would like to receive an event (actually run a script) when I plug/unplugged an usb cable.
>> I tried to use udev with this simple rule:
>> SUBSYSTEM=="usb",RUN+="/var/local/usb-changed.sh"
>>
>> I do receive the "add" event when I plug the usb cable: just perfect !
>>
>> But I never receive the "remove" event.
>> Any idea why ?
>>
>> More information:
>> I use linux kernel v3.16.
>> When the cable is plugged, I load the kernel module "g_mass_storage", this work great. My need is to unload the module when the usb cable is unplugged (note it would be even better if I receive an event when the mass-storage is unmounted by the other host, but I do not have any idea where to look for.)
>>
>> Thanks by advance for any hint.
>>
>> Christophe
>> _______________________________________________
>> systemd-devel mailing list
>> systemd-devel at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/systemd-devel
More information about the systemd-devel
mailing list