Proposal: better timestamp granularity for modificationTime/setFileTimes in System.Posix.Files[.ByteString]

Dear all, System.Posix.Files[.ByteString] contains the following functions related to file times: accessTime, modificationTime, statusChangeTime, setFileTimes. All of these functions offer granularity of one second. Modern posix systems support newer functions (such as utimes, utimensat) that offer better granularity (up to 1 nanosecond). I propose to add a new set of functions to System.Posix.Files[.ByteString] to utilize these new capabilities. One problem here is the choice of the data type to be used for these timestamps as the EpochTime type only allows granularity of one second. One option might be POSIXTime from Data.Time.Clock.POSIX. I am willing to provide patches.

On Mon, Jun 11, 2012 at 9:25 AM, Marios Titas
System.Posix.Files[.ByteString] contains the following functions related to file times: accessTime, modificationTime, statusChangeTime, setFileTimes. All of these functions offer granularity of one second. Modern posix systems support newer functions (such as utimes, utimensat) that offer better granularity (up to 1 nanosecond).
Be aware that how these are provided varies: Solaris, FreeBSD, and Linux use different extensions and different types to represent them. -- brandon s allbery allbery.b@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms

On Mon, Jun 11, 2012 at 2:04 PM, Brandon Allbery
On Mon, Jun 11, 2012 at 9:25 AM, Marios Titas
wrote: System.Posix.Files[.ByteString] contains the following functions related to file times: accessTime, modificationTime, statusChangeTime, setFileTimes. All of these functions offer granularity of one second. Modern posix systems support newer functions (such as utimes, utimensat) that offer better granularity (up to 1 nanosecond).
Be aware that how these are provided varies: Solaris, FreeBSD, and Linux use different extensions and different types to represent them.
Yes, I am well aware of that. What I meant is to pick the best function available using #ifdef's and then convert the timestamps to a common type (such as POSIXTime from Data.Time.Clock.POSIX) irrespective of what function was actually used.

On Mon, Jun 11, 2012 at 7:14 PM, Marios Titas
On Mon, Jun 11, 2012 at 2:04 PM, Brandon Allbery
wrote: On Mon, Jun 11, 2012 at 9:25 AM, Marios Titas
wrote: System.Posix.Files[.ByteString] contains the following functions related to file times: accessTime, modificationTime, statusChangeTime, setFileTimes. All of these functions offer granularity of one second. Modern posix systems support newer functions (such as utimes, utimensat) that offer better granularity (up to 1 nanosecond).
Be aware that how these are provided varies: Solaris, FreeBSD, and Linux use different extensions and different types to represent them.
Yes, I am well aware of that. What I meant is to pick the best function available using #ifdef's and then convert the timestamps to a common type (such as POSIXTime from Data.Time.Clock.POSIX) irrespective of what function was actually used.
I posted a patch to the bug tracker [1]. It tries to detect the best function available and uses that. It should work under all posix systems. I tested it under Linux (x86 & x86-64), FreeBSD (x86) and Mac OS X (x86-64). [1] http://hackage.haskell.org/trac/ghc/ticket/6160
participants (2)
-
Brandon Allbery
-
Marios Titas