Patch for sub-second resolution in stat(2)
Conrad Scott
Conrad.Scott@dsl.pipex.com
Wed Jun 5 17:57:00 GMT 2002
[Second attempt once I'd calmed down enough to get it right.]
Attached is a patch that adds sub-second resolution to the access,
modification, and creation times returned by stat(2) etc. I thought this
would make a nice companion to Corinna's work on making other things in
stat(2) be 64-bit.
Also, I was having trouble with a makefile where the commands could execute
in less than a second leading to irregular breakage: this patch fixes that.
This patch seems like a good idea to me but there is one detail that could
cause an issue. The function that maps FILETIMEs to time_t (to_time_t in
times.cc) currently rounds up the seconds. Thus this patch may show some
times as a second behind those shown currently.
The change to round-up times was made due to a problem on FAT partitions. I
don't understand exactly what the issue was (or still is) and I've been
unable to provoke any strange behaviour on a floppy disk (my only accessible
FAT partition . . .) The changelog entry is:
> Wed May 13 17:47:23 1998 Geoffrey Noer <noer@cygnus.com>
>
> patch from sos@prospect.com.ru (Sergey Okhapkin):
> * times.cc (to_time_t): prevent stat from returning incorrect
> file modification time (one second less) on fat partitions due
> to round-up error.
Apart from that issue, I've checked that this patch maintains both source
and binary compatibility (tho' it does add macros for st_mtime etc. to hide
the indirection involved). It also doesn't seem to disturb anything; for
example, cvs works fine with repositories created with second timing and
updated with sub-second timing.
I'm unclear whether this is the best naming / type scheme (timestruc_t
st_mtim etc. w/ ) but it is a common one and it's recognised by both the
make and fileutils packages available from the cygwin setup (i.e. make this
patch and re-compile those packages and they detect the new fields).
(As per Chris's response to my first partial message, I've sent a patch to
sys/types.h to the newlib mailing list.)
Oh! and I hope the Changelog's a little better this time. Good enough?
// Conrad
Changelog message:
* fhandler.cc (fhandler_base::fstat): Initialise tv_nsec member of st_atim,
st_mtim, st_ctim fields.
* fhandler_disk_file.cc (fhandler_disk_file::fstat_helper): ditto.
* fhandler_process.cc (fhandler_process::fstat): ditto.
* glob.c (stat32_to_STAT): Copy across the whole st_atim. st_mtime, st_ctim
fields.
* syscalls.cc (stat64_to_stat32): ditto.
* times.cc (to_timestruc_t time_as_timestruc_t): New functions.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: winsup.patch
Type: application/octet-stream
Size: 7782 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20020605/2803dd44/attachment.obj>
More information about the Cygwin-patches
mailing list