[OpenWrt-Devel] [PATCH fstools RFC] block: generate hotplug.d mount even "add" after mounting
John Crispin
john at phrozen.org
Fri Nov 30 14:50:48 EST 2018
On 30/11/2018 16:07, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal at milecki.pl>
>
> This is what was implemented in mountd and what some scripts used to
> use. It's a pretty generic solution for managing software that may use
> e.g. USB storage.
>
> Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
looks good, I agree that this is a missing feature compared to mountd
John
> ---
> It's just a RFC for now. It's mainly missing a "remove" event support.
> ---
> block.c | 27 +++++++++++++++++++++++++++
> 1 file changed, 27 insertions(+)
>
> diff --git a/block.c b/block.c
> index a356315..20c14fe 100644
> --- a/block.c
> +++ b/block.c
> @@ -880,6 +880,31 @@ static int exec_mount(const char *source, const char *target,
> return err;
> }
>
> +static void hotplug_call_mount(const char *action, const char *device)
> +{
> + pid_t pid;
> +
> + pid = fork();
> + if (!pid) {
> + char * const argv[] = { "hotplug-call", "mount", (char *)0 };
> + char actionenv[14];
> + char deviceenv[32];
> + char *envp[] = { actionenv, deviceenv, (char *)0 };
> +
> + snprintf(actionenv, sizeof(actionenv), "ACTION=%s", action);
> + snprintf(deviceenv, sizeof(deviceenv), "DEVICE=%s", device);
> +
> + execve("/sbin/hotplug-call", argv, envp);
> + exit(-1);
> + } else if (pid > 0) {
> + int status;
> +
> + waitpid(pid, &status, 0);
> + if (WEXITSTATUS(status))
> + ULOG_ERR("hotplug-call call failed: %d\n", WEXITSTATUS(status));
> + }
> +}
> +
> static int handle_mount(const char *source, const char *target,
> const char *fstype, struct mount *m)
> {
> @@ -1079,6 +1104,8 @@ static int mount_device(struct probe_info *pr, int type)
>
> handle_swapfiles(true);
>
> + hotplug_call_mount("add", device);
> +
> return 0;
> }
>
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list