Skip to content

Commit

Permalink
path_test: adjust test for open(O_PATH | O_CREAT)
Browse files Browse the repository at this point in the history
Instead of failing, it must succeed now.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D48332
  • Loading branch information
kostikbel committed Jan 7, 2025
1 parent cc0d806 commit 749b3b2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/sys/file/path_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -684,10 +684,14 @@ ATF_TC_BODY(path_io, tc)
size_t page_size;
int error, fd, pathfd, sd[2];

/* It shouldn't be possible to create new files with O_PATH. */
/* It is allowed to create new files with O_PATH. */
snprintf(path, sizeof(path), "path_io.XXXXXX");
ATF_REQUIRE_MSG(mktemp(path) == path, FMT_ERR("mktemp"));
ATF_REQUIRE_ERRNO(ENOENT, open(path, O_PATH | O_CREAT, 0600) < 0);
pathfd = open(path, O_PATH | O_CREAT, 0600);
ATF_REQUIRE_MSG(pathfd >= 0, FMT_ERR("open(O_PATH|O_CREAT)"));
/* Ensure that this is indeed O_PATH fd */
ATF_REQUIRE_ERRNO(EBADF, write(pathfd, path, strlen(path)) == -1);
CHECKED_CLOSE(pathfd);

/* Create a non-empty file for use in the rest of the tests. */
mktfile(path, "path_io.XXXXXX");
Expand Down

0 comments on commit 749b3b2

Please sign in to comment.