Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add statx #297

Closed
wants to merge 1 commit into from
Closed

Add statx #297

wants to merge 1 commit into from

Conversation

hasufell
Copy link
Member

@hasufell hasufell commented Sep 16, 2023

TODO:

  • decide whether to provide STATX_MNT_ID
  • maybe provide StatxMask defaults for STATX_BASIC_STATS and STATX_ALL
  • fix the autoconf thing and use proper if guards (and use FP_CHECK_CONSTS to check for the constants)
  • support the same queries as FileStatus
  • add support for String and PosixPath

@hasufell hasufell self-assigned this Sep 16, 2023
@hasufell hasufell marked this pull request as draft September 16, 2023 08:21
# check for statx
AC_CHECK_FUNC([statx], [AC_DEFINE([HAVE_STATX_FUN],[1],[HAVE_STATX_FUN])],[],[#include <sys/stat.h>])
AC_CHECK_TYPE([struct statx],[AC_DEFINE([HAVE_STRUCT_STATX],[1],[HAVE_STRUCT_STATX])],[],[#include <sys/stat.h>])
AS_IF([test "x$HAVE_STRUCT_STATX" = "x1" && test "x$HAVE_STATX_FUN" = "x1"], [AC_DEFINE([HAVE_STATX],[1],[HAVE_STATX])])
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check doesn't work somehow... autoconf fun

symlinkNoFollow = False
}

data StatxMask =
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I omitted STATX_MNT_ID, which is only available since Linux 5.8.

--
data StatxFlags =
StatxFlags {
emptyPath :: Bool
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe prefix with statx_ as well?

@hasufell
Copy link
Member Author

ghci> import System.Posix.Files.ByteString
ghci> :set -XOverloadedStrings
ghci> exStatus <- getExtendedFileStatus Nothing "/home/hasufell/git/unix/unix.cabal" defaultStatxFlags defaultStatxMask
ghci> fileSizeX exStatus
9318

Seems to somewhat work.


newtype ExtendedFileStatus = ExtendedFileStatus (ForeignPtr CStatx) -- ^ The constructor is considered internal and may change.

fileOwnerX :: ExtendedFileStatus -> UserID
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only a subset of FileStatus. Need to add the rest.

@hasufell hasufell closed this Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant