[OpenWrt-Devel] block info and DISK_MEDIA_CHANGE events

John Crispin blogic at openwrt.org
Fri Feb 19 12:45:09 EST 2016

On 19/02/2016 18:00, Karl Palsson wrote:
> Hi,
> I'm trying to get "block mount" to behave well when a microSD
> card is removed/inserted from a fixed USB card reader. I've
> compiled the uevent-hotplug debugger example from
> https://www.kernel.org/doc/pending/hotplug.txt and running that
> on my device, I can see that "block info" is somehow triggering
> the uevent change notifications I hope. (I can't see anywhere in
> the fstools how the uevent is triggered, but it only happens if I
> run "block info" manually, "blkid" doesn't trigger any events, so
> it's something in block info
> Example event (unfortuntely it's identical for card inserted ->
> removed and for removed -> inserted)
> ```
> change@/devices/platform/ehci-platform/usb1/1-1/1-1.1/1-1.1:1.0/host0/target0:0:0/0:0:0:0/block/sda
> ACTION=change
> DEVPATH=/devices/platform/ehci-platform/usb1/1-1/1-1.1/1-1.1:1.0/host0/target0:0:0/0:0:0:0/block/sda
> ```

fstools/libblkid-tiny/libblkid-tiny.c: probe_block()

does an open() on the device node which will eventually end up inside

drivers/scsi/sd.c: sd_open()

which will call check_disk_change(bdev);

and that triggers the uevent.

i am not sure how you can get it to automatically send the event without
polling it.
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org

More information about the openwrt-devel mailing list