Re: [systemd-devel] udev event on usb unpluged

2015-08-31 Thread christophe . jalady
>By the way, Milasan asked you to use -u and -p for udevadm monitor.

See attached the logs with -u and -p parameters (seem's that it's less than 
without).

Christophe

- Mail original -
De: "Tom Yan" <tom.t...@gmail.com>
À: "christophe jalady" <christophe.jal...@free.fr>
Cc: "Robert Milasan" <rmila...@suse.com>, "systemd" 
<systemd-devel@lists.freedesktop.org>
Envoyé: Samedi 29 Août 2015 19:54:20
Objet: Re: [systemd-devel] udev event on usb unpluged

Are you sure that the add events in jc.log actually appears before you
plugin anything? I think "usb1" is the host controller/bus and
"usb1/1-0:1.0" is the internal hub. If it's that case of course you
won't see any remove event of them by unpluging your device because
the add events doesn't belong to the device as well.

In that case, perhaps for some reason your device isn't under the usb
subsystem, so the rule is a mismatch for it.

As for the `udevadm monitor` log, I don't know how/when exactly your
"init.d" script is ran, but actually you don't have to do it that way.
You can just boot up, start capturing udevadm monitor output, then
restart systemd-udev-trigger.serivce (or `/usr/bin/udevadm trigger
--type=subsystems --action=add ; /usr/bin/udevadm trigger
--type=devices --action=add` if you aren't running systemd, that's
what the service run), then stop capturing, and you'll basically see
what happened when it boot.

By the way, Milasan asked you to use -u and -p for udevadm monitor.

