From patchwork Sun Oct 4 13:39:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Hadjinlian X-Patchwork-Id: 526155 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ozlabs.org (Postfix) with ESMTP id C349B1402B6 for ; Mon, 5 Oct 2015 00:40:13 +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=pHaC+rH2; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id EBCF831A20; Sun, 4 Oct 2015 13:40:12 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8gxWIhkP8W0C; Sun, 4 Oct 2015 13:40:11 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 7D63E30FE9; Sun, 4 Oct 2015 13:40:11 +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 53D1A1C1034 for ; Sun, 4 Oct 2015 13:40:10 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 4EEED88D24 for ; Sun, 4 Oct 2015 13:40:10 +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 6s+4HkUtF8wh for ; Sun, 4 Oct 2015 13:40:09 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wi0-f171.google.com (mail-wi0-f171.google.com [209.85.212.171]) by whitealder.osuosl.org (Postfix) with ESMTPS id 56C1F88C96 for ; Sun, 4 Oct 2015 13:40:09 +0000 (UTC) Received: by wicgb1 with SMTP id gb1so86413829wic.1 for ; Sun, 04 Oct 2015 06:40:08 -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=B0HGBrLD4LOBOMxYet/dqmc9QUHzQNXig2Gx2yf2ozI=; b=pHaC+rH28nDWSs3u2wh8x/vS/+OdT35wugPjk2eH9ab9jAJT3Lixu6+vzbQdCijJNr Z4V3OMwGwLyS25QywZS5uMFw91HD7APqj6gRlP2QTsXobfudxk83lJCXvgq2aSgvjBbQ dAeM5JkA3grX5+QCLnaHJyBTKvmFOxDyFUj24CfTerYbc3iRgjfM3GQEYTdHllQ3hpsI +GxcwRVAwg4DNQU5WHsDvdhSCcKmOBt1HT6bNeRleNzFKN1SThFFPtTjYHujAsIglfid 09+0u07ooo0utWbf5aPxGqcGBVg4E62XoRXzbOJtf0zPXuH0Mbo365p9Pj10ViVvoXHO lH7g== X-Received: by 10.194.143.102 with SMTP id sd6mr29482645wjb.15.1443966007961; Sun, 04 Oct 2015 06:40:07 -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 fu5sm12872165wic.0.2015.10.04.06.39.51 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 04 Oct 2015 06:40:06 -0700 (PDT) From: Maxime Hadjinlian To: buildroot@busybox.net Date: Sun, 4 Oct 2015 15:39:08 +0200 Message-Id: <1443965948-13945-1-git-send-email-maxime.hadjinlian@gmail.com> X-Mailer: git-send-email 2.5.3 Subject: [Buildroot] [PATCH v2] 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 --- v1 -> v2: - Rebase on current master ('null' was removed from inittab) - 'Rework' sed expression (add quote, remove curly braces, remove useless escape of comma) --- 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 24d9199..7202474 100644 --- a/package/busybox/inittab +++ b/package/busybox/inittab @@ -15,10 +15,9 @@ # Startup the system ::sysinit:/bin/mount -t proc proc /proc -::sysinit:/bin/mount -o remount,rw / ::sysinit:/bin/mkdir -p /dev/pts ::sysinit:/bin/mkdir -p /dev/shm -::sysinit:/bin/mount -a +::sysinit:/bin/mount -a -o remount ::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..ae8f429 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