Skip to content

Commit

Permalink
Add a flag to for the use of lstat in ReadDir
Browse files Browse the repository at this point in the history
  • Loading branch information
adithyaov committed Jan 3, 2025
1 parent f801b86 commit 620f6ab
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ jobs:
disable_sdist_build: "y"
ignore_error: false
# Note: use linux for warning build for convenient dev testing
- name: 9.10.1-Werror
- name: 9.10.1-Werror-lstat-readir
ghc_version: 9.10.1
runner: ubuntu-latest
build: cabal
cabal_build_options: "--flag limit-build-mem"
cabal_build_options: "--flag limit-build-mem --flag force-lstat-readdir"
cabal_version: 3.12.1.0
disable_sdist_build: "y"
cabal_project: cabal.project.Werror
Expand Down
4 changes: 4 additions & 0 deletions core/src/Streamly/Internal/FileSystem/Posix/ReadDir.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ lstatDname parent dname = do
{-# INLINE checkDirStatus #-}
checkDirStatus
:: PosixPath -> Ptr CChar -> #{type unsigned char} -> IO (Bool, Bool)
#ifdef FORCE_LSTAT_READDIR
checkDirStatus parent dname _ = lstatDname parent dname
#else
checkDirStatus parent dname dtype =
if dtype == #const DT_UNKNOWN
then lstatDname parent dname
Expand All @@ -171,6 +174,7 @@ checkDirStatus parent dname dtype =
isMeta <- liftIO $ isMetaDir dname
pure (True, isMeta)
else pure (False, False)
#endif

-- XXX We can use getdents64 directly so that we can use array slices from the
-- same buffer that we passed to the OS. That way we can also avoid any
Expand Down
8 changes: 8 additions & 0 deletions core/streamly-core.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,21 @@ flag use-folds
manual: True
default: False

flag force-lstat-readdir
description: Use lstat instead of checking for dtype in ReadDir
manual: True
default: False

-------------------------------------------------------------------------------
-- Common stanzas
-------------------------------------------------------------------------------

common compile-options
default-language: Haskell2010

if flag(force-lstat-readdir)
cpp-options: -DFORCE_LSTAT_READDIR

if flag(dev)
cpp-options: -DDEVBUILD

Expand Down

0 comments on commit 620f6ab

Please sign in to comment.