On 29 August 2015 at 23:30,  <christophe.jal...@free.fr> wrote:
> sorry for the delay.
> Attached are the logs.
>
> The log show the hole process meaning:
>Boot
>Plug of the usb cable: the device is shown as a "mass-storage" on the 
> other device.
>Other device umount. I unplug the cable.
>Shutdown of the device.
>
> 'jc.log' is the log from my script. You will see 2 "add" event, but no 
> "remove" event.
> 'udev.log' if the log from "udevadm monitor > /var/log/udev.log 2>&1" since 
> boot time (I launch it from an init.d script at startup).
>
>
> 1) Why I see event in my jc.log but not in udev.log ??
> 2) Why is there no "usb" event in udev.log (nor add/change or remove ...) ?
>
>
> For completeness, I attach also my .rule and .sh scripts.
>
> Thanks for your help.
>
> Christophe
>
>
>
>
> - Mail original -
> De: "Robert Milasan" <rmila...@suse.com>
> À: "christophe jalady" <christophe.jal...@free.fr>
> Cc: systemd-devel@lists.freedesktop.org
> Envoyé: Mercredi 26 Août 2015 14:35:24
> Objet: Re: [systemd-devel] udev event on usb unpluged
>
> On Wed, 26 Aug 2015 15:32:13 +0200 (CEST)
> <christophe.jal...@free.fr> wrote:
>
>> >They are not referring to your device, but the machine on which you
>> >are
>> running the rule.
>> >In a terminal/console you run: udevadm monitor
>> >The do the removal itself and see what 'udevadm monitor' says.
>>
>> this is the problem: the machine which are running the rule is a
>> "specific robotic device" with one usb port and no screen (and no
>> network device). Either I connect through ssh using the usb cable
>> (eth over usb) or I use the usb cable to test my plug/unplug process.
>> I cannot have a console _and_ test the unplugging at the same time.
>
> Then login into that machine and run screen, in which you run:
> 'udevadm monitor -u -p > /tmp/udev.log 2>&1'
>
> Do the necessary removal of the usb cable or whatever, then attach
> the usb cable again, login again and check the log.
>
>>
>> Christophe
>>
>
>
> --
> Robert Milasan
>
> L3 Support Engineer
> SUSE Linux (http://www.suse.com)
> email: rmila...@suse.com
> GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
>
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel
>monitor will print the received events for:
UDEV - the event which udev sends out after rule processing

UDEV  [73.327514] change   /devices/platform/leds_pwm/leds/ev3-left1:green:ev3dev (leds)
ACTION=change
DEVPATH=/devices/platform/leds_pwm/leds/ev3-left1:green:ev3dev
ID_PATH=platform-leds_pwm
ID_PATH_TAG=platform-leds_pwm
SEQNUM=991
SUBSYSTEM=leds
TRIGGER=default-on
USEC_INITIALIZED=3862

UDEV  [73.379486] change   /devices/platform/leds_pwm/leds/ev3-right1:green:ev3dev (leds)
ACTION=change
DEVPATH=/devices/platform/leds_pwm/leds/ev3-right1:green:ev3dev
ID_PATH=platform-leds_pwm
ID_PATH_TAG=platform-leds_pwm
SEQNUM=992
SUBSYSTEM=leds
TRIGGER=def

Re: [systemd-devel] udev event on usb unpluged

2015-08-31 Thread christophe . jalady
>I do not think you can get a useful event from udev for filesystem
unmounting. 

ok fine.


>But you should be able to get events for device removal 

Could someone provide the simplest .rule to catch such event ??

Christophe


- Mail original -
De: "Tom Yan" <tom.t...@gmail.com>
À: "christophe jalady" <christophe.jal...@free.fr>
Cc: "Robert Milasan" <rmila...@suse.com>, "systemd" 
<systemd-devel@lists.freedesktop.org>
Envoyé: Dimanche 30 Août 2015 05:13:08
Objet: Re: [systemd-devel] udev event on usb unpluged

First of all I meant "Are you sure that the add events in jc.log
actually appears AFTER you plugin anything?". If it appears BEFORE the
device is plugged, then the two events are just of the bus/hub.

I do not think you can get a useful event from udev for filesystem
unmounting. That's simply not what udev is about. But you should be
able to get events for device removal (even "devices" created by
dummy_hcd/g_mass_storage, btw I think it's better to use `modprobe -r`
than `rmmod`, just like `modprobe` vs `insmod`)

On 30 August 2015 at 03:43,  <christophe.jal...@free.fr> wrote:
>>re you sure that the add events in jc.log actually appears before you
>>plugin anything? I think "usb1" is the host controller/bus and
>>"usb1/1-0:1.0" is the internal hub. If it's that case of course you
>>won't see any remove event of them by unpluging your device because
>>the add events doesn't belong to the device as well.
>>In that case, perhaps for some reason your device isn't under the usb
>>subsystem, so the rule is a mismatch for it.
>
> I'll check that but you are right: it could explain the behavior.
>
> But then, back to my first question:
> Is it possible to get an event from udev (or whatever) alerting that:  either 
> the g_mass_storage is unmounted by the other host _or_ that an usb cable is 
> unplugged.
>
>
> I'll check for the rest of your answer. (thanks by the way!)
>
> Christophe
>
>
>
> - Mail original -
> De: "Tom Yan" <tom.t...@gmail.com>
> À: "christophe jalady" <christophe.jal...@free.fr>
> Cc: "Robert Milasan" <rmila...@suse.com>, "systemd" 
> <systemd-devel@lists.freedesktop.org>
> Envoyé: Samedi 29 Août 2015 19:54:20
> Objet: Re: [systemd-devel] udev event on usb unpluged
>
> Are you sure that the add events in jc.log actually appears before you
> plugin anything? I think "usb1" is the host controller/bus and
> "usb1/1-0:1.0" is the internal hub. If it's that case of course you
> won't see any remove event of them by unpluging your device because
> the add events doesn't belong to the device as well.
>
> In that case, perhaps for some reason your device isn't under the usb
> subsystem, so the rule is a mismatch for it.
>
> As for the `udevadm monitor` log, I don't know how/when exactly your
> "init.d" script is ran, but actually you don't have to do it that way.
> You can just boot up, start capturing udevadm monitor output, then
> restart systemd-udev-trigger.serivce (or `/usr/bin/udevadm trigger
> --type=subsystems --action=add ; /usr/bin/udevadm trigger
> --type=devices --action=add` if you aren't running systemd, that's
> what the service run), then stop capturing, and you'll basically see
> what happened when it boot.
>
> By the way, Milasan asked you to use -u and -p for udevadm monitor.
>
> On 29 August 2015 at 23:30,  <christophe.jal...@free.fr> wrote:
>> sorry for the delay.
>> Attached are the logs.
>>
>> The log show the hole process meaning:
>>Boot
>>Plug of the usb cable: the device is shown as a "mass-storage" on the 
>> other device.
>>Other device umount. I unplug the cable.
>>Shutdown of the device.
>>
>> 'jc.log' is the log from my script. You will see 2 "add" event, but no 
>> "remove" event.
>> 'udev.log' if the log from "udevadm monitor > /var/log/udev.log 2>&1" since 
>> boot time (I launch it from an init.d script at startup).
>>
>>
>> 1) Why I see event in my jc.log but not in udev.log ??
>> 2) Why is there no "usb" event in udev.log (nor add/change or remove ...) ?
>>
>>
>> For completeness, I attach also my .rule and .sh scripts.
>>
>> Thanks for your help.
>>
>> Christophe
>>
>>
>>
>>
>> - Mail original -
>> De: "Robert Milasan" <rmila...@suse.com>
>> À: "christophe jalady" <christophe.jal...@free.fr>
>> Cc: systemd-devel@lists.freedesktop.org
>> 

