summaryrefslogtreecommitdiff
path: root/src/shared/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/util.c')
-rw-r--r--src/shared/util.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index 53185403d6..681484bc0f 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -5639,3 +5639,18 @@ bool is_valid_documentation_url(const char *url) {
return false;
}
+
+bool in_initrd(void) {
+ static bool checked=false;
+ static bool is_in_initrd=false;
+
+ if (!checked) {
+ struct stat sb;
+ if (stat("/", &sb) == 0) {
+ is_in_initrd = (sb.st_dev == 1);
+ checked = true;
+ }
+ }
+
+ return is_in_initrd;
+}