systemd/debian/patches/Fix-usr-remount-failure-for-split-usr.patch
Martin Pitt 11e8737306 New upstream release 220
- Ship sdio.ids and ids-update.pl in upstream tarball. (Closes: #780650)
  - Drop non-working "journalctl /dev/sda" example from manpage
    (Closes: #781604)
  - man systemd.network: Explain UseDomains a bit more (not used by
    default). (Closes: #766413)
  - Ignore comments in /etc/hostname (LP: #766413)
  - Drop all backported patches and port the others to new upstream release.

TODO: Port path_is_mount_point-handle-false-positive-on-some-fs.patch
2015-05-25 19:50:53 +02:00

65 lines
2.0 KiB
Diff

From: Michael Biebl <biebl@debian.org>
Date: Tue, 13 Jan 2015 08:25:00 +0100
Subject: Fix /usr remount failure for split /usr
Fix systemd-remount-fs.service to not fail on remounting /usr if /usr isn't
mounted yet. This happens with initramfs-tools < 0.118 which we might not get
into Jessie any more.
This can be dropped when /usr always gets mounted from initramfs.
Bug-Debian: https://bugs.debian.org/742048
---
src/remount-fs/remount-fs.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/src/remount-fs/remount-fs.c b/src/remount-fs/remount-fs.c
index a09531b..e47851b 100644
--- a/src/remount-fs/remount-fs.c
+++ b/src/remount-fs/remount-fs.c
@@ -32,6 +32,32 @@
#include "mount-setup.h"
#include "exit-status.h"
+static bool is_mounted(const char *dev_path) {
+ _cleanup_free_ char *parent_path = NULL;
+ struct stat st, pst;
+ int r;
+
+ parent_path = strjoin(dev_path, "/..", NULL);
+
+ r = stat(dev_path, &st);
+ if (r < 0)
+ return false;
+
+ r = stat(parent_path, &pst);
+ if (r < 0)
+ return false;
+
+ /*
+ * This code to check if a given path is a mountpoint is
+ * borrowed from util-linux' mountpoint tool.
+ */
+ if ((st.st_dev != pst.st_dev) ||
+ (st.st_dev == pst.st_dev && st.st_ino == pst.st_ino))
+ return true;
+
+ return false;
+}
+
/* Goes through /etc/fstab and remounts all API file systems, applying
* options that are in /etc/fstab that systemd might not have
* respected */
@@ -81,6 +107,11 @@ int main(int argc, char *argv[]) {
!path_equal(me->mnt_dir, "/usr"))
continue;
+ /* Skip /usr if it hasn't been mounted by the initrd */
+ if (path_equal(me->mnt_dir, "/usr") &&
+ !is_mounted("/usr"))
+ continue;
+
log_debug("Remounting %s", me->mnt_dir);
pid = fork();