Re: [systemd-devel] udev event on usb unpluged

2015-08-29 Thread christophe . jalady
sorry for the delay.
Attached are the logs.

The log show the hole process meaning:
   Boot
   Plug of the usb cable: the device is shown as a mass-storage on the other 
device.
   Other device umount. I unplug the cable.
   Shutdown of the device.

'jc.log' is the log from my script. You will see 2 add event, but no remove 
event.
'udev.log' if the log from udevadm monitor  /var/log/udev.log 21 since 
boot time (I launch it from an init.d script at startup).


1) Why I see event in my jc.log but not in udev.log ??
2) Why is there no usb event in udev.log (nor add/change or remove ...) ?


For completeness, I attach also my .rule and .sh scripts.

Thanks for your help.

Christophe 




- Mail original -
De: Robert Milasan rmila...@suse.com
À: christophe jalady christophe.jal...@free.fr
Cc: systemd-devel@lists.freedesktop.org
Envoyé: Mercredi 26 Août 2015 14:35:24
Objet: Re: [systemd-devel] udev event on usb unpluged

On Wed, 26 Aug 2015 15:32:13 +0200 (CEST)
christophe.jal...@free.fr wrote:

 They are not referring to your device, but the machine on which you
 are
 running the rule.
 In a terminal/console you run: udevadm monitor
 The do the removal itself and see what 'udevadm monitor' says.
 
 this is the problem: the machine which are running the rule is a
 specific robotic device with one usb port and no screen (and no
 network device). Either I connect through ssh using the usb cable
 (eth over usb) or I use the usb cable to test my plug/unplug process.
 I cannot have a console _and_ test the unplugging at the same time.

Then login into that machine and run screen, in which you run:
'udevadm monitor -u -p  /tmp/udev.log 21'

Do the necessary removal of the usb cable or whatever, then attach
the usb cable again, login again and check the log.

 
 Christophe
 


-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A


usb-changed.sh
Description: application/shellscript


95-usb.rules
Description: Binary data
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent

KERNEL[76.710918] change   /devices/platform/leds_pwm/leds/ev3-left1:green:ev3dev (leds)
KERNEL[76.753187] change   /devices/platform/leds_pwm/leds/ev3-right1:green:ev3dev (leds)
KERNEL[76.783563] change   /devices/platform/leds_pwm/leds/ev3-left0:red:ev3dev (leds)
KERNEL[76.814720] change   /devices/platform/leds_pwm/leds/ev3-left0:red:ev3dev (leds)
KERNEL[76.859972] change   /devices/platform/leds_pwm/leds/ev3-right0:red:ev3dev (leds)
KERNEL[76.904334] change   /devices/platform/leds_pwm/leds/ev3-right0:red:ev3dev (leds)
UDEV  [78.253965] change   /devices/platform/leds_pwm/leds/ev3-left1:green:ev3dev (leds)
UDEV  [78.309536] change   /devices/platform/leds_pwm/leds/ev3-right1:green:ev3dev (leds)
UDEV  [78.368676] change   /devices/platform/leds_pwm/leds/ev3-left0:red:ev3dev (leds)
UDEV  [78.447464] change   /devices/platform/leds_pwm/leds/ev3-right0:red:ev3dev (leds)
UDEV  [79.350682] change   /devices/platform/leds_pwm/leds/ev3-left0:red:ev3dev (leds)
UDEV  [79.408343] change   /devices/platform/leds_pwm/leds/ev3-right0:red:ev3dev (leds)
KERNEL[291.356497] change   /devices/platform/leds_pwm/leds/ev3-left1:green:ev3dev (leds)
KERNEL[291.382591] change   /devices/platform/leds_pwm/leds/ev3-left1:green:ev3dev (leds)
KERNEL[291.406296] change   /devices/platform/leds_pwm/leds/ev3-right1:green:ev3dev (leds)
KERNEL[291.441321] change   /devices/platform/leds_pwm/leds/ev3-right1:green:ev3dev (leds)
KERNEL[291.475845] change   /devices/platform/leds_pwm/leds/ev3-left0:red:ev3dev (leds)
KERNEL[291.708675] change   /devices/platform/leds_pwm/leds/ev3-right0:red:ev3dev (leds)
UDEV  [293.290931] change   /devices/platform/leds_pwm/leds/ev3-left1:green:ev3dev (leds)
UDEV  [293.442428] change   /devices/platform/leds_pwm/leds/ev3-right1:green:ev3dev (leds)
UDEV  [293.661357] change   /devices/platform/leds_pwm/leds/ev3-left0:red:ev3dev (leds)
UDEV  [293.739961] change   /devices/platform/leds_pwm/leds/ev3-right0:red:ev3dev (leds)
UDEV  [295.962372] change   /devices/platform/leds_pwm/leds/ev3-left1:green:ev3dev (leds)
UDEV  [296.208847] change   /devices/platform/leds_pwm/leds/ev3-right1:green:ev3dev (leds)
add /devices/platform/ohci.0/usb1
add /devices/platform/ohci.0/usb1/1-0:1.0
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udev event on usb unpluged

2015-08-29 Thread Tom Yan
Are you sure that the add events in jc.log actually appears before you
plugin anything? I think usb1 is the host controller/bus and
usb1/1-0:1.0 is the internal hub. If it's that case of course you
won't see any remove event of them by unpluging your device because
the add events doesn't belong to the device as well.

In that case, perhaps for some reason your device isn't under the usb
subsystem, so the rule is a mismatch for it.

As for the `udevadm monitor` log, I don't know how/when exactly your
init.d script is ran, but actually you don't have to do it that way.
You can just boot up, start capturing udevadm monitor output, then
restart systemd-udev-trigger.serivce (or `/usr/bin/udevadm trigger
--type=subsystems --action=add ; /usr/bin/udevadm trigger
--type=devices --action=add` if you aren't running systemd, that's
what the service run), then stop capturing, and you'll basically see
what happened when it boot.

By the way, Milasan asked you to use -u and -p for udevadm monitor.

On 29 August 2015 at 23:30,  christophe.jal...@free.fr wrote:
 sorry for the delay.
 Attached are the logs.

 The log show the hole process meaning:
Boot
Plug of the usb cable: the device is shown as a mass-storage on the 
 other device.
