mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
fd-util: make path_is_root_at() not fail even when /proc is mounted
path_get_mnt_id_at() -> fd_fdinfo_mnt_id() may return -EOPNOTSUPP when /proc is mounted, and -ENOSYS otherwise, when an old kernel is used.
This commit is contained in:
parent
7487115766
commit
bd96111d5f
@ -929,17 +929,18 @@ int path_is_root_at(int dir_fd, const char *path) {
|
||||
* $ mount --bind /tmp/x /tmp/x/y
|
||||
*
|
||||
* Note, statx() does not provide the mount ID and path_get_mnt_id_at() does not work when an old
|
||||
* kernel is used without /proc mounted. In that case, let's assume that we do not have such spurious
|
||||
* mount points in an early boot stage, and silently skip the following check. */
|
||||
* kernel is used. In that case, let's assume that we do not have such spurious mount points in an
|
||||
* early boot stage, and silently skip the following check. */
|
||||
|
||||
if (!FLAGS_SET(st.nsx.stx_mask, STATX_MNT_ID)) {
|
||||
int mntid;
|
||||
|
||||
r = path_get_mnt_id_at(dir_fd, "", &mntid);
|
||||
if (r == -ENOSYS)
|
||||
return true; /* skip the mount ID check */
|
||||
if (r < 0)
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_NOT_SUPPORTED(r))
|
||||
return true; /* skip the mount ID check */
|
||||
return r;
|
||||
}
|
||||
assert(mntid >= 0);
|
||||
|
||||
st.nsx.stx_mnt_id = mntid;
|
||||
@ -950,10 +951,11 @@ int path_is_root_at(int dir_fd, const char *path) {
|
||||
int mntid;
|
||||
|
||||
r = path_get_mnt_id_at(dir_fd, "..", &mntid);
|
||||
if (r == -ENOSYS)
|
||||
return true; /* skip the mount ID check */
|
||||
if (r < 0)
|
||||
if (r < 0) {
|
||||
if (ERRNO_IS_NOT_SUPPORTED(r))
|
||||
return true; /* skip the mount ID check */
|
||||
return r;
|
||||
}
|
||||
assert(mntid >= 0);
|
||||
|
||||
pst.nsx.stx_mnt_id = mntid;
|
||||
|
Loading…
Reference in New Issue
Block a user