git: 5e96f4006d2e - main - opendir: Simplify is_unionstack().
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 02 Jul 2025 10:23:04 UTC
The branch main has been updated by des:
URL: https://cgit.FreeBSD.org/src/commit/?id=5e96f4006d2e5f165531a53b6c1393a1c7604f42
commit 5e96f4006d2e5f165531a53b6c1393a1c7604f42
Author: Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2025-07-02 10:22:21 +0000
Commit: Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2025-07-02 10:22:29 +0000
opendir: Simplify is_unionstack().
Sponsored by: Klara, Inc.
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D51118
---
lib/libc/gen/opendir2.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/lib/libc/gen/opendir2.c b/lib/libc/gen/opendir2.c
index 30a9030693e4..b9ac23e6d9fd 100644
--- a/lib/libc/gen/opendir2.c
+++ b/lib/libc/gen/opendir2.c
@@ -243,20 +243,18 @@ _filldir(DIR *dirp, bool use_current_pos)
return (true);
}
+/*
+ * Return true if the file descriptor is associated with a file from a
+ * union file system or from a file system mounted with the union flag.
+ */
static bool
is_unionstack(int fd)
{
- int unionstack;
-
- unionstack = _fcntl(fd, F_ISUNIONSTACK, 0);
- if (unionstack != -1)
- return (unionstack);
-
/*
- * Should not happen unless running on a kernel without the op,
- * but no use rendering the system useless in such a case.
+ * This call shouldn't fail, but if it does, just assume that the
+ * answer is no.
*/
- return (0);
+ return (_fcntl(fd, F_ISUNIONSTACK, 0) > 0);
}
/*