Other device umount. I unplug the cable.
Shutdown of the device.

 'jc.log' is the log from my script. You will see 2 add event, but no 
 remove event.
 'udev.log' if the log from udevadm monitor  /var/log/udev.log 21 since 
 boot time (I launch it from an init.d script at startup).


 1) Why I see event in my jc.log but not in udev.log ??
 2) Why is there no usb event in udev.log (nor add/change or remove ...) ?


 For completeness, I attach also my .rule and .sh scripts.

 Thanks for your help.

 Christophe




 - Mail original -
 De: Robert Milasan rmila...@suse.com
 À: christophe jalady christophe.jal...@free.fr
 Cc: systemd-devel@lists.freedesktop.org
 Envoyé: Mercredi 26 Août 2015 14:35:24
 Objet: Re: [systemd-devel] udev event on usb unpluged

 On Wed, 26 Aug 2015 15:32:13 +0200 (CEST)
 christophe.jal...@free.fr wrote:

 They are not referring to your device, but the machine on which you
 are
 running the rule.
 In a terminal/console you run: udevadm monitor
 The do the removal itself and see what 'udevadm monitor' says.

 this is the problem: the machine which are running the rule is a
 specific robotic device with one usb port and no screen (and no
 network device). Either I connect through ssh using the usb cable
 (eth over usb) or I use the usb cable to test my plug/unplug process.
 I cannot have a console _and_ test the unplugging at the same time.

 Then login into that machine and run screen, in which you run:
 'udevadm monitor -u -p  /tmp/udev.log 21'

 Do the necessary removal of the usb cable or whatever, then attach
 the usb cable again, login again and check the log.


 Christophe



 --
 Robert Milasan

 L3 Support Engineer
 SUSE Linux (http://www.suse.com)
 email: rmila...@suse.com
 GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A

 ___
 systemd-devel mailing list
 systemd-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/systemd-devel

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udev event on usb unpluged

2015-08-29 Thread christophe . jalady
re you sure that the add events in jc.log actually appears before you
plugin anything? I think usb1 is the host controller/bus and
usb1/1-0:1.0 is the internal hub. If it's that case of course you
won't see any remove event of them by unpluging your device because
the add events doesn't belong to the device as well.
In that case, perhaps for some reason your device isn't under the usb
subsystem, so the rule is a mismatch for it.

I'll check that but you are right: it could explain the behavior.

But then, back to my first question:
Is it possible to get an event from udev (or whatever) alerting that:  either 
the g_mass_storage is unmounted by the other host _or_ that an usb cable is 
unplugged.


I'll check for the rest of your answer. (thanks by the way!)

Christophe



- Mail original -
De: Tom Yan tom.t...@gmail.com
À: christophe jalady christophe.jal...@free.fr
Cc: Robert Milasan rmila...@suse.com, systemd 
systemd-devel@lists.freedesktop.org
Envoyé: Samedi 29 Août 2015 19:54:20
Objet: Re: [systemd-devel] udev event on usb unpluged

Are you sure that the add events in jc.log actually appears before you
plugin anything? I think usb1 is the host controller/bus and
usb1/1-0:1.0 is the internal hub. If it's that case of course you
won't see any remove event of them by unpluging your device because
the add events doesn't belong to the device as well.

In that case, perhaps for some reason your device isn't under the usb
subsystem, so the rule is a mismatch for it.

As for the `udevadm monitor` log, I don't know how/when exactly your
init.d script is ran, but actually you don't have to do it that way.
You can just boot up, start capturing udevadm monitor output, then
restart systemd-udev-trigger.serivce (or `/usr/bin/udevadm trigger
--type=subsystems --action=add ; /usr/bin/udevadm trigger
--type=devices --action=add` if you aren't running systemd, that's
what the service run), then stop capturing, and you'll basically see
what happened when it boot.

By the way, Milasan asked you to use -u and -p for udevadm monitor.

On 29 August 2015 at 23:30,  christophe.jal...@free.fr wrote:
 sorry for the delay.
 Attached are the logs.

 The log show the hole process meaning:
Boot
Plug of the usb cable: the device is shown as a mass-storage on the 
 other device.
Other device umount. I unplug the cable.
Shutdown of the device.

 'jc.log' is the log from my script. You will see 2 add event, but no 
 remove event.
 'udev.log' if the log from udevadm monitor  /var/log/udev.log 21 since 
 boot time (I launch it from an init.d script at startup).


 1) Why I see event in my jc.log but not in udev.log ??
 2) Why is there no usb event in udev.log (nor add/change or remove ...) ?


 For completeness, I attach also my .rule and .sh scripts.

 Thanks for your help.

 Christophe




 - Mail original -
 De: Robert Milasan rmila...@suse.com
 À: christophe jalady christophe.jal...@free.fr
 Cc: systemd-devel@lists.freedesktop.org
 Envoyé: Mercredi 26 Août 2015 14:35:24
 Objet: Re: [systemd-devel] udev event on usb unpluged

 On Wed, 26 Aug 2015 15:32:13 +0200 (CEST)
 christophe.jal...@free.fr wrote:

 They are not referring to your device, but the machine on which you
 are
 running the rule.
 In a terminal/console you run: udevadm monitor
 The do the removal itself and see what 'udevadm monitor' says.

 this is the problem: the machine which are running the rule is a
 specific robotic device with one usb port and no screen (and no
 network device). Either I connect through ssh using the usb cable
 (eth over usb) or I use the usb cable to test my plug/unplug process.
 I cannot have a console _and_ test the unplugging at the same time.

 Then login into that machine and run screen, in which you run:
 'udevadm monitor -u -p  /tmp/udev.log 21'

 Do the necessary removal of the usb cable or whatever, then attach
 the usb cable again, login again and check the log.


 Christophe



 --
 Robert Milasan

 L3 Support Engineer
 SUSE Linux (http://www.suse.com)
 email: rmila...@suse.com
 GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A

 ___
 systemd-devel mailing list
 systemd-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/systemd-devel

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udev event on usb unpluged

2015-08-26 Thread christophe . jalady
 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.t...@gmail.com
À: christophe jalady christophe.jal...@free.fr
Cc: systemd systemd-devel@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.t...@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.jal...@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@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/systemd-devel
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udev event on usb unpluged

2015-08-26 Thread Tom Yan
Can you paste run `udevadm monitor`, plug in your cable/device, wait
for a second, unplug it, and paste the output? Or can you show how you
confirmed your script receive the add event, or how the script
catch the event?

On 26 August 2015 at 15:35,  christophe.jal...@free.fr 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?

 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.t...@gmail.com
 À: christophe jalady christophe.jal...@free.fr
 Cc: systemd systemd-devel@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.t...@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.jal...@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@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/systemd-devel
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udev event on usb unpluged

2015-08-26 Thread Robert Milasan
On Wed, 26 Aug 2015 14:43:35 +0200 (CEST)
christophe.jal...@free.fr wrote:

 can you show how you confirmed your script receive the add event,
 or how the script catch the event?
 
 Sure: basically I do echo USB_$ACTION  /tmp/jc.log.
 After plug/wait/unplugged/wait I only see lines USB_add.
 See attached my .rules and .sh scripts.
 
 
 Can you paste run `udevadm monitor`, plug in your cable/device, wait
 for a second, unplug it, and paste the output?
 
 Well, this is the trick: I cannot add a connection to my device _and_
 the usb cable connected to it. So I am not able to monitor the
 process directly from my device. Does the scripts provided are enough
 to help you understanding my problem ?
 
 Christophe

They are not referring to your device, but the machine on which you are
running the rule.

In a terminal/console you run: udevadm monitor

The do the removal itself and see what 'udevadm monitor' says.


-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udev event on usb unpluged

2015-08-26 Thread christophe . jalady
can you show how you confirmed your script receive the add event, or how the 
script
catch the event?

Sure: basically I do echo USB_$ACTION  /tmp/jc.log.
After plug/wait/unplugged/wait I only see lines USB_add.
See attached my .rules and .sh scripts.


Can you paste run `udevadm monitor`, plug in your cable/device, wait
for a second, unplug it, and paste the output?

Well, this is the trick: I cannot add a connection to my device _and_ the usb 
cable connected to it.
So I am not able to monitor the process directly from my device.
Does the scripts provided are enough to help you understanding my problem ?

Christophe

- Mail original -
De: Tom Yan tom.t...@gmail.com
À: christophe jalady christophe.jal...@free.fr
Cc: systemd systemd-devel@lists.freedesktop.org
Envoyé: Mercredi 26 Août 2015 08:57:12
Objet: Re: [systemd-devel] udev event on usb unpluged

Can you paste run `udevadm monitor`, plug in your cable/device, wait
for a second, unplug it, and paste the output? Or can you show how you
confirmed your script receive the add event, or how the script
catch the event?

On 26 August 2015 at 15:35,  christophe.jal...@free.fr 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?

 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.t...@gmail.com
 À: christophe jalady christophe.jal...@free.fr
 Cc: systemd systemd-devel@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.t...@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.jal...@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@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/systemd-devel

95-usb.rules
Description: Binary data


usb-changed.sh
Description: application/shellscript
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udev event on usb unpluged

2015-08-26 Thread christophe . jalady
They are not referring to your device, but the machine on which you are
running the rule.
In a terminal/console you run: udevadm monitor
The do the removal itself and see what 'udevadm monitor' says.

this is the problem: the machine which are running the rule is a specific 
robotic device with one usb port and no screen (and no network device).
Either I connect through ssh using the usb cable (eth over usb) or I use the 
usb cable to test my plug/unplug process.
I cannot have a console _and_ test the unplugging at the same time.

Christophe



- Mail original -
De: Robert Milasan rmila...@suse.com
À: systemd-devel@lists.freedesktop.org
Envoyé: Mercredi 26 Août 2015 13:49:44
Objet: Re: [systemd-devel] udev event on usb unpluged

On Wed, 26 Aug 2015 14:43:35 +0200 (CEST)
christophe.jal...@free.fr wrote:

 can you show how you confirmed your script receive the add event,
 or how the script catch the event?
 
 Sure: basically I do echo USB_$ACTION  /tmp/jc.log.
 After plug/wait/unplugged/wait I only see lines USB_add.
 See attached my .rules and .sh scripts.
 
 
 Can you paste run `udevadm monitor`, plug in your cable/device, wait
 for a second, unplug it, and paste the output?
 
 Well, this is the trick: I cannot add a connection to my device _and_
 the usb cable connected to it. So I am not able to monitor the
 process directly from my device. Does the scripts provided are enough
 to help you understanding my problem ?
 
 Christophe

They are not referring to your device, but the machine on which you are
running the rule.

In a terminal/console you run: udevadm monitor

The do the removal itself and see what 'udevadm monitor' says.


-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udev event on usb unpluged

2015-08-26 Thread Robert Milasan
On Wed, 26 Aug 2015 15:32:13 +0200 (CEST)
christophe.jal...@free.fr wrote:

 They are not referring to your device, but the machine on which you
 are
 running the rule.
 In a terminal/console you run: udevadm monitor
 The do the removal itself and see what 'udevadm monitor' says.
 
 this is the problem: the machine which are running the rule is a
 specific robotic device with one usb port and no screen (and no
 network device). Either I connect through ssh using the usb cable
 (eth over usb) or I use the usb cable to test my plug/unplug process.
 I cannot have a console _and_ test the unplugging at the same time.

Then login into that machine and run screen, in which you run:
'udevadm monitor -u -p  /tmp/udev.log 21'

Do the necessary removal of the usb cable or whatever, then attach
the usb cable again, login again and check the log.

 
 Christophe
 


-- 
Robert Milasan

L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmila...@suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udev event on usb unpluged

2015-08-26 Thread Tom Yan
Maybe there's indeed some problem with your kernel or device. I tried
the following rule on my machine:
/etc/udev/rules.d/usb.rules:SUBSYSTEM==usb, RUN+=/usr/bin/bash -c
'echo $ACTION $DEVPATH  /home/tom/test

And here's the test log after I reboot and plug/unplug a usb thumb
drive (2-4):
add /devices/pci:00/:00:1a.0/usb3
add /devices/pci:00/:00:14.0/usb2
add /devices/pci:00/:00:1d.0/usb4
add /devices/pci:00/:00:14.0/usb1
add /devices/pci:00/:00:1d.0/usb4/4-0:1.0
add /devices/pci:00/:00:1a.0/usb3/3-0:1.0
add /devices/pci:00/:00:14.0/usb2/2-0:1.0
add /devices/pci:00/:00:14.0/usb1/1-0:1.0
add /devices/pci:00/:00:14.0/usb2/2-1
add /devices/pci:00/:00:14.0/usb2/2-1/2-1:1.0
add /devices/pci:00/:00:14.0/usb2/2-2
add /devices/pci:00/:00:14.0/usb2/2-2/2-2:1.0
add /devices/pci:00/:00:1a.0/usb3/3-1
add /devices/pci:00/:00:1a.0/usb3/3-1/3-1:1.0
add /devices/pci:00/:00:1d.0/usb4/4-1
add /devices/pci:00/:00:1d.0/usb4/4-1/4-1:1.0
add /devices/pci:00/:00:14.0/usb1/1-13
add /devices/pci:00/:00:14.0/usb1/1-13/1-13:1.0
add /devices/pci:00/:00:14.0/usb1/1-13/1-13:1.1
add /devices/pci:00/:00:14.0/usb1/1-13/1-13:1.2
add /devices/pci:00/:00:14.0/usb1/1-14
add /devices/pci:00/:00:14.0/usb1/1-14/1-14:1.0
add /devices/pci:00/:00:14.0/usb1/1-14/1-14:1.1
add /devices/pci:00/:00:14.0/usb2/2-4
add /devices/pci:00/:00:14.0/usb2/2-4/2-4:1.0
remove /devices/pci:00/:00:14.0/usb2/2-4/2-4:1.0
remove /devices/pci:00/:00:14.0/usb2/2-4

Perhaps you can check the devpath and see if it's actually gone with
`ls` after you unplug the cable/device?

On 26 August 2015 at 21:35, Robert Milasan rmila...@suse.com wrote:
 On Wed, 26 Aug 2015 15:32:13 +0200 (CEST)
 christophe.jal...@free.fr wrote:

 They are not referring to your device, but the machine on which you
 are
 running the rule.
 In a terminal/console you run: udevadm monitor
 The do the removal itself and see what 'udevadm monitor' says.

 this is the problem: the machine which are running the rule is a
 specific robotic device with one usb port and no screen (and no
 network device). Either I connect through ssh using the usb cable
 (eth over usb) or I use the usb cable to test my plug/unplug process.
 I cannot have a console _and_ test the unplugging at the same time.

 Then login into that machine and run screen, in which you run:
 'udevadm monitor -u -p  /tmp/udev.log 21'

 Do the necessary removal of the usb cable or whatever, then attach
 the usb cable again, login again and check the log.


 Christophe



 --
 Robert Milasan

 L3 Support Engineer
 SUSE Linux (http://www.suse.com)
 email: rmila...@suse.com
 GPG fingerprint: B6FE F4A8 0FA3 3040 3402  6FE7 2F64 167C 1909 6D1A
 ___
 systemd-devel mailing list
 systemd-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/systemd-devel
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udev event on usb unpluged

2015-08-25 Thread Tom Yan
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.t...@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.jal...@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@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/systemd-devel
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] udev event on usb unpluged

2015-08-25 Thread Tom Yan
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.jal...@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@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/systemd-devel
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] udev event on usb unpluged

2015-08-25 Thread christophe . jalady
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@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel