From patchwork Tue Apr 9 18:08:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kenneth J. Miller" X-Patchwork-Id: 1082599 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=none (p=none dis=none) header.from=miller.ec Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="RB7JH9sA"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=miller-ec.20150623.gappssmtp.com header.i=@miller-ec.20150623.gappssmtp.com header.b="Ejrley/9"; 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 44dwKg1LGnz9sNp for ; Wed, 10 Apr 2019 04:09:26 +1000 (AEST) 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:Message-Id:Date:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=hiUOwp7T1Kg9OkjuxIObE4WiacUhVOKTi6nQZ49HcyU=; b=RB7JH9sAtJTKwJ Rw1qJx1qlgxgMYVxmSGY1Wu+IQfcQKP/FYgdXaX/1Bxf0K23xUO7krNOLzdjCm6D6Zh2hamJ1mZzd crP4tHEuZ6rj0y4C5GIzbrC+ShVd7tVQ2xUapT1UmfVBbmjGIrYqfdoZXG0uViFpiymy0C21ji+Yd bNkA5w/dJT4xwhma1/xMheMDTwCPQn5HxlIr8RjDRZsVqmXxKvme3LcMOSL/7JWWaymYPvU+XuzOX 6jg0JXn2hefC9a/X56S0rEVTtQwiG5j1Th22UeUvM8osk/izrpD20df0Yr3bj4raY9zUEx4IByHkl 2fILVbf7PbDN7LZCXfug==; 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 1hDvB9-00045t-Um; Tue, 09 Apr 2019 18:09:03 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hDvB6-00045Q-7v for openwrt-devel@lists.openwrt.org; Tue, 09 Apr 2019 18:09:02 +0000 Received: by mail-wm1-x341.google.com with SMTP id z11so4708252wmi.0 for ; Tue, 09 Apr 2019 11:08:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=miller-ec.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bLuvmqxK/Okljx7zsumaJjHpUj/oX6cB8FGUjQDSCdg=; b=Ejrley/9W6F/59VMv/vXFx7xDD9O1LeKAtXTxCTYQlKakkKwvT+3m1TkFVkNjhgwJe 6SSn1ZEQ/ebxnpeLkMTEqJ89U62mBjuiXYWzLe4V4W7RC+K6UC6tGOipDI2flpwQHwlM 3VxINDGFy6yqgLeS3ZwaEjbKSk2AMrCbhR6hsaXMRGzyCklfqK8Yqeo5AY/VnwyO9YxR dkiz7R1n4qCRx56Mw/FZ/YQ22UDRjTAdUxYOtuD1SpjrtBIj72igJSP3fYZUO7tOtWqy xe7/5kBwaCeeO3CF3B2xudP4xeOXul7EkVoMvMinAwTZvHujLhgSBvLJM1c2GcYyIv1G GkEA== 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:mime-version :content-transfer-encoding; bh=bLuvmqxK/Okljx7zsumaJjHpUj/oX6cB8FGUjQDSCdg=; b=TKqMW+47NW/dilSm0ZYz3X4yqKrS1wMhsBjhli8NgN/JBawm4F23gQaNiKBHlnUWzp b/UEE07y4JSVkIa2yBI+Bde2tMxjCzRpPamyBqh7L1qoQkwc/iL9guziTrNRiqQStpmZ 5rBgaVCxd5UP+qmgpQgbv+Jc/X7fhF4JkAW7QUH0fkoUBoDm4Rm8AkT5y3rD9OD36NPi ZsumCz+uCfmaOG8kd09GK8OHhGzG8akTBGDApTt4SgrzyTG9OIwqUTb0RIP8nQqrgyw1 I26kek4ZhIqtc+/r5gSL7Y3Ts26LYHxzmmfehS3QJvzQi4u8DRCFHGmJxSway1KyrMBk Q9ww== X-Gm-Message-State: APjAAAUrY5GAtoNNE76c1jjyfBbBkRvk7QytQWqGiq1HBDSEPp1EzxAg GErMJQDyuEP6qYzO/x8Wn7mas99xgVD32A== X-Google-Smtp-Source: APXvYqyqrcNqTjO3s5wl7I9GEu0hXbM+5MkvEpyQ/le5wMf6xZ0L2c15P9Ba20LWNJZhuEmcPwP1gQ== X-Received: by 2002:a1c:9ad6:: with SMTP id c205mr23345468wme.46.1554833337693; Tue, 09 Apr 2019 11:08:57 -0700 (PDT) Received: from ZK-Think.localdomain (dslb-178-002-254-214.178.002.pools.vodafone-ip.de. [178.2.254.214]) by smtp.gmail.com with ESMTPSA id n6sm24093841wmn.48.2019.04.09.11.08.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 11:08:56 -0700 (PDT) From: "Kenneth J. Miller" To: openwrt-devel@lists.openwrt.org Date: Tue, 9 Apr 2019 20:08:39 +0200 Message-Id: <20190409180839.1815-1-ken@miller.ec> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190409_110900_422280_311A2DE0 X-CRM114-Status: UNSURE ( 9.78 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.0 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:341 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.0 DKIMWL_WL_MED DKIMwl.org - Medium sender Subject: [OpenWrt-Devel] [PATCH] fstools: block: make extroot mount preparation more robust 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: "Kenneth J. Miller" Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The extroot mount preparation code for r/w rootfs overlay discovery, and determining the user-defined /etc/config/fstab location within, would only discover overlays residing on JFFS2 or UBIFS MTD storage. This led to attempts at loading the uci fstab configuration without the required /tmp/overlay directory prefix on devices with a non-MTD r/w rootfs overlay, and thus failure to find any custom fstab /overlay extroot entries on PREINIT. (example: the default openwrt eMMC partition layout on the zyxel nbg6817) Futher, with UBIFS_EXTROOT enabled (fstools package default), and no MTD rootfs partitions present, check_extroot would not attempt rootfs discovery on block devices, such as the ext4 mmcblk rootfs overlay on the nbg6817. With this patch: 1) main_extroot now attempts to load uci fstab configuration from an already mounted overlay, before defaulting to the prefix-less uci config dir when no MTD rootfs partitions are detected. 2) check_extroot now also attempts to find rootfs partitions on block devices when no MTD rootfs partitions are detected. Fixes: FS#2231 Ref: https://bugs.openwrt.org/index.php?do=details&task_id=2231 Signed-off-by: Kenneth J. Miller Tested-by: Val Kulkov --- block.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/block.c b/block.c index 39212d2..3dfc4a5 100644 --- a/block.c +++ b/block.c @@ -1301,7 +1301,7 @@ static int find_block_ubi_RO(libubi_t libubi, char *name, char *part, int plen) return err; } -#else +#endif static int find_root_dev(char *buf, int len) { @@ -1332,8 +1332,6 @@ static int find_root_dev(char *buf, int len) return -1; } -#endif - static int test_fs_support(const char *name) { char line[128], *p; @@ -1363,25 +1361,20 @@ static int check_extroot(char *path) struct probe_info *pr = NULL; char devpath[32]; -#ifdef UBIFS_EXTROOT if (find_block_mtd("\"rootfs\"", devpath, sizeof(devpath))) { int err = -1; +#ifdef UBIFS_EXTROOT libubi_t libubi; libubi = libubi_open(); err = find_block_ubi_RO(libubi, "rootfs", devpath, sizeof(devpath)); libubi_close(libubi); - if (err) - return -1; - } -#else - if (find_block_mtd("\"rootfs\"", devpath, sizeof(devpath))) { - if (find_root_dev(devpath, sizeof(devpath))) { +#endif + if (err && find_root_dev(devpath, sizeof(devpath))) { ULOG_ERR("extroot: unable to determine root device\n"); return -1; } } -#endif list_for_each_entry(pr, &devices, list) { if (!strcmp(pr->dev, devpath)) { @@ -1585,7 +1578,7 @@ static int main_extroot(int argc, char **argv) } #endif - return mount_extroot(NULL); + return mount_extroot("/tmp/overlay"); } static int main_mount(int argc, char **argv)