Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1874124pxj; Sat, 22 May 2021 04:33:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynmTYgye1gi+Z1sNcBPWqxKVP65A0beA1Zjbk3uCCrSWiOISWb1SbqkUU/AX4bwTGn4Gv9 X-Received: by 2002:a50:bf0f:: with SMTP id f15mr14530273edk.205.1621683231832; Sat, 22 May 2021 04:33:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621683231; cv=none; d=google.com; s=arc-20160816; b=Gn3BL7X6kZy3DY1urp1JzjF3myl0XlQ9Q4nrNAimhUr31K7wzUF8l0YEsxIna4GpU9 djoEIpVsWAofdEp1NkANtBQYAPl33RNK11pHrlrgTX4nddENZ4GuPFmTMadw/7pHj45X NAV8Qb2u3zqVEtI01cXYSr/N3SeLWnuRulBwecUSXyn+bZqMO1dZR+TIEASsbiXSgA5l iELueuvlfV0n3H0m6qadLsqltwr+943NHIkzW0j1JyHRnZ6Pi6QyoifNycD9QplnRKQU g8TJ8xWPo9SRa2dHjOeDlS3lt6CeHscQFZcGnwpQgqCnRdg6HPGSy9JlivQMWq/LQW+z T+lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=1kOHHb+Y1mDpGXTDWCoDuGyBc8YqEz2A5xaJqIhlchQ=; b=0DOcZxMktKtn8ujlyLwtOocIIi4MWO28msgot66sRpa8mVxwKeI6DtwQ9bAsW1Cxnk pyUxrC9u7cXvqy1I+2faoB2IbPBdIucqLmRHrLcAxODmV3AgYxO1b35N57ftvbk8D/5Q WbmsNRcJGICn0YOXBkcZLy7ReBxpl70khLn2GboiSvs7kDsM6GWAXHd45yn7afXZWoJ6 BBwpXAMgyJMrwKkfdGO+b09GF+lM+kuqg0JLQA8sASIa3nGnwTrvV9ZXeirCswRvHYv2 uHbf1BTRWf7JzIbALI9yVuF8JPqNsKLE2P/CuqirDVFAfA0CZNvwZLzSL5YdMmXNkXEf hV7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gAzPsBMX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qq5si3557064ejb.736.2021.05.22.04.33.28; Sat, 22 May 2021 04:33:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gAzPsBMX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230489AbhEVLdj (ORCPT + 99 others); Sat, 22 May 2021 07:33:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230358AbhEVLdi (ORCPT ); Sat, 22 May 2021 07:33:38 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27509C061574; Sat, 22 May 2021 04:32:13 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id a7so3610328plh.3; Sat, 22 May 2021 04:32:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=1kOHHb+Y1mDpGXTDWCoDuGyBc8YqEz2A5xaJqIhlchQ=; b=gAzPsBMXEQuxRpMyvG3kICmHXTgzm6Ob0J2tx3Yt4keonOI3K1g5XKYsZsmFLo39h3 JyUxdKwMfYZ6fCb3TPiN/WtxHPsAp4B5DmmN6ubQpARdvZN/X6DaguYrPsJFxCOnuVAA DoZa1rQei9VDfoUfM6UodhdUWb4VDuwV3z+IoNXUipzIqLUcCpg8mbJ/YAOKHJNcoOJ8 b172jM28j77307jsjTqJ1ocGIHjVAcDivKi7yX7y9Idz6MybRvL4SThVK4TiSbSFhTlU zdcaLjqQWq+v8cTDEOH+F2hvsChJuFuEj5b6qPkqw/qLEe4dytXojL3qsEyyloS7BkiB 1XKw== 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=1kOHHb+Y1mDpGXTDWCoDuGyBc8YqEz2A5xaJqIhlchQ=; b=gSvaGmi2sX//T4KsRD04gsogY5OO2w8B/5Jx7I+qOuXlOo1J/bMT/UQWLgx3KVcg8R b5zXfwYdTMjywNkW1WvSuRULWKaveCHmuBI5GQUd8LiSq896mEeBylZ/ceeAFmjZQRzS dWS4ZvbBDC+8uTJGL2k5UsxUrN4ndNlFVPUCbwUwGsaX7uNB5syn3eY0ZsqmisgDVeDc XLTbakkbuXDpp5Ytlri4may6NJF5rvPSvoMMDnVZ0dBYA7CHKdH1LS2ugUs+5buj0JzX T7hc5wgAlhcMq7jl1rQIooPHt8RJcFIiqiJCuHtr/PTpKew1NcA9s1NpsMMBck8ixQlc pOFQ== X-Gm-Message-State: AOAM532KiraoOknWHlYLmJA8i/Y97IpTKGb/K1b9sHsMOv/Pes2o+rNP qu4vcrXKEce8fPGUPoGVGKw= X-Received: by 2002:a17:902:d903:b029:ef:abd0:d8fa with SMTP id c3-20020a170902d903b02900efabd0d8famr16587186plz.49.1621683132609; Sat, 22 May 2021 04:32:12 -0700 (PDT) Received: from localhost ([178.236.46.205]) by smtp.gmail.com with ESMTPSA id e7sm7020330pfl.171.2021.05.22.04.32.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 May 2021 04:32:11 -0700 (PDT) From: menglong8.dong@gmail.com X-Google-Original-From: dong.menglong@zte.com.cn To: mcgrof@kernel.org Cc: viro@zeniv.linux.org.uk, keescook@chromium.org, samitolvanen@google.com, johan@kernel.org, ojeda@kernel.org, jeyu@kernel.org, joe@perches.com, dong.menglong@zte.com.cn, masahiroy@kernel.org, jack@suse.cz, axboe@kernel.dk, hare@suse.de, gregkh@linuxfoundation.org, tj@kernel.org, song@kernel.org, neilb@suse.de, akpm@linux-foundation.org, brho@google.com, f.fainelli@gmail.com, wangkefeng.wang@huawei.com, arnd@arndb.de, linux@rasmusvillemoes.dk, mhiramat@kernel.org, rostedt@goodmis.org, vbabka@suse.cz, glider@google.com, pmladek@suse.com, ebiederm@xmission.com, jojing64@gmail.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 0/3] init/initramfs.c: make initramfs support pivot_root Date: Sat, 22 May 2021 19:31:52 +0800 Message-Id: <20210522113155.244796-1-dong.menglong@zte.com.cn> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Menglong Dong As Luis Chamberlain suggested, I split the patch: [init/initramfs.c: make initramfs support pivot_root] (https://lore.kernel.org/linux-fsdevel/20210520154244.20209-1-dong.menglong@zte.com.cn/) into three. The goal of the series patches is to make pivot_root() support initramfs. In the first patch, I introduce the function ramdisk_exec_exist(), which is used to check the exist of 'ramdisk_execute_command' in relative path mode. In the second patch, I create a second mount, which is called 'user root', and make it become the root. Therefore, the root has a parent mount, and it can be umounted or pivot_root. Before change root, I have to check the exist of ramdisk_execute_command, because 'user root' should be umounted if ramdisk_execute_command not exist. 'user root' is mounted on '/root', and cpio is unpacked to it. So I have to use relative path to do this check, as 'user root' is not the root yet. Maybe I can do the check after change root, but it seems complex to change root back to '/'. What's weird is that I try to move 'user root' from '/root' to '/', but the absolute path lookup seems never follow the mount. That's why I introduced ramdisk_exec_exist. In the third patch, I fix rootfs_fs_type with ramfs, as it is not used directly any more, and it make no sense to switch it between ramfs and tmpfs, just fix it with ramfs to simplify the code. Menglong Dong (3): init/main.c: introduce function ramdisk_exec_exist() init/do_cmounts.c: introduce 'user_root' for initramfs init/do_mounts.c: fix rootfs_fs_type with ramfs fs/namespace.c | 2 -- include/linux/init.h | 1 - init/do_mounts.c | 82 +++++++++++++++++++++++++++++++++++++------- init/do_mounts.h | 7 +++- init/initramfs.c | 10 ++++++ init/main.c | 17 ++++++++- 6 files changed, 101 insertions(+), 18 deletions(-) -- 2.31.1