fd-util: do not call statx() twice when it does not provide mount ID

Previously, in path_is_root_at(), if statx() does not provide mount ID,
path_get_mnt_id_at() was called, but it also calls statx(). Let's avoid
the second trial.
This commit is contained in:
Yu Watanabe
2023-07-22 02:22:06 +09:00
parent bd96111d5f
commit 68a4fc8b53
3 changed files with 17 additions and 8 deletions
+2 -2
View File
@@ -935,7 +935,7 @@ int path_is_root_at(int dir_fd, const char *path) {
if (!FLAGS_SET(st.nsx.stx_mask, STATX_MNT_ID)) {
int mntid;
r = path_get_mnt_id_at(dir_fd, "", &mntid);
r = path_get_mnt_id_at_fallback(dir_fd, "", &mntid);
if (r < 0) {
if (ERRNO_IS_NOT_SUPPORTED(r))
return true; /* skip the mount ID check */
@@ -950,7 +950,7 @@ int path_is_root_at(int dir_fd, const char *path) {
if (!FLAGS_SET(pst.nsx.stx_mask, STATX_MNT_ID)) {
int mntid;
r = path_get_mnt_id_at(dir_fd, "..", &mntid);
r = path_get_mnt_id_at_fallback(dir_fd, "..", &mntid);
if (r < 0) {
if (ERRNO_IS_NOT_SUPPORTED(r))
return true; /* skip the mount ID check */