path_test: Verify that operations on unlinked files work
MFC after: 1 week Sponsored by: The FreeBSD Foundation
This commit is contained in:
parent
081b4452a7
commit
b13ac67842
@ -900,6 +900,38 @@ ATF_TC_BODY(path_unix, tc)
|
||||
CHECKED_CLOSE(pathfd);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check that we can perform operations using an O_PATH fd for an unlinked file.
|
||||
*/
|
||||
ATF_TC_WITHOUT_HEAD(path_unlinked);
|
||||
ATF_TC_BODY(path_unlinked, tc)
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
struct stat sb;
|
||||
int pathfd;
|
||||
|
||||
mktfile(path, "path_rights.XXXXXX");
|
||||
|
||||
pathfd = open(path, O_PATH);
|
||||
ATF_REQUIRE_MSG(pathfd >= 0, FMT_ERR("open"));
|
||||
|
||||
ATF_REQUIRE_MSG(fstatat(pathfd, "", &sb, AT_EMPTY_PATH) == 0,
|
||||
FMT_ERR("fstatat"));
|
||||
ATF_REQUIRE(sb.st_nlink == 1);
|
||||
ATF_REQUIRE_MSG(fstat(pathfd, &sb) == 0, FMT_ERR("fstat"));
|
||||
ATF_REQUIRE(sb.st_nlink == 1);
|
||||
|
||||
ATF_REQUIRE_MSG(unlink(path) == 0, FMT_ERR("unlink"));
|
||||
|
||||
ATF_REQUIRE_MSG(fstatat(pathfd, "", &sb, AT_EMPTY_PATH) == 0,
|
||||
FMT_ERR("fstatat"));
|
||||
ATF_REQUIRE(sb.st_nlink == 0);
|
||||
ATF_REQUIRE_MSG(fstat(pathfd, &sb) == 0, FMT_ERR("fstat"));
|
||||
ATF_REQUIRE(sb.st_nlink == 0);
|
||||
|
||||
CHECKED_CLOSE(pathfd);
|
||||
}
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
ATF_TP_ADD_TC(tp, path_access);
|
||||
@ -922,6 +954,7 @@ ATF_TP_ADD_TCS(tp)
|
||||
ATF_TP_ADD_TC(tp, path_pipe_fstatat);
|
||||
ATF_TP_ADD_TC(tp, path_rights);
|
||||
ATF_TP_ADD_TC(tp, path_unix);
|
||||
ATF_TP_ADD_TC(tp, path_unlinked);
|
||||
|
||||
return (atf_no_error());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user