From patchwork Sat Dec 28 10:58:08 2019 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: 1215833 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 (sender SPF authorized) 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="uV+vN1KU"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="fazO8vkd"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47lLJw3F9Wz9sPW for ; Sat, 28 Dec 2019 21:58:24 +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=14CQ/FrXbO1jNl6WJhY3sB9vSR4rGwctoh1wSC1O1Gs=; b=uV+vN1KUSFqC6e ydjurzbO0/JTkokZOG22JOX8iOqsaiQQLJ/Pac+svORqgcC0ELTotKQRFQqqUaxhC4pTvAhhOWsjF QefpXhVZxAtrObTFSEp0uXqGLLVtdleYT/DmHi0ZM1YtTVt1s0dH4u8NCwnsvxzRJXdt4VH93HbbK ttW5aCyumu04xqh+s3uN/7nyP1mvnKuafOmnJjfDpv0vyOcCFy2XGKlAS2gmiYopB5LJ5gvL0CMhP h7WbLvB1A+JQBxLYXZkFvddXsmECnymqYNTiCkmBCnltQj5qIrW0quy4S06FWzvpy89ee/sHP0qBK NZexjN70TWQ5kN+2j5xQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1il9nY-0003ic-DI; Sat, 28 Dec 2019 10:58:20 +0000 Received: from mail-lj1-x241.google.com ([2a00:1450:4864:20::241]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1il9nV-0003iH-E5 for openwrt-devel@lists.openwrt.org; Sat, 28 Dec 2019 10:58:19 +0000 Received: by mail-lj1-x241.google.com with SMTP id m26so26592243ljc.13 for ; Sat, 28 Dec 2019 02:58:17 -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=Sg+80A/N6l2hwTWyHWuTp2olNsnr34FzBkc9bV2JJqs=; b=fazO8vkdHwOou97GMxxR7jZbglEgr9r2EkJGa1d7UlhCJJMRnL7P+/2xTpFdHPWUjF ebDCVGz6k6PlqiigbiVvLK1mHcZDccyrkkih3Ee8Q7cKqePkV7p3MABJ02C5ahbRHIM2 lMY76IlGhL48WP2XKmKboxL4Nn2LLE+yWQSv8CvyJGyMhnOyLr+BRdRXFr1WUFZ+0vi0 ScjcR/mH3IkseBJS/9zpMFJJu6hvaCGYisUSeG517iYYSJ2/n8o8RoDDu6AodficISHp UelHpUdEY+wta+qNXzPZ1YbyphdwP9ClVavb8pf5fVbbzcHuJrIDELuBPphUFRqVoBtM JWWw== 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=Sg+80A/N6l2hwTWyHWuTp2olNsnr34FzBkc9bV2JJqs=; b=rGipv87dakAR1nld91Pf7Q80zIGXi7KB8ii6m9uuihuSaMMDl0qzOno2TjqlljGr+O W7uR9xb/+emGewNbCMkwWAyN9XXpq+A2W4QjfONMoGi+5ZEN4iXlZ8AiSIPcyQ0hNcHL xjXh6fesO+MEfsEOrD0Ra66ffk8osgue8lRcKfEcjWQThC+RPqQeyU6BhKcLFehlQPug 06H/Xj/8whqvf6oBiQrbs8ztVbcYs/No8Bttp12OKaJHnLrh8wo4KQoUsBehBV/5v5TE CZrwQTj+UokqRCpXGbcBIU8bCk7s/k9DPy3June+DpwWFwYD2EaaNP8Yqip4kb9LEw9L mrWA== X-Gm-Message-State: APjAAAW5on0DDUcQRqvXknWszZP1Oae4fbScIl3f0ZZ7ZGYfi+p3z2e/ dBnZI+hTtyIS3xvhjYTuwXksUfbK X-Google-Smtp-Source: APXvYqwusyL87qYbHD76OCc3GCsPp3TT9qE3gOYD1GKxJrtsT5nk3/ON390UmbYaq4p1EqTY3xUsfQ== X-Received: by 2002:a2e:9596:: with SMTP id w22mr30575189ljh.21.1577530695608; Sat, 28 Dec 2019 02:58:15 -0800 (PST) Received: from localhost.localdomain (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id z14sm8623290ljm.86.2019.12.28.02.58.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 Dec 2019 02:58:15 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: openwrt-devel@lists.openwrt.org Date: Sat, 28 Dec 2019 11:58:08 +0100 Message-Id: <20191228105808.5432-1-zajec5@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191227085335.10144-1-zajec5@gmail.com> References: <20191227085335.10144-1-zajec5@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191228_025817_528670_12CD4B87 X-CRM114-Status: GOOD ( 13.22 ) 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 https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:241 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (zajec5[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (zajec5[at]gmail.com) -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_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Subject: [OpenWrt-Devel] [PATCH V2 fstools] Revert "block: mount_action: handle mount/umount deps" X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Yousong Zhou , John Crispin Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Rafał Miłecki This reverts commit 32c3126b2f0464106d74317336b6aef1d7d5f82f. Internal list of devices guarantees some basic sorting (by device type and then a name) but nothing more. In particular it cannot be guaranteed that all preceding entries are parent devices. That would require a tree struct instead of a flat list. In most cases mounting all preceding devices results in unwanted mounts. If there are 2 disks with 2 partitions each: sda: /dev/sda1 /dev/sda2 sdb: /dev/sdb1 /dev/sdb2 Then using autofs and accessing sdb2 would result in mounting all 4 partitions and spinning unneeded sda. If some dependency handling is required it should be implemented explicitly as current solution isn't reliable and it breaks expected autofs behavior. Cc: Yousong Zhou Signed-off-by: Rafał Miłecki --- V2: Update commit message --- block.c | 43 +++++++++++++------------------------------ 1 file changed, 13 insertions(+), 30 deletions(-) diff --git a/block.c b/block.c index b6d49a8..e07cbc5 100644 --- a/block.c +++ b/block.c @@ -1199,47 +1199,30 @@ static int umount_device(char *path, int type, bool all) static int mount_action(char *action, char *device, int type) { - struct device *the_dev, *dev; char path[32]; if (!action || !device) return -1; - - if (config_load(NULL)) - return -1; - cache_load(0); - - the_dev = find_block_device(NULL, NULL, device); + snprintf(path, sizeof(path), "/dev/%s", device); if (!strcmp(action, "remove")) { if (type == TYPE_HOTPLUG) blockd_notify(device, NULL, NULL); - if (!the_dev || !the_dev->m || the_dev->m->type != TYPE_MOUNT) { - snprintf(path, sizeof(path), "/dev/%s", device); - umount_device(path, type, true); - } else - vlist_for_element_to_last_reverse(&devices, the_dev, dev, node) - if (dev->m && dev->m->type == TYPE_MOUNT) - umount_device(dev->pr->dev, type, true); + umount_device(path, type, true); + return 0; - } else if (!strcmp(action, "add")) { - if (!the_dev) - return -1; - if (the_dev->m && the_dev->m->type == TYPE_MOUNT) { - vlist_for_first_to_element(&devices, the_dev, dev, node) { - if (dev->m && dev->m->type == TYPE_MOUNT) { - int err = mount_device(dev, type); - if (err) - return err; - } - } - return 0; - } else - return mount_device(the_dev, type); + } else if (strcmp(action, "add")) { + ULOG_ERR("Unkown action %s\n", action); + + return -1; } - ULOG_ERR("Unkown action %s\n", action); - return -1; + + if (config_load(NULL)) + return -1; + cache_load(0); + + return mount_device(find_block_device(NULL, NULL, path), type); } static int main_hotplug(int argc, char **argv)