[systemd-devel] udev event on usb unpluged
christophe.jalady at free.fr
christophe.jalady at free.fr
Sat Aug 29 12:43:18 PDT 2015
>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.ty89 at gmail.com>
À: "christophe jalady" <christophe.jalady at free.fr>
Cc: "Robert Milasan" <rmilasan at suse.com>, "systemd" <systemd-devel at 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.jalady at 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" <rmilasan at suse.com>
> À: "christophe jalady" <christophe.jalady at free.fr>
> Cc: systemd-devel at 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.jalady at 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: rmilasan at suse.com
> GPG fingerprint: B6FE F4A8 0FA3 3040 3402 6FE7 2F64 167C 1909 6D1A
>
> _______________________________________________
> 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