libudev-monitor: rename udev_has_devtmpfs() and move it to mount-util.c
As the function itself is quite generic.
This commit is contained in:
@@ -951,3 +951,39 @@ int mount_option_mangle(
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dev_is_devtmpfs(void) {
|
||||
_cleanup_fclose_ FILE *proc_self_mountinfo = NULL;
|
||||
char line[LINE_MAX], *e;
|
||||
int mount_id, r;
|
||||
|
||||
r = path_get_mnt_id("/dev", &mount_id);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
proc_self_mountinfo = fopen("/proc/self/mountinfo", "re");
|
||||
if (!proc_self_mountinfo)
|
||||
return -errno;
|
||||
|
||||
(void) __fsetlocking(proc_self_mountinfo, FSETLOCKING_BYCALLER);
|
||||
|
||||
FOREACH_LINE(line, proc_self_mountinfo, return -errno) {
|
||||
int mid;
|
||||
|
||||
if (sscanf(line, "%i", &mid) != 1)
|
||||
continue;
|
||||
|
||||
if (mid != mount_id)
|
||||
continue;
|
||||
|
||||
e = strstr(line, " - ");
|
||||
if (!e)
|
||||
continue;
|
||||
|
||||
/* accept any name that starts with the currently expected type */
|
||||
if (startswith(e + 3, "devtmpfs"))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -54,3 +54,5 @@ int mount_option_mangle(
|
||||
unsigned long mount_flags,
|
||||
unsigned long *ret_mount_flags,
|
||||
char **ret_remaining_options);
|
||||
|
||||
int dev_is_devtmpfs(void);
|
||||
|
||||
Reference in New Issue
Block a user