systemd: fix remount-fs (Andr? Erdmann)
PATCH 1/1 systemd: fix remount-fs (Andr? Erdmann)
Hi Andre, list,
This is a reply to a digest mail, I hope it doesn't break stuff, but
the following fixes an
issue I ran into so I feel like I should reply with a tested by.
Quoted 15 lines
Date: Wed, 12 Nov 2014 19:01:06 +0100
From: Andr? Erdmann <[email protected]>
To: buildroot at buildroot.org
Subject: [Buildroot] [RFC/PATCH 1/1] systemd: fix remount-fs
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8systemd runs "
/bin/mountMOUNTPOINT -o remount" for remounting the rootfs (and others like /usr, /proc, ...) [0]. This is supposed to remount the rootfs in rw/ro mode depending on/etc/fstab.busybox' mount -o remount command, however, complety ignores fstab and reads the mount options from
/proc/mountsonly (+ cmdline "-o ...") [1], so "mount / -o remount" is a no-op.
Quoted 8 lines
This commit adds a patch that causes systemd's remount-fs to pass the options from
/etc/fstabto the mount command.References:
[0] http://cgit.freedesktop.org/systemd/systemd/tree/src/remount-fs/remount-fs.c?id=v217 (line 99)
[1] http://git.busybox.net/busybox/tree/util-linux/mount.c?h=1_22_stable (line 2133)Signed-off-by Andr? Erdmann <[email protected]>
Quoted 98 lines
---
Notes:
* selecting BR2_PACKAGE_UTIL_LINUX_MOUNT=y would also fix remounting, but that also requires BR2_PACKAGE_UTIL_LINUX_BINARIES=y...* passing all options to mount rather than checking for "rw"/ro" (hasmntopt(...,"ro")==NULL) makes remount-fs behave identical regardless of whether util-linux' or busybox' mount is used (remount-fs also remounts /proc etc.)
* a systemd-based buildroot config ignores
BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RWThis is not changed by this commit, but the rootfs is now always rw unless/etc/fstabgets replaced by a a postbuild script / rootfs overlay.By the way, I have a script for generating
/etc/fstab, which could be useful for dealing with remount-ro/rw and systemd-specific mounts (and maybe genimages). Tell me if there's any interest in getting this integrated into buildroot.You can view it here
https://gist.github.com/dywisor/62d41835c2dff043f794#file-mkfstab-bash-L17-L96
(not the latest revision, but sufficient for getting an overview.)--- ...t-fs-pass-options-from-fstab-to-bin-mount.patch | 63 ++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 package/systemd/0005-remount-fs-pass-options-from-fstab-to-bin-mount.patchpackage/systemd/0005-remount-fs-pass-options-from-fstab-to-bin-mount.patch new file +63
-1@@ -0,0 +1,63 @@ +From 7bc0901a00e78f22f97dbd3f85c7a19d9a78e7a1 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Andr=C3=A9=20Erdmann?= <[email protected]> +Date: Wed, 12 Nov 2014 17:45:46 +0100 +Subject: [PATCH 1/1] remount-fs: pass options from fstab to /bin/mount +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +busybox mount -o remount reads the mount options from /proc/mounts (or mtab); +Executing "/bin/mount / -o remount" has no effect when /bin/mount is linked +to busybox. + +remount-fs already reads the options from /etc/fstab, +so simply pass them to the mount command. + +Signed-off-by: Andr? Erdmann <[email protected]> +--- + src/remount-fs/remount-fs.c | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +diff --git a/src/remount-fs/remount-fs.c b/src/remount-fs/remount-fs.c +index cd7cfe7..f63f009 100644 +--- a/src/remount-fs/remount-fs.c ++++ b/src/remount-fs/remount-fs.c +@@ -20,6 +20,7 @@ + ***/ + + #include <unistd.h> ++#include <stdlib.h> + #include <fcntl.h> + #include <errno.h> + #include <string.h> +@@ -93,18 +94,26 @@ int main(int argc, char *argv[]) { + } + + if (pid == 0) { ++ char *opts_str; + const char *arguments[5]; + /* Child */ + ++ opts_str = strappend("remount,", me->mnt_opts); ++ if (opts_str == NULL) { ++ log_error("Failed to get remount opts"); ++ _exit(EXIT_FAILURE); ++ } ++ + arguments[0] = "/bin/mount"; + arguments[1] = me->mnt_dir; + arguments[2] = "-o"; +- arguments[3] = "remount"; ++ arguments[3] = opts_str; + arguments[4] = NULL; + + execv("/bin/mount", (char **) arguments); + + log_error("Failed to execute /bin/mount: %m"); ++ free(opts_str); + _exit(EXIT_FAILURE); + } + +-- +2.1.3 + --2.1.3
PATCH 1/1 systemd: fix remount-fs (Andr? Erdmann)
Eric, All,
On 2014-11-15 08:45 +0100, Eric Limpens spake thusly:
Quoted 5 lines
Hi Andre, list,
This is a reply to a digest mail, I hope it doesn't break stuff, but
the following fixes an
issue I ran into so I feel like I should reply with a tested by.
Yes, it broke it. Patchwork did not catch your tested tag.
Quoted 1 line
Tested-by Eric Limpens <[email protected]>
If you don't mind, I'll post ot for you.
Regards,
Yann E. MORIN.
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'