stat-util: add simpler helper for checking if /proc/ is mounted

This commit is contained in:
Lennart Poettering 2020-04-23 14:51:08 +02:00
parent 6d965610bd
commit 883fff25f4
2 changed files with 14 additions and 0 deletions

View 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;
}

View 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);