]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
stat-util: add simpler helper for checking if /proc/ is mounted
authorLennart Poettering <lennart@poettering.net>
Thu, 23 Apr 2020 12:51:08 +0000 (14:51 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 23 Apr 2020 12:51:08 +0000 (14:51 +0200)
src/basic/stat-util.c
src/basic/stat-util.h

index 6a48af23ae6c9e6a35f51e86483d2c6d451328c9..1f3de56cf926781ba94da9682c98d3d516150710 100644 (file)
@@ -376,3 +376,15 @@ int device_path_parse_major_minor(const char *path, mode_t *ret_mode, dev_t *ret
 
         return 0;
 }
+
+int proc_mounted(void) {
+        int r;
+
+        /* A quick check of procfs is properly mounted */
+
+        r = path_is_fs_type("/proc/", PROC_SUPER_MAGIC);
+        if (r == -ENOENT) /* not mounted at all */
+                return false;
+
+        return r;
+}
index 7824af35006e5ed03b7a8296f6dd524f223532ce..81607483121d66839bd93346d88a6fc05f203c5a 100644 (file)
@@ -87,3 +87,5 @@ int fd_verify_directory(int fd);
 int device_path_make_major_minor(mode_t mode, dev_t devno, char **ret);
 int device_path_make_canonical(mode_t mode, dev_t devno, char **ret);
 int device_path_parse_major_minor(const char *path, mode_t *ret_mode, dev_t *ret_devno);
+
+int proc_mounted(void);