mirror of
https://github.com/systemd/systemd.git
synced 2025-01-11 09:18:07 +03:00
systemd-tmpfiles: use statx_mount_same
It was pointed out in review that the preexisting code should be updated (https://github.com/systemd/systemd/pull/30380#discussion_r1426899180).
This commit is contained in:
parent
9e90d4f42e
commit
983dbcefe8
@ -571,7 +571,7 @@ static int opendir_and_stat(
|
||||
bool *ret_mountpoint) {
|
||||
|
||||
_cleanup_closedir_ DIR *d = NULL;
|
||||
STRUCT_STATX_DEFINE(sx);
|
||||
STRUCT_NEW_STATX_DEFINE(st1);
|
||||
int r;
|
||||
|
||||
assert(path);
|
||||
@ -598,26 +598,24 @@ static int opendir_and_stat(
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = statx_fallback(dirfd(d), "", AT_EMPTY_PATH, STATX_MODE|STATX_INO|STATX_ATIME|STATX_MTIME, &sx);
|
||||
r = statx_fallback(dirfd(d), "", AT_EMPTY_PATH, STATX_MODE|STATX_INO|STATX_ATIME|STATX_MTIME, &st1.sx);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "statx(%s) failed: %m", path);
|
||||
|
||||
if (FLAGS_SET(sx.stx_attributes_mask, STATX_ATTR_MOUNT_ROOT))
|
||||
*ret_mountpoint = FLAGS_SET(sx.stx_attributes, STATX_ATTR_MOUNT_ROOT);
|
||||
if (FLAGS_SET(st1.sx.stx_attributes_mask, STATX_ATTR_MOUNT_ROOT))
|
||||
*ret_mountpoint = FLAGS_SET(st1.sx.stx_attributes, STATX_ATTR_MOUNT_ROOT);
|
||||
else {
|
||||
struct stat ps;
|
||||
STRUCT_NEW_STATX_DEFINE(st2);
|
||||
|
||||
if (fstatat(dirfd(d), "..", &ps, AT_SYMLINK_NOFOLLOW) != 0)
|
||||
return log_error_errno(errno, "stat(%s/..) failed: %m", path);
|
||||
r = statx_fallback(dirfd(d), "..", 0, STATX_INO, &st2.sx);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "statx(%s/..) failed: %m", path);
|
||||
|
||||
*ret_mountpoint =
|
||||
sx.stx_dev_major != major(ps.st_dev) ||
|
||||
sx.stx_dev_minor != minor(ps.st_dev) ||
|
||||
sx.stx_ino != ps.st_ino;
|
||||
*ret_mountpoint = !statx_mount_same(&st1.nsx, &st2.nsx);
|
||||
}
|
||||
|
||||
*ret = TAKE_PTR(d);
|
||||
*ret_sx = sx;
|
||||
*ret_sx = st1.sx;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user