diff mbox

[OpenWrt-Devel,v3] procd: hotplug.json: allow passing hotplug events from all subsystems

Message ID 1455679618-13963-1-git-send-email-yszhou4tech@gmail.com
State Accepted
Headers show

Commit Message

Yousong Zhou Feb. 17, 2016, 3:26 a.m. UTC
There are time that programs need to be notified of events from
subsystems that are not enumerated in the .json definition, e.g. QEMU
guest agent by default requires /dev/virtio-ports/org.qemu.guest_agent.0
which is a symlink to /dev/vportMpN from virtio-ports subsystem.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
---
Changes from v2, fix hotplug-call platform twice

Changes from v1, now we depend on "isdir" support from libubox/json_script to
selectively hotplug-call only those subsystems we have handlers ready

For the record, the PR about qemu-ga is at
https://github.com/openwrt/packages/pull/2041

 package/system/procd/files/hotplug.json | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

Comments

Yousong Zhou Feb. 17, 2016, 5:26 a.m. UTC | #1
On 17 February 2016 at 11:26, Yousong Zhou <yszhou4tech@gmail.com> wrote:
> There are time that programs need to be notified of events from
> subsystems that are not enumerated in the .json definition, e.g. QEMU
> guest agent by default requires /dev/virtio-ports/org.qemu.guest_agent.0
> which is a symlink to /dev/vportMpN from virtio-ports subsystem.
>
> Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
> ---
> Changes from v2, fix hotplug-call platform twice
>
> Changes from v1, now we depend on "isdir" support from libubox/json_script to
> selectively hotplug-call only those subsystems we have handlers ready
>
> For the record, the PR about qemu-ga is at
> https://github.com/openwrt/packages/pull/2041
>
>  package/system/procd/files/hotplug.json | 18 ++++++------------
>  1 file changed, 6 insertions(+), 12 deletions(-)
>
> diff --git a/package/system/procd/files/hotplug.json b/package/system/procd/files/hotplug.json
> index 516a122..e2f1604 100644
> --- a/package/system/procd/files/hotplug.json
> +++ b/package/system/procd/files/hotplug.json
> @@ -58,10 +58,6 @@
>                 ]
>         } ],
>         [ "if",
> -               [ "eq", "SUBSYSTEM", "platform" ],
> -               [ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ]
> -       ],
> -       [ "if",

Is it required that we should hotplug-call platform first before doing
button handling?

                yousong

>                 [ "and",
>                         [ "has", "BUTTON" ],
>                         [ "eq", "SUBSYSTEM", "button" ],
> @@ -69,18 +65,16 @@
>                 [ "button", "/etc/rc.button/%BUTTON%" ]
>         ],
>         [ "if",
> -               [ "eq", "SUBSYSTEM",
> -                       [ "net", "input", "usb", "usbmisc", "ieee1394", "block", "atm", "zaptel", "tty", "button", "sound" ]
> -               ],
> -               [ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ]
> -       ],
> -       [ "if",
>                 [ "and",
>                         [ "eq", "SUBSYSTEM", "usb-serial" ],
>                         [ "regex", "DEVNAME",
>                                 [ "^ttyUSB", "^ttyACM" ]
> -                       ],
> +                       ]
>                 ],
> -               [ "exec", "/sbin/hotplug-call", "tty" ]
> +               [ "exec", "/sbin/hotplug-call", "tty" ],
> +               [ "if",
> +                       [ "isdir", "/etc/hotplug.d/%SUBSYSTEM%" ],
> +                       [ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ]
> +               ]
>         ],
>  ]
> --
> 2.6.4
>
diff mbox

Patch

diff --git a/package/system/procd/files/hotplug.json b/package/system/procd/files/hotplug.json
index 516a122..e2f1604 100644
--- a/package/system/procd/files/hotplug.json
+++ b/package/system/procd/files/hotplug.json
@@ -58,10 +58,6 @@ 
 		]
 	} ],
 	[ "if",
-		[ "eq", "SUBSYSTEM", "platform" ],
-		[ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ]
-	],
-	[ "if",
 		[ "and",
 			[ "has", "BUTTON" ],
 			[ "eq", "SUBSYSTEM", "button" ],
@@ -69,18 +65,16 @@ 
 		[ "button", "/etc/rc.button/%BUTTON%" ]
 	],
 	[ "if",
-		[ "eq", "SUBSYSTEM",
-			[ "net", "input", "usb", "usbmisc", "ieee1394", "block", "atm", "zaptel", "tty", "button", "sound" ]
-		],
-		[ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ]
-	],
-	[ "if",
 		[ "and",
 			[ "eq", "SUBSYSTEM", "usb-serial" ],
 			[ "regex", "DEVNAME",
 				[ "^ttyUSB", "^ttyACM" ]
-			],
+			]
 		],
-		[ "exec", "/sbin/hotplug-call", "tty" ]
+		[ "exec", "/sbin/hotplug-call", "tty" ],
+		[ "if",
+			[ "isdir", "/etc/hotplug.d/%SUBSYSTEM%" ],
+			[ "exec", "/sbin/hotplug-call", "%SUBSYSTEM%" ]
+		]
 	],
 ]