From 30780a73053d968460cbe9595f8024de07460c4e Mon Sep 17 00:00:00 2001 From: Luis Hector Chavez Date: Wed, 14 Feb 2018 08:36:16 -0800 Subject: [PATCH] init.rc: Remount / with MS_REMOUNT|MS_BIND Since we only want to change the ro flag on / (and leave all other mount flags alone), this can also be achieved by passing MS_REMOUNT|MS_BIND, even if the mount is not a bind-mount. This aims to make running Android within a user namespace easier, since remounts without the MS_BIND flag are forbidden. Bug: 73255020 Test: aosp_sailfish still boots Test: rootfs on / type rootfs (rw,seclabel) /dev/root on / type ext4 (ro,seclabel,relatime,data=ordered) Change-Id: I2f89a8badfc467db47304c9355648e8fd8ad1272 --- rootdir/init.rc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rootdir/init.rc b/rootdir/init.rc index f008c1748..da3f82454 100644 --- a/rootdir/init.rc +++ b/rootdir/init.rc @@ -318,8 +318,9 @@ on post-fs start hwservicemanager start vndservicemanager - # once everything is setup, no need to modify / - mount rootfs rootfs / ro remount + # Once everything is setup, no need to modify /. + # The bind+ro combination avoids modifying any other mount flags. + mount rootfs rootfs / remount bind ro # Mount shared so changes propagate into child namespaces mount rootfs rootfs / shared rec # Mount default storage into root namespace