Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 Aug 2021 11:22:59 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 21edf70b8c87 - stable/13 - Add test for fstatat(pipefd, AT_EMPTY_PATH)
Message-ID:  <202108191122.17JBMxOx037096@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=21edf70b8c879cfdac21f8ad43f23eb468b5e7de

commit 21edf70b8c879cfdac21f8ad43f23eb468b5e7de
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2021-08-14 10:33:18 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2021-08-19 11:21:57 +0000

    Add test for fstatat(pipefd, AT_EMPTY_PATH)
    
    (cherry picked from commit b42df9dafb8038169e23f9225f3f1588ded8d27e)
---
 tests/sys/file/path_test.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/tests/sys/file/path_test.c b/tests/sys/file/path_test.c
index e1f5240374c4..50a77f16736c 100644
--- a/tests/sys/file/path_test.c
+++ b/tests/sys/file/path_test.c
@@ -63,6 +63,25 @@
 #define	CHECKED_CLOSE(fd)	\
 	ATF_REQUIRE_MSG(close(fd) == 0, FMT_ERR("close"))
 
+/*
+ * Verify fstatat(AT_EMPTY_PATH) on non-regular dirfd.
+ * Verify that fstatat(AT_EMPTY_PATH) on NULL path returns EFAULT.
+ */
+ATF_TC_WITHOUT_HEAD(path_pipe_fstatat);
+ATF_TC_BODY(path_pipe_fstatat, tc)
+{
+	struct stat sb;
+  	int fd[2];
+
+	ATF_REQUIRE_MSG(pipe(fd) == 0, FMT_ERR("pipe"));
+	ATF_REQUIRE_MSG(fstatat(fd[0], "", &sb, AT_EMPTY_PATH) == 0,
+	    FMT_ERR("fstatat pipe"));
+	ATF_REQUIRE_ERRNO(EFAULT, fstatat(fd[0], NULL, &sb,
+	    AT_EMPTY_PATH) == -1);
+	CHECKED_CLOSE(fd[0]);
+	CHECKED_CLOSE(fd[1]);
+}
+
 /* Create a temporary regular file containing some data. */
 static void
 mktfile(char path[PATH_MAX], const char *template)
@@ -873,6 +892,7 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, path_lock);
 	ATF_TP_ADD_TC(tp, path_rights);
 	ATF_TP_ADD_TC(tp, path_unix);
+	ATF_TP_ADD_TC(tp, path_pipe_fstatat);
 
 	return (atf_no_error());
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202108191122.17JBMxOx037096>