aboutsummaryrefslogtreecommitdiffstats
path: root/package/system/fstools/files/media-change.hotplug
diff options
context:
space:
mode:
authorMatthias Badaire <mbadaire@gmail.com>2018-05-16 00:07:37 +0200
committerJo-Philipp Wich <jo@mein.io>2019-06-21 14:17:22 +0200
commitfc39d5fc4500c512bd7e0427000f72b324486e5e (patch)
tree6ce05446e9b9e9e6bcd30d5e88fa3090c40a9726 /package/system/fstools/files/media-change.hotplug
parentb463a13881d3699c0f2d67ceeda146c76af58ac6 (diff)
downloadupstream-fc39d5fc4500c512bd7e0427000f72b324486e5e.tar.gz
upstream-fc39d5fc4500c512bd7e0427000f72b324486e5e.tar.bz2
upstream-fc39d5fc4500c512bd7e0427000f72b324486e5e.zip
fstools: media change detection (eg:sdcard) using kernel polling
Linux kernel has a polling mechanism that can be activated by changing the parameter /sys/module/block/parameters/events_dfl_poll_msecs which is deactivated by default or the /sys/block/[device]/events_poll_msecs for one device. This patch set the events_poll_msecs when a disk is inserted. Once the media disk change event is sent by the kernel then we force a re-read of the devices using /sbin/block info. With this patch, insertion and ejection of sd card will automatically generate partition devices in /dev. Signed-off-by: Matthias Badaire <mbadaire@gmail.com> [rewrap commit message, fix bashisms, fix non-matching condition, bump pkg release] Signed-off-by: Jo-Philipp Wich <jo@mein.io> (cherry picked from commit cf8483cb4ffc99bf3f512bb134860ccc8c099abe)
Diffstat (limited to 'package/system/fstools/files/media-change.hotplug')
-rw-r--r--package/system/fstools/files/media-change.hotplug8
1 files changed, 8 insertions, 0 deletions
diff --git a/package/system/fstools/files/media-change.hotplug b/package/system/fstools/files/media-change.hotplug
new file mode 100644
index 0000000000..30fc3d5c4f
--- /dev/null
+++ b/package/system/fstools/files/media-change.hotplug
@@ -0,0 +1,8 @@
+[ -n "$DISK_MEDIA_CHANGE" ] && /sbin/block info
+
+if [ "$ACTION" = "add" -a "$DEVTYPE" = "disk" ]; then
+ case "$DEVNAME" in
+ mtd*) : ;;
+ *) echo 2000 > /sys/block/$DEVNAME/events_poll_msecs ;;
+ esac
+fi