File respect_ro_bootparam.patch of Package systemd.1472
Index: systemd-210/src/remount-fs/remount-fs.c
===================================================================
--- systemd-210.orig/src/remount-fs/remount-fs.c
+++ systemd-210/src/remount-fs/remount-fs.c
@@ -38,6 +38,27 @@
* options that are in /etc/fstab that systemd might not have
* respected */
+static int check_ro_from_cmdline(void) {
+ _cleanup_free_ char *line = NULL;
+ int r;
+
+ /* check for 'ro' boot parameter */
+ r = read_one_line_file("/proc/cmdline", &line);
+ if (r >= 0) {
+ char *w, *state;
+ size_t l;
+
+ FOREACH_WORD_QUOTED(w, l, line, state) {
+ if (l == 2 && memcmp(w, "ro", 2) == 0) {
+ return 1;
+ break;
+ }
+ }
+ }
+ return 0;
+}
+
+
int main(int argc, char *argv[]) {
int ret = EXIT_FAILURE;
_cleanup_endmntent_ FILE *f = NULL;
@@ -99,7 +120,10 @@ int main(int argc, char *argv[]) {
arguments[0] = "/bin/mount";
arguments[1] = me->mnt_dir;
arguments[2] = "-o";
- arguments[3] = "remount";
+ if (check_ro_from_cmdline() && (path_equal(me->mnt_dir, "/") || path_equal(me->mnt_dir, "/usr")))
+ arguments[3] = "remount,ro";
+ else
+ arguments[3] = "remount";
arguments[4] = NULL;
execv("/bin/mount", (char **) arguments);