]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - util.c
managemon: fix typo affecting incrmental assembly.
[thirdparty/mdadm.git] / util.c
diff --git a/util.c b/util.c
index 3965f437a895b63a22917a759f57746fbc3ad3ff..aa2c8be87dfbf17763633513e6087052b72bc9e8 100644 (file)
--- a/util.c
+++ b/util.c
@@ -29,6 +29,8 @@
 #include       <sys/wait.h>
 #include       <sys/un.h>
 #include       <sys/resource.h>
+#include       <sys/vfs.h>
+#include       <linux/magic.h>
 #include       <ctype.h>
 #include       <dirent.h>
 #include       <signal.h>
@@ -1937,3 +1939,12 @@ void enable_fds(int devices)
        lim.rlim_cur = fds;
        setrlimit(RLIMIT_NOFILE, &lim);
 }
+
+int in_initrd(void)
+{
+       /* This is based on similar function in systemd. */
+       struct statfs s;
+       return  statfs("/", &s) >= 0 &&
+               (s.f_type == TMPFS_MAGIC ||
+                s.f_type == RAMFS_MAGIC);
+}