From patchwork Sat Oct 3 21:42:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Hadjinlian X-Patchwork-Id: 526027 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ozlabs.org (Postfix) with ESMTP id 9A904140B0E for ; Sun, 4 Oct 2015 08:42:30 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=UEESB/lX; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id E252088371; Sat, 3 Oct 2015 21:42:29 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rK79ZL3q1e3M; Sat, 3 Oct 2015 21:42:29 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 57C858B53B; Sat, 3 Oct 2015 21:42:29 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id E49DC1C0F8B for ; Sat, 3 Oct 2015 21:42:27 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id E01D888C9F for ; Sat, 3 Oct 2015 21:42:27 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5umjeS-GFCsh for ; Sat, 3 Oct 2015 21:42:27 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by whitealder.osuosl.org (Postfix) with ESMTPS id 26FD988C9A for ; Sat, 3 Oct 2015 21:42:27 +0000 (UTC) Received: by wicgb1 with SMTP id gb1so73441678wic.1 for ; Sat, 03 Oct 2015 14:42:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=gXnTTJFcxkFQ5XpEbzk0mtnlLDfsV6+a3w58N27GaB4=; b=UEESB/lXw7BPSfL9zP2eL3iZsIq0MpZt36GrE6U/A7yCNk1h5AJbEC+j19zFpUe6NE yXZaDiEzt4s47FQsSGYc0eTLTuPY/sS9fWGTbSgeZ6fmww20Uf9srGKzzSvTO/qM6Ppa PJLOU6RbrqkaD6T+CITY680XkX0q8qJPskYYOCE5wjOfuKPNWa3GhlRZxXsQOBXyAwW0 7A0P6QtqCOaXm8Lk+HhU/Bfs2+Ut+4Aynibiz9AtHTOc3YQ3qtJGCwutiQBbnS5S+jt4 XwaP2Z+88XoSSn6fd6U/4T1uh9Y4eCQV2figh0NCn5NFPGkWvUfX1DOoixN8DnYHijr6 1YUw== X-Received: by 10.180.240.170 with SMTP id wb10mr4279680wic.91.1443908545729; Sat, 03 Oct 2015 14:42:25 -0700 (PDT) Received: from localhost.localdomain (LPoitiers-656-1-204-92.w80-11.abo.wanadoo.fr. [80.11.219.92]) by smtp.gmail.com with ESMTPSA id p1sm6031532wif.7.2015.10.03.14.42.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 03 Oct 2015 14:42:24 -0700 (PDT) From: Maxime Hadjinlian To: buildroot@busybox.net Date: Sat, 3 Oct 2015 23:42:21 +0200 Message-Id: <1443908541-26513-1-git-send-email-maxime.hadjinlian@gmail.com> X-Mailer: git-send-email 2.5.3 Subject: [Buildroot] [PATCH] skeleton: Have a portable remount RW/RO X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" With systemd, inittab is useless, but it's also where we stored a 'mount -o remount ...' to toggle the rootfs ro/rw at the demand of the user. Instead, doing a simple 'mount -a -o remount' should change the flag of every mountpoint by reading /etc/fstab. Therefore, we now modify /etc/fstab, which happens to be read by systemd also and so, everyone benefits. Signed-off-by: Maxime Hadjinlian --- package/busybox/inittab | 3 +-- package/skeleton/skeleton.mk | 8 ++++---- package/sysvinit/inittab | 3 +-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/package/busybox/inittab b/package/busybox/inittab index b1892c1..2a6b5cf 100644 --- a/package/busybox/inittab +++ b/package/busybox/inittab @@ -15,10 +15,9 @@ # Startup the system null::sysinit:/bin/mount -t proc proc /proc -null::sysinit:/bin/mount -o remount,rw / null::sysinit:/bin/mkdir -p /dev/pts null::sysinit:/bin/mkdir -p /dev/shm -null::sysinit:/bin/mount -a +null::sysinit:/bin/mount -a -o remount null::sysinit:/bin/hostname -F /etc/hostname # now run any rc scripts ::sysinit:/etc/init.d/rcS diff --git a/package/skeleton/skeleton.mk b/package/skeleton/skeleton.mk index 48e7085..0409f2a 100644 --- a/package/skeleton/skeleton.mk +++ b/package/skeleton/skeleton.mk @@ -142,14 +142,14 @@ endif ifeq ($(BR2_INIT_BUSYBOX)$(BR2_INIT_SYSV),y) ifeq ($(BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW),y) -# Find commented line, if any, and remove leading '#'s +# Find 'ro,' (avoid 'root') in the first line and change it to 'rw,' define SKELETON_SYSTEM_REMOUNT_RW - $(SED) '/^#.*-o remount,rw \/$$/s~^#\+~~' $(TARGET_DIR)/etc/inittab + $(SED) 0,/ro\,/{s/ro\,/rw\,/} $(TARGET_DIR)/etc/fstab endef else -# Find uncommented line, if any, and add a leading '#' +# Find rw on the first line and change it to ro define SKELETON_SYSTEM_REMOUNT_RW - $(SED) '/^[^#].*-o remount,rw \/$$/s~^~#~' $(TARGET_DIR)/etc/inittab + $(SED) 0,/rw/{s/rw/ro/} $(TARGET_DIR)/etc/fstab endef endif TARGET_FINALIZE_HOOKS += SKELETON_SYSTEM_REMOUNT_RW diff --git a/package/sysvinit/inittab b/package/sysvinit/inittab index fc0c9b5..4b8cfd7 100644 --- a/package/sysvinit/inittab +++ b/package/sysvinit/inittab @@ -5,10 +5,9 @@ id:3:initdefault: si0::sysinit:/bin/mount -t proc proc /proc -si1::sysinit:/bin/mount -o remount,rw / si2::sysinit:/bin/mkdir -p /dev/pts si3::sysinit:/bin/mkdir -p /dev/shm -si4::sysinit:/bin/mount -a +si4::sysinit:/bin/mount -a -o remount si5::sysinit:/bin/hostname -F /etc/hostname si6::sysinit:/etc/init.d/rcS