1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-25 01:34:28 +03:00

mountpoint-util: check /proc is mounted on failure

This commit is contained in:
Yu Watanabe 2023-04-17 23:26:47 +09:00
parent 9a0dcf03fa
commit 4b1e461c49

View File

@ -123,7 +123,7 @@ static int fd_fdinfo_mnt_id(int fd, const char *filename, int flags, int *ret_mn
r = read_full_virtual_file(path, &fdinfo, NULL); r = read_full_virtual_file(path, &fdinfo, NULL);
if (r == -ENOENT) /* The fdinfo directory is a relatively new addition */ if (r == -ENOENT) /* The fdinfo directory is a relatively new addition */
return -EOPNOTSUPP; return proc_mounted() > 0 ? -EOPNOTSUPP : -ENOSYS;
if (r < 0) if (r < 0)
return r; return r;
@ -280,7 +280,7 @@ int fd_is_mount_point(int fd, const char *filename, int flags) {
fallback_fdinfo: fallback_fdinfo:
r = fd_fdinfo_mnt_id(fd, filename, flags, &mount_id); r = fd_fdinfo_mnt_id(fd, filename, flags, &mount_id);
if (IN_SET(r, -EOPNOTSUPP, -EACCES, -EPERM)) if (IN_SET(r, -EOPNOTSUPP, -EACCES, -EPERM, -ENOSYS))
goto fallback_fstat; goto fallback_fstat;
if (r < 0) if (r < 0)
return r; return r;
@ -549,6 +549,8 @@ int dev_is_devtmpfs(void) {
return r; return r;
r = fopen_unlocked("/proc/self/mountinfo", "re", &proc_self_mountinfo); r = fopen_unlocked("/proc/self/mountinfo", "re", &proc_self_mountinfo);
if (r == -ENOENT)
return proc_mounted() > 0 ? -ENOENT : -ENOSYS;
if (r < 0) if (r < 0)
return r; return r;