Skip to content

Commit

Permalink
Hopefully fix compile on SmartOS
Browse files Browse the repository at this point in the history
Don't assume that we have struct dirent.d_type, because on SmartOS we don't.
  • Loading branch information
qris committed Jan 23, 2017
1 parent 8eefaee commit 31d129f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions infrastructure/cmake/CMakeLists.txt
Expand Up @@ -560,6 +560,11 @@ endforeach()
check_symbol_exists(dirfd "dirent.h" HAVE_DECL_DIRFD)
file(APPEND "${boxconfig_h_file}" "#cmakedefine01 HAVE_DECL_DIRFD\n")

if(WIN32)
# We emulate this in lib/win32, so we know it's present:
file(APPEND "${boxconfig_h_file}" "#define HAVE_VALID_DIRENT_D_TYPE 1\n")
endif()

# Emulate ax_check_mount_point.m4
# These checks are run by multi-line M4 commands which are harder to parse/fake using
# regexps above, so we hard-code them here:
Expand Down
7 changes: 7 additions & 0 deletions lib/httpserver/S3Simulator.cpp
Expand Up @@ -547,7 +547,12 @@ void S3Simulator::HandleListObjects(const std::string& bucket_name,
ASSERT(prefix == "" || EndsWith("/", prefix));
std::string object_name = prefix + entry_name;

#ifdef HAVE_VALID_DIRENT_D_TYPE
if(p_dirent->d_type == DT_UNKNOWN)
#else
// Always use this branch if we don't have struct dirent.d_type:
if(true)
#endif
{
int entry_type = ObjectExists(entry_path);
if(entry_type == ObjectExists_File)
Expand All @@ -565,6 +570,7 @@ void S3Simulator::HandleListObjects(const std::string& bucket_name,
continue;
}
}
#ifdef HAVE_VALID_DIRENT_D_TYPE
else if(p_dirent->d_type == DT_REG)
{
object_name_to_type[object_name] = ObjectExists_File;
Expand All @@ -573,6 +579,7 @@ void S3Simulator::HandleListObjects(const std::string& bucket_name,
{
object_name_to_type[object_name] = ObjectExists_Dir;
}
#endif // HAVE_VALID_DIRENT_D_TYPE
else
{
continue;
Expand Down

0 comments on commit 31d129f

Please sign in to comment.