MFV r357687: Import NFS fix for O_SEARCH tests
The version that ended upstream was ultimately slightly different than the version committed here; notably, statvfs() is used but it's redefined appropriately to statfs() on FreeBSD since we don't provide the fstypename for the former interface.
This commit is contained in:
parent
035000c596
commit
d3642b2b36
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: t_o_search.c,v 1.9 2020/02/06 12:18:06 martin Exp $ */
|
/* $NetBSD: t_o_search.c,v 1.10 2020/02/08 19:58:36 kamil Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2012 The NetBSD Foundation, Inc.
|
* Copyright (c) 2012 The NetBSD Foundation, Inc.
|
||||||
@ -29,16 +29,13 @@
|
|||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__RCSID("$NetBSD: t_o_search.c,v 1.9 2020/02/06 12:18:06 martin Exp $");
|
__RCSID("$NetBSD: t_o_search.c,v 1.10 2020/02/08 19:58:36 kamil Exp $");
|
||||||
|
|
||||||
#include <atf-c.h>
|
#include <atf-c.h>
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#ifdef __FreeBSD__
|
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
#else
|
|
||||||
#include <sys/statvfs.h>
|
#include <sys/statvfs.h>
|
||||||
#endif
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
@ -60,6 +57,11 @@ __RCSID("$NetBSD: t_o_search.c,v 1.9 2020/02/06 12:18:06 martin Exp $");
|
|||||||
#define USE_O_SEARCH
|
#define USE_O_SEARCH
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
#define statvfs statfs
|
||||||
|
#define fstatvfs fstatfs
|
||||||
|
#endif
|
||||||
|
|
||||||
#define DIR "dir"
|
#define DIR "dir"
|
||||||
#define FILE "dir/o_search"
|
#define FILE "dir/o_search"
|
||||||
#define BASEFILE "o_search"
|
#define BASEFILE "o_search"
|
||||||
@ -316,8 +318,9 @@ ATF_TC_HEAD(o_search_revokex, tc)
|
|||||||
}
|
}
|
||||||
ATF_TC_BODY(o_search_revokex, tc)
|
ATF_TC_BODY(o_search_revokex, tc)
|
||||||
{
|
{
|
||||||
int dfd, fd;
|
struct statvfs vst;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
|
int dfd, fd;
|
||||||
|
|
||||||
ATF_REQUIRE(mkdir(DIR, 0755) == 0);
|
ATF_REQUIRE(mkdir(DIR, 0755) == 0);
|
||||||
ATF_REQUIRE((fd = open(FILE, O_CREAT|O_RDWR, 0644)) != -1);
|
ATF_REQUIRE((fd = open(FILE, O_CREAT|O_RDWR, 0644)) != -1);
|
||||||
@ -327,23 +330,11 @@ ATF_TC_BODY(o_search_revokex, tc)
|
|||||||
|
|
||||||
/* Drop permissions. The kernel must still not check the exec bit. */
|
/* Drop permissions. The kernel must still not check the exec bit. */
|
||||||
ATF_REQUIRE(chmod(DIR, 0000) == 0);
|
ATF_REQUIRE(chmod(DIR, 0000) == 0);
|
||||||
{
|
|
||||||
const char *fstypename;
|
|
||||||
#ifdef __FreeBSD__
|
|
||||||
struct statfs st;
|
|
||||||
|
|
||||||
fstatfs(dfd, &st);
|
|
||||||
fstypename = st.f_fstypename;
|
|
||||||
#else
|
|
||||||
struct statvfs vst;
|
|
||||||
|
|
||||||
fstatvfs(dfd, &vst);
|
fstatvfs(dfd, &vst);
|
||||||
fstypename = vst.f_fstypename;
|
if (strcmp(vst.f_fstypename, "nfs") == 0)
|
||||||
#endif
|
atf_tc_expect_fail("NFS protocol cannot observe O_SEARCH semantics");
|
||||||
if (strcmp(fstypename, "nfs") == 0)
|
|
||||||
atf_tc_expect_fail(
|
|
||||||
"NFS protocol cannot observe O_SEARCH semantics");
|
|
||||||
}
|
|
||||||
ATF_REQUIRE(fstatat(dfd, BASEFILE, &sb, 0) == 0);
|
ATF_REQUIRE(fstatat(dfd, BASEFILE, &sb, 0) == 0);
|
||||||
|
|
||||||
ATF_REQUIRE(close(dfd) == 0);
|
ATF_REQUIRE(close(dfd) == 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user