[OpenWrt-Devel] detecting USB sd card removal ("block info")
Karl Palsson
karlp at tweak.net.au
Thu Jan 28 07:35:05 EST 2016
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Daniel Golle <daniel at makrotopia.org> wrote:
> Hi Karl,
>
> On Thu, Jan 28, 2016 at 09:31:14AM -0000, Karl Palsson wrote:
> > Given that OpenWrt doesn't have a daemon like udisks to
> > mount/umount things automatically, I was trying to build it
> > myself by something like "block info" in a crontab.
>
> Well, there is mountd which can be used to maintain autofs for
> hot-plugable block devices. It will only mount things when they
> are actually being accessed (rather than mounting them once
> inserted/plugged-in) but at least unmounting on hot-removal
> doesn't need any extra care... I don't know your excact usage
> scenario, however, it guess that's already a better place to
> start from than having a cron-job...
I'll have a play with mountd, it seemed to be very very old
untouched code, so I wasn't really excited about even trying, but
sure.
Are you saying that mountd will automatically unmount the
filesystem if the device goes away or what? The problem is that
the device does _not_ go away on hotplug. (It doesn't get created
on hotplug either)
I have to explicitly run "block info" to get the system to notice that the card is inserted (and it creates the devices) and that also works for noticing that the card has been removed (and removing the devices) but it _doesn't_ work after the device has been mounted. Until I explicitly unmount (block umount or manual umount) block info doesn't detect that the card has been removed.
I want to _somehow_ catch and cleanup up if the card has been
removed. At present, I can keep writing to a card that doesn't
exist and all I get is a steady stream of failures on the
console. Having to unmount just to _test_ if the card is still
there isn't very helpful.
Timelines, maybe that helps: paste these two into
websequencediagrams.com
- ------------
title USB SD Card detect without mounting
note over devs: no /dev/sda*
SD->USB-reader: inserted
note over devs: no /dev/sda*
Bob->console: block info
console->devs: ??
note over devs:
/dev/sda* created
dmesg log about size ~xGb
end note
Bob->console: block info
console->Bob: no change
SD->USB-reader: removed
Bob->console: block info
console->devs: ??
note over devs:
/dev/sda* removed
dmesg log about size changed to 0
end note
- --------------
- ------
title USB SD Card detect WITH mounting
note over mounts: no mounts
note over devs: no /dev/sda*
SD->USB-reader: inserted
note over devs: no /dev/sda*
Bob->console: block info
console->devs: ??
note over devs:
/dev/sda* created
dmesg log about size ~xGb
end note
Bob->console: block detect
Bob->console: edit and enable /etc/config/fstab
Bob->console: block mount
note over mounts: /mnt/sda1 working
Bob->console: block info
console->Bob: no change
SD->USB-reader: removed
Bob->console: block info
console->Bob: no change!! no longer notices card gone!
note over devs,mounts:
/dev/sda* and mounts still EXIST
end note
- -------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
iQIcBAEBAgAGBQJWqgr5AAoJEBmotQ/U1cr2/mYP/3t4OMlJXGboCMwcZHXPEPWy
oqNQ9Qtjdu0YWeiB5Vgil22o1pQgLtUw7FgiJ/H5JN09CMoU31Y/omeg6rvyzJBU
Uf1YxW21pXPNhTPgGhtbIvPeD8ZMx3BIXJYNQmnZtRI1XJG5123u+S3hwHTQ68Jf
YTI18+DpoHEheEkCWPAuKKC24bkknV2c9zKD9wb7LucYuLkoOVlNvgons6Duganr
KIoREXvYZXtUqN4gCL+zBPK+sXib7sj4NVTQ7y64KaXJDiB/0G4CowSRIXjGYKA1
VXZjZJmW6PRtCVhaAt0QGvqLxTqP+o8VTPH8PmeGR3PQbZ8Dk+T+/OuZswWanwMK
F4VR/PDqc66XR6E4MdSXKISsyRL23Hzpp8sIR1G4kgbuvfncms71zB6mKLrYne0n
ZzaArsL69Zcp/qhSUOV0auGk1h5b6nFQQ1kREfbToJJMUXuSqMLWxAzx7Y25TKh5
zm5Piqwq2klvLwgnFUKJwuHZYwLsjsq//TJh3HZLrcfjyOGJlk61AKrnfXNStP8T
eyAKn/Hh2FN/Bx/COSQIqkkA2gnTYODNmd02BsKVLCcX+4tcj4EaqOFo1l/PVldm
IqkLmSG/1EV06ccJSQM2FwBzCFPgZUE+ri3dsPwscQfvVCBeISV27Mq/auiot4hh
yMWKqybPLjx5j0SOfF/A
=xvdw
-----END PGP SIGNATURE-----
-------------- next part --------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list