diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 143594395..31281de04 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2011-01-13 Corinna Vinschen + + * fhandler_disk_file.cc (fhandler_base::fstat_helper): Alwasy set + st_size of directories to 0. Explain why. + 2011-01-12 Corinna Vinschen * posix.sgml: Add madvise to BSD list. diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index aea62a1b2..3d72f86b9 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -497,7 +497,14 @@ fhandler_base::fstat_helper (struct __stat64 *buf, &buf->st_ctim); to_timestruc_t ((PFILETIME) &pfnoi->CreationTime, &buf->st_birthtim); buf->st_rdev = buf->st_dev = get_dev (); - buf->st_size = (_off64_t) pfnoi->EndOfFile.QuadPart; + /* CV 2011-01-13: Observations on the Cygwin mailing list point to an + interesting behaviour in some Windows versions. Apparently the size of + a directory is computed at the time the directory is first scanned. This + can result in two subsequent NtQueryInformationFile calls to return size + 0 in the first call and size > 0 in the second call. This in turn can + affect applications like newer tar. + FIXME: Is the allocation size affected as well? */ + buf->st_size = pc.isdir () ? 0 : (_off64_t) pfnoi->EndOfFile.QuadPart; /* The number of links to a directory includes the number of subdirectories in the directory, since all those subdirectories point to it. However, this is painfully slow, so we do without it. */