From patchwork Thu Dec 6 12:51:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 1008770 X-Patchwork-Delegate: zajec5@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Yu0l6E9Z"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="XCuVj6eR"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 439b982csnz9s1c for ; Thu, 6 Dec 2018 23:52:28 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wtf95TJoRWfhSlkyk+7BO3MD0Szjaq2Gv1knb9HDzcw=; b=Yu0l6E9ZLjua8z pLnZujVW1Me8BXAZOACq0MkfTwXNVY5hUMcmJNZgl8C7x5hchF0sReGwmDs9nbPNjag2cFBATJfIL gm75MeKPg1z/jnEp2JqOae51O/fA5E/TIp+ufj/kTMxZqEJl0bAzWOtayVH92wn2Ico6OXnn77FS4 3didmWK+qiSluaw9eNi86958J/OsfpLWqqvxsNK7JzqNjejM5HvU5ptOJapMn/msTk8nx0nVN3J+s dlm7BwJSdgQVu1LSNAjx7cm9RzP1RxPF8b5gB3BjL5NDfHB/aXKRMNtyYAmXwg5JWtkfp+Dk5HggS rnsM1MBoQPk6fQiVUyzg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUt8c-0006pK-V2; Thu, 06 Dec 2018 12:52:18 +0000 Received: from mail-lf1-x143.google.com ([2a00:1450:4864:20::143]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gUt8Z-0006oq-WA for openwrt-devel@lists.openwrt.org; Thu, 06 Dec 2018 12:52:17 +0000 Received: by mail-lf1-x143.google.com with SMTP id v5so255161lfe.7 for ; Thu, 06 Dec 2018 04:52:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WcjRnur77PI+W0JvMsd2DOqtIXPDZzcd22ihkC5bcLM=; b=XCuVj6eR90WiK69WWr6fIrb1Vit/Wxe4f37+ToIQsM6QuUp3To1JAiwgdf8pq2TpkN kKFvVDBkZCfwws8brn5KtkOMNN5yd+9V2SpTlZksEmOTJiNlSjROhw+pOLGtzmeqoOk3 8EydYmwm5rirzoJuoXD1Vi4sh1P7FU5kfjl1wVZeL0y3ZfMFbKsXfuoAfUtc2LcPpK9N WdzdqmTALST1zyPb3FwP7qyu7jwHHeoLSv3/8LMtnNpWQ4PKfhUQWTnPQZjInOfSB824 rOvJ7saZw+RIavUFdVCYup909OHfI7uy45r1dbJD60ekV4VUAFINVfP7r7Dm5fj6f+XD FPZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WcjRnur77PI+W0JvMsd2DOqtIXPDZzcd22ihkC5bcLM=; b=k+MWex9bCX3EvujDnbU1GWjfBeOKDGuF0fK+vqH1C5myMD3FQf7chGsiY4XTgLuYbQ smb8fwPb9eAtx8rUc1aj0JQpOcbkyfOcwz2KNeQ6L5lMQv6c2pLg7t5NPYqlxrJmious //UjOcXXicJ8m1SYlvZHNrqd9w7dV3vwBICJJXb4PjBG/r6vBYZD/Ve3Mqs/Z+q9u+BU rbJ84tbv668UlYm6KPySbv2wGGwmkKiSk6mLMzowb9kKlCfyl6Q0yrEZd2CojRdeFseZ HoNVbqLrNpXuCfQFoPd2lrKOg2Jf3h7EuIlodLkXXroCtyMjMxb/SswL4TnmjAWqZsjP Re/Q== X-Gm-Message-State: AA+aEWbk3eUXcb6AJyOYhaqGxlm622m50qLT1x0uPqRIP9xs+qnb83IC j1GZvuPcTpDN68sFTgEsl2REBcnX X-Google-Smtp-Source: AFSGD/XRwwwM19mxW9QoNGNRgDvVF+P5ee0E/iITDjJo/bMa4NMgL6LKrUhfDTd4YF3VeAhRpVT02g== X-Received: by 2002:a19:9dd1:: with SMTP id g200mr16306930lfe.127.1544100722943; Thu, 06 Dec 2018 04:52:02 -0800 (PST) Received: from linux-veee.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id u79-v6sm57019lje.36.2018.12.06.04.52.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Dec 2018 04:52:02 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: openwrt-devel@lists.openwrt.org Date: Thu, 6 Dec 2018 13:51:55 +0100 Message-Id: <20181206125155.32381-1-zajec5@gmail.com> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20181205213549.13138-1-zajec5@gmail.com> References: <20181205213549.13138-1-zajec5@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181206_045216_036334_F83335EA X-CRM114-Status: GOOD ( 11.40 ) X-Spam-Score: 0.1 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:143 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (zajec5[at]gmail.com) 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (zajec5[at]gmail.com) -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Subject: [OpenWrt-Devel] [PATCH V2 fstools] block: generate hotplug.d mount events X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Rafał Miłecki With this change block generates 2 "mount" hotplug.d subsystem events: 1) "add" when block device gets mounted 2) "remove" when block device gets unmounted This allows e.g. controlling USB storage dependant software using hotplug.d listeners. A very similar solution was implemented in mountd which was replaced by blockd. Signed-off-by: Rafał Miłecki --- V2: Use hotplug_call() helper. It requires [PATCH libubox] hotplug: add hotplug_call() helper --- block.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/block.c b/block.c index 46050b4..99e02b0 100644 --- a/block.c +++ b/block.c @@ -38,6 +38,7 @@ #include #include +#include #include #include #include @@ -880,6 +881,24 @@ static int exec_mount(const char *source, const char *target, return err; } +static int hotplug_call_mount(const char *action, const char *device) +{ + char actionenv[] = "ACTION=xxxxxx"; + char deviceenv[32]; + char *envp[] = { actionenv, deviceenv, NULL }; + int err; + + snprintf(actionenv, sizeof(actionenv), "ACTION=%s", action); + snprintf(deviceenv, sizeof(deviceenv), "DEVICE=%s", device); + + err = hotplug_call("mount", envp); + if (err) { + ULOG_ERR("hotplug-call call failed: %d\n", err); + } + + return err; +} + static int handle_mount(const char *source, const char *target, const char *fstype, struct mount *m) { @@ -1079,6 +1098,8 @@ static int mount_device(struct probe_info *pr, int type) handle_swapfiles(true); + hotplug_call_mount("add", device); + return 0; } @@ -1091,6 +1112,8 @@ static int umount_device(char *path) if (!mp) return -1; + hotplug_call_mount("remove", basename(path)); + err = umount2(mp, MNT_DETACH); if (err) ULOG_ERR("unmounting %s (%s) failed (%d) - %m\n", path, mp,