Commit b9782ef4 authored by Martin Pitt's avatar Martin Pitt
Browse files

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.

Closes: #742048
parent 7024b511
......@@ -16,6 +16,9 @@ systemd (215-9) UNRELEASED; urgency=medium
[ Michael Biebl ]
* sysv-generator: handle Provides: for non-virtual facility names.
(Closes: #774335)
* 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. (Closes: #742048)
-- Didier Roche <didrocks@ubuntu.com> Wed, 10 Dec 2014 13:57:17 +0100
......
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 847637a..82a1596 100644
--- a/src/remount-fs/remount-fs.c
+++ b/src/remount-fs/remount-fs.c
@@ -34,6 +34,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 */
@@ -83,6 +109,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();
......@@ -176,3 +176,4 @@ sysv-generator-Avoid-wrong-dependencies-for-failing-.patch
Prefer-etc-X11-default-display-manager-if-present.patch
core-Fix-bind-error-message.patch
core-Make-binding-notify-private-dbus-socket-more-ro.patch
Fix-usr-remount-failure-for-split-usr.patch
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment