diff --git a/include/llfio/revision.hpp b/include/llfio/revision.hpp
index 6a3fa7ce..e047a474 100644
--- a/include/llfio/revision.hpp
+++ b/include/llfio/revision.hpp
@@ -1,4 +1,4 @@
// Note the second line of this file must ALWAYS be the git SHA, third line ALWAYS the git SHA update time
-#define LLFIO_PREVIOUS_COMMIT_REF dfe95ff5e36c495df11f9a4420ddeb866be4d658
-#define LLFIO_PREVIOUS_COMMIT_DATE "2024-08-20 07:56:43 +00:00"
-#define LLFIO_PREVIOUS_COMMIT_UNIQUE dfe95ff5
+#define LLFIO_PREVIOUS_COMMIT_REF 938b8456e9d575c4455ddeca5fbe808c040b8c88
+#define LLFIO_PREVIOUS_COMMIT_DATE "2024-08-20 11:29:01 +00:00"
+#define LLFIO_PREVIOUS_COMMIT_UNIQUE 938b8456
diff --git a/include/llfio/v2.0/detail/impl/posix/directory_handle.ipp b/include/llfio/v2.0/detail/impl/posix/directory_handle.ipp
index f8483b3b..04bb431e 100644
--- a/include/llfio/v2.0/detail/impl/posix/directory_handle.ipp
+++ b/include/llfio/v2.0/detail/impl/posix/directory_handle.ipp
@@ -1,5 +1,5 @@
/* A handle to a directory
-(C) 2017 Niall Douglas (20 commits)
+(C) 2017-2024 Niall Douglas (20 commits)
File Created: Aug 2017
@@ -37,6 +37,11 @@ http://www.boost.org/LICENSE_1_0.txt)
#include
#include
+#ifdef __APPLE__
+extern "C" int _getdirentries(int, char *, int, long *);
+extern "C" size_t __getdirentries64(int fd, void *buf, size_t bufsize, __darwin_off_t *basep);
+#endif
+
LLFIO_V2_NAMESPACE_BEGIN
result directory_handle::directory(const path_handle &base, path_view_type path, mode _mode, creation _creation, caching _caching,
@@ -71,7 +76,7 @@ result directory_handle::directory(const path_handle &base, pa
#ifdef O_DIRECTORY
attribs |= O_DIRECTORY;
#endif
-#ifdef O_SEARCH
+#if defined(O_SEARCH) && !defined(__APPLE__) // Newer Mac OS defines this, but setting it breaks enumeration
attribs |= O_SEARCH;
#endif
if(base.is_valid() && path.empty())
@@ -81,7 +86,8 @@ result directory_handle::directory(const path_handle &base, pa
path = ".";
}
path_view::zero_terminated_rendered_path<> zpath(path);
- auto rename_random_dir_over_existing_dir = [_mode, _caching, flags](const path_handle &base, path_view_type path) -> result {
+ auto rename_random_dir_over_existing_dir = [_mode, _caching, flags](const path_handle &base, path_view_type path) -> result
+ {
// Take a path handle to the directory containing the file
auto path_parent = path.parent_path();
path_handle dirh;
@@ -343,11 +349,19 @@ result directory_handle::read(io_request([](int fd, char *buf, unsigned count) -> int {
- off_t foo;
- return syscall(SYS_getdirentries64, fd, buf, count, &foo);
+ static getdents_emulation_t getdents = static_cast(
+ [](int fd, char *buf, unsigned count) -> int
+ {
+#if __DARWIN_64_BIT_INO_T
+ __darwin_off_t foo = 0;
+ uint64_t *flags = (uint64_t *) (buf + count - sizeof(uint64_t));
+ *flags = 0;
+ return (int) __getdirentries64(fd, buf, count, &foo);
+#else
+ long foo = 0;
+ return _getdirentries(fd, buf, (int) count, &foo);
+#endif
});
#endif
if(!req.buffers._kernel_buffer && req.kernelbuffer.empty())
diff --git a/include/llfio/v2.0/detail/impl/posix/import.hpp b/include/llfio/v2.0/detail/impl/posix/import.hpp
index 1d21a765..b4e33d12 100644
--- a/include/llfio/v2.0/detail/impl/posix/import.hpp
+++ b/include/llfio/v2.0/detail/impl/posix/import.hpp
@@ -48,16 +48,16 @@ inline result attribs_from_handle_mode_caching_and_flags(native_handle_type
break;
case handle::mode::attr_read:
case handle::mode::read:
- attribs = O_RDONLY;
+ attribs |= O_RDONLY;
nativeh.behaviour |= native_handle_type::disposition::seekable | native_handle_type::disposition::readable;
break;
case handle::mode::attr_write:
case handle::mode::write:
- attribs = O_RDWR;
+ attribs |= O_RDWR;
nativeh.behaviour |= native_handle_type::disposition::seekable | native_handle_type::disposition::readable | native_handle_type::disposition::writable;
break;
case handle::mode::append:
- attribs = O_WRONLY | O_APPEND;
+ attribs |= O_WRONLY | O_APPEND;
nativeh.behaviour |= native_handle_type::disposition::writable | native_handle_type::disposition::append_only;
break;
}