Changeset View
Changeset View
Standalone View
Standalone View
head/tests/sys/fs/fusefs/utils.cc
Show First 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
const uint32_t default_max_write = MIN(libfuse_max_write, MAXPHYS / 2); | const uint32_t default_max_write = MIN(libfuse_max_write, MAXPHYS / 2); | ||||
/* Check that fusefs(4) is accessible and the current user can mount(2) */ | /* Check that fusefs(4) is accessible and the current user can mount(2) */ | ||||
void check_environment() | void check_environment() | ||||
{ | { | ||||
const char *devnode = "/dev/fuse"; | const char *devnode = "/dev/fuse"; | ||||
const char *bsdextended_node = "security.mac.bsdextended.enabled"; | |||||
int bsdextended_val = 0; | |||||
size_t bsdextended_size = sizeof(bsdextended_val); | |||||
int bsdextended_found; | |||||
const char *usermount_node = "vfs.usermount"; | const char *usermount_node = "vfs.usermount"; | ||||
int usermount_val = 0; | int usermount_val = 0; | ||||
size_t usermount_size = sizeof(usermount_val); | size_t usermount_size = sizeof(usermount_val); | ||||
if (eaccess(devnode, R_OK | W_OK)) { | if (eaccess(devnode, R_OK | W_OK)) { | ||||
if (errno == ENOENT) { | if (errno == ENOENT) { | ||||
GTEST_SKIP() << devnode << " does not exist"; | GTEST_SKIP() << devnode << " does not exist"; | ||||
} else if (errno == EACCES) { | } else if (errno == EACCES) { | ||||
GTEST_SKIP() << devnode << | GTEST_SKIP() << devnode << | ||||
" is not accessible by the current user"; | " is not accessible by the current user"; | ||||
} else { | } else { | ||||
GTEST_SKIP() << strerror(errno); | GTEST_SKIP() << strerror(errno); | ||||
} | } | ||||
} | } | ||||
// mac_bsdextended(4), when enabled, generates many more GETATTR | |||||
// operations. The fusefs tests' expectations don't account for those, | |||||
// and adding extra code to handle them obfuscates the real purpose of | |||||
// the tests. Better just to skip the fusefs tests if mac_bsdextended | |||||
// is enabled. | |||||
bsdextended_found = sysctlbyname(bsdextended_node, &bsdextended_val, | |||||
&bsdextended_size, NULL, 0); | |||||
if (bsdextended_found == 0 && bsdextended_val != 0) | |||||
GTEST_SKIP() << | |||||
"The fusefs tests are incompatible with mac_bsdextended."; | |||||
ASSERT_EQ(sysctlbyname(usermount_node, &usermount_val, &usermount_size, | ASSERT_EQ(sysctlbyname(usermount_node, &usermount_val, &usermount_size, | ||||
NULL, 0), | NULL, 0), | ||||
0);; | 0); | ||||
if (geteuid() != 0 && !usermount_val) | if (geteuid() != 0 && !usermount_val) | ||||
GTEST_SKIP() << "current user is not allowed to mount"; | GTEST_SKIP() << "current user is not allowed to mount"; | ||||
} | } | ||||
const char *cache_mode_to_s(enum cache_mode cm) { | const char *cache_mode_to_s(enum cache_mode cm) { | ||||
switch (cm) { | switch (cm) { | ||||
case Uncached: | case Uncached: | ||||
return "Uncached"; | return "Uncached"; | ||||
▲ Show 20 Lines • Show All 527 Lines • Show Last 20 Lines |