control: tags -1 + patch Am 06.01.2015 um 10:37 schrieb Michael Biebl: > Am 06.01.2015 um 08:23 schrieb Martin Pitt: >> Also, I think there is a simpler way to check if a dir is a >> mountpoint: s1 = stat(dir), s2 = stat(parent(dir)) >> (i. e. dir + "/.."), and check >> >> is_mount = (st.st_dev != st2.st_dev) || >> (st.st_dev == st2.st_dev && st.st_ino == st2.st_ino); > > .. this seems simpler indeed. So let's just use that. Thanks for the hint! > >> That's the approach that /bin/mountpoint uses, and it avoids relying >> on having /etc/mtab, /proc mounted, and doing the iteration.
Updated patch attached (tested with a split-usr setup and with both initramfs-tools 0.116 and 0.118) -- Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?
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();
signature.asc
Description: OpenPGP digital signature

