Mail Archives: djgpp/2000/08/29/01:00:17
From: | pjfarley AT banet DOT net (Peter J. Farley III)
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Q: libc fstat: Why is st_ctime < st_atime == st_mtime after fopen?
|
Date: | Tue, 29 Aug 2000 04:46:58 GMT
|
Message-ID: | <39ab3cee.32395153@news3.banet.net>
|
X-Newsreader: | Forte Free Agent 1.21/32.243
|
NNTP-Posting-Host: | 32.100.85.86
|
X-Trace: | 29 Aug 2000 04:45:58 GMT, 32.100.85.86
|
Organization: | Global Network Services - Remote Access Mail & News Services
|
Lines: | 47
|
X-Complaints-To: | abuse AT prserv DOT net
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
I have a small test program (see below) which unlinks a file, uses
fopen to open the file in "wt" mode, and then calls fstat on the
newly-opened file. The time values in the stat structure have this
relationship to each other immediately after the open, before any
write to the file has occurred:
st_ctime < st_atime == st_mtime
For example, the test program produced this output when I just ran it:
atime=967508974,ctime=967508972,mtime=967508974
On first glance, I would have thought that all these values would be
equal right after an "open for output" on a new file. If there is a
reason they are not, I would appreciate knowing why.
The test program mirrors perl code that is failing in testing a DJGPP
build of perl-5.6.0, which expects that ctime == mtime unless the
system is Cygwin or Win32 (but makes no exception for DJGPP). I need
to know if it is intentional or system-related that ctime != mtime in
the DJGPP fstat results, so that the perl test case can be adjusted
appropriately for DJGPP.
Any info or RTFM's appreciated.
------------ teststat.c ----------------------------------
#include <stdio.h>
#include <sys/stat.h>
int main () {
struct stat mystat;
FILE *tmp;
unlink("Opstat.tmp");
tmp = fopen("Opstat.tmp", "wt");
fstat(fileno(tmp), &mystat);
printf("atime=%d,ctime=%d,mtime=%d\n",
mystat.st_atime, mystat.st_ctime, mystat.st_mtime);
fprintf(tmp, "Unrelated data\n");
fclose(tmp);
}
------------ teststat.c ----------------------------------
----------------------------------------------------
Peter J. Farley III (pjfarley AT nospam DOT dorsai DOT org OR
pjfarley AT nospam DOT banet DOT net)
- Raw text -