* fhandler.cc (fhandler_base::fstat): Initialise tv_nsec member of
st_atim, st_mtim, and 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, and st_ctim fields. * syscalls.cc (stat64_to_stat32): Ditto. * times.cc (to_timestruc_t): New function. (time_as_timestruc_t): New function. * winsup.h: Add to_timestruc_t and time_as_timestruc_t functions. * include/cygwin/stat.h: Replace time_t with timestruc_t throughout for all file times, removing the st_spare1, st_spare2, and st_spare3 fields in the process. Add macros to access tv_sec fields by old names. * include/cygwin/types.h: Typedef timespec_t and timestruc_t as struct timespec.
This commit is contained in:
parent
a81cc3be2a
commit
c4e6ff484c
|
@ -1,3 +1,22 @@
|
||||||
|
2002-06-05 Conrad Scott <conrad.scott@dsl.pipex.com>
|
||||||
|
|
||||||
|
* fhandler.cc (fhandler_base::fstat): Initialise tv_nsec member of
|
||||||
|
st_atim, st_mtim, and 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, and st_ctim fields.
|
||||||
|
* syscalls.cc (stat64_to_stat32): Ditto.
|
||||||
|
* times.cc (to_timestruc_t): New function.
|
||||||
|
(time_as_timestruc_t): New function.
|
||||||
|
* winsup.h: Add to_timestruc_t and time_as_timestruc_t functions.
|
||||||
|
* include/cygwin/stat.h: Replace time_t with timestruc_t
|
||||||
|
throughout for all file times, removing the st_spare1, st_spare2,
|
||||||
|
and st_spare3 fields in the process. Add macros to access tv_sec
|
||||||
|
fields by old names.
|
||||||
|
* include/cygwin/types.h: Typedef timespec_t and timestruc_t as
|
||||||
|
struct timespec.
|
||||||
|
|
||||||
2002-06-03 Pierre Humblet <pierre.humblet@ieee.org>
|
2002-06-03 Pierre Humblet <pierre.humblet@ieee.org>
|
||||||
|
|
||||||
* sec_helper.cc (lookup_name): Suppress.
|
* sec_helper.cc (lookup_name): Suppress.
|
||||||
|
|
|
@ -842,7 +842,8 @@ fhandler_base::fstat (struct __stat64 *buf, path_conv *)
|
||||||
buf->st_mode |= get_device () == FH_FLOPPY ? S_IFBLK : S_IFCHR;
|
buf->st_mode |= get_device () == FH_FLOPPY ? S_IFBLK : S_IFCHR;
|
||||||
buf->st_nlink = 1;
|
buf->st_nlink = 1;
|
||||||
buf->st_blksize = S_BLKSIZE;
|
buf->st_blksize = S_BLKSIZE;
|
||||||
buf->st_atime = buf->st_mtime = buf->st_ctime = time (NULL) - 1;
|
time_as_timestruc_t (&buf->st_ctim);
|
||||||
|
buf->st_atim = buf->st_mtim = buf->st_ctim;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -200,9 +200,9 @@ fhandler_disk_file::fstat_helper (struct __stat64 *buf, path_conv *pc,
|
||||||
&& ftCreationTime.dwHighDateTime == 0)
|
&& ftCreationTime.dwHighDateTime == 0)
|
||||||
ftCreationTime = ftLastWriteTime;
|
ftCreationTime = ftLastWriteTime;
|
||||||
|
|
||||||
buf->st_atime = to_time_t (&ftLastAccessTime);
|
to_timestruc_t (&ftLastAccessTime, &buf->st_atim);
|
||||||
buf->st_mtime = to_time_t (&ftLastWriteTime);
|
to_timestruc_t (&ftLastWriteTime, &buf->st_mtim);
|
||||||
buf->st_ctime = to_time_t (&ftCreationTime);
|
to_timestruc_t (&ftCreationTime, &buf->st_ctim);
|
||||||
buf->st_nlink = nNumberOfLinks;
|
buf->st_nlink = nNumberOfLinks;
|
||||||
buf->st_dev = pc->volser ();
|
buf->st_dev = pc->volser ();
|
||||||
buf->st_size = ((__off64_t)nFileSizeHigh << 32) + nFileSizeLow;
|
buf->st_size = ((__off64_t)nFileSizeHigh << 32) + nFileSizeLow;
|
||||||
|
|
|
@ -121,7 +121,8 @@ fhandler_process::fstat (struct __stat64 *buf, path_conv *pc)
|
||||||
return 0;
|
return 0;
|
||||||
case 2:
|
case 2:
|
||||||
buf->st_ctime = buf->st_mtime = p->start_time;
|
buf->st_ctime = buf->st_mtime = p->start_time;
|
||||||
buf->st_atime = time(NULL);
|
buf->st_ctim.tv_nsec = buf->st_mtim.tv_nsec = 0;
|
||||||
|
time_as_timestruc_t(&buf->st_atim);
|
||||||
buf->st_uid = p->uid;
|
buf->st_uid = p->uid;
|
||||||
buf->st_gid = p->gid;
|
buf->st_gid = p->gid;
|
||||||
buf->st_mode |= S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH;
|
buf->st_mode |= S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH;
|
||||||
|
|
|
@ -818,9 +818,9 @@ stat32_to_STAT (struct __stat32 *src, struct STAT *dst)
|
||||||
dst->st_gid = src->st_gid;
|
dst->st_gid = src->st_gid;
|
||||||
dst->st_rdev = src->st_rdev;
|
dst->st_rdev = src->st_rdev;
|
||||||
dst->st_size = src->st_size;
|
dst->st_size = src->st_size;
|
||||||
dst->st_atime = src->st_atime;
|
dst->st_atim = src->st_atim;
|
||||||
dst->st_mtime = src->st_mtime;
|
dst->st_mtim = src->st_mtim;
|
||||||
dst->st_ctime = src->st_ctime;
|
dst->st_ctim = src->st_ctim;
|
||||||
dst->st_blksize = src->st_blksize;
|
dst->st_blksize = src->st_blksize;
|
||||||
dst->st_blocks = src->st_blocks;
|
dst->st_blocks = src->st_blocks;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,12 +27,9 @@ struct __stat32
|
||||||
__gid16_t st_gid;
|
__gid16_t st_gid;
|
||||||
__dev16_t st_rdev;
|
__dev16_t st_rdev;
|
||||||
__off32_t st_size;
|
__off32_t st_size;
|
||||||
time_t st_atime;
|
timestruc_t st_atim;
|
||||||
long st_spare1;
|
timestruc_t st_mtim;
|
||||||
time_t st_mtime;
|
timestruc_t st_ctim;
|
||||||
long st_spare2;
|
|
||||||
time_t st_ctime;
|
|
||||||
long st_spare3;
|
|
||||||
blksize_t st_blksize;
|
blksize_t st_blksize;
|
||||||
__blkcnt32_t st_blocks;
|
__blkcnt32_t st_blocks;
|
||||||
long st_spare4[2];
|
long st_spare4[2];
|
||||||
|
@ -48,12 +45,9 @@ struct __stat64
|
||||||
__gid32_t st_gid;
|
__gid32_t st_gid;
|
||||||
__dev32_t st_rdev;
|
__dev32_t st_rdev;
|
||||||
__off64_t st_size;
|
__off64_t st_size;
|
||||||
time_t st_atime;
|
timestruc_t st_atim;
|
||||||
long st_spare1;
|
timestruc_t st_mtim;
|
||||||
time_t st_mtime;
|
timestruc_t st_ctim;
|
||||||
long st_spare2;
|
|
||||||
time_t st_ctime;
|
|
||||||
long st_spare3;
|
|
||||||
blksize_t st_blksize;
|
blksize_t st_blksize;
|
||||||
__blkcnt64_t st_blocks;
|
__blkcnt64_t st_blocks;
|
||||||
long st_spare4[2];
|
long st_spare4[2];
|
||||||
|
@ -75,17 +69,18 @@ struct stat
|
||||||
gid_t st_gid;
|
gid_t st_gid;
|
||||||
dev_t st_rdev;
|
dev_t st_rdev;
|
||||||
off_t st_size;
|
off_t st_size;
|
||||||
time_t st_atime;
|
timestruc_t st_atim;
|
||||||
long st_spare1;
|
timestruc_t st_mtim;
|
||||||
time_t st_mtime;
|
timestruc_t st_ctim;
|
||||||
long st_spare2;
|
|
||||||
time_t st_ctime;
|
|
||||||
long st_spare3;
|
|
||||||
blksize_t st_blksize;
|
blksize_t st_blksize;
|
||||||
blkcnt_t st_blocks;
|
blkcnt_t st_blocks;
|
||||||
long st_spare4[2];
|
long st_spare4[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define st_atime st_atim.tv_sec
|
||||||
|
#define st_mtime st_mtim.tv_sec
|
||||||
|
#define st_ctime st_ctim.tv_sec
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -19,6 +19,8 @@ extern "C"
|
||||||
|
|
||||||
#include <sys/sysmacros.h>
|
#include <sys/sysmacros.h>
|
||||||
|
|
||||||
|
typedef struct timespec timespec_t, timestruc_t;
|
||||||
|
|
||||||
typedef long __off32_t;
|
typedef long __off32_t;
|
||||||
typedef long long __off64_t;
|
typedef long long __off64_t;
|
||||||
#ifdef __CYGWIN_USE_BIG_TYPES__
|
#ifdef __CYGWIN_USE_BIG_TYPES__
|
||||||
|
|
|
@ -1000,9 +1000,9 @@ stat64_to_stat32 (struct __stat64 *src, struct __stat32 *dst)
|
||||||
dst->st_gid = src->st_gid;
|
dst->st_gid = src->st_gid;
|
||||||
dst->st_rdev = src->st_rdev;
|
dst->st_rdev = src->st_rdev;
|
||||||
dst->st_size = src->st_size;
|
dst->st_size = src->st_size;
|
||||||
dst->st_atime = src->st_atime;
|
dst->st_atim = src->st_atim;
|
||||||
dst->st_mtime = src->st_mtime;
|
dst->st_mtim = src->st_mtim;
|
||||||
dst->st_ctime = src->st_ctime;
|
dst->st_ctim = src->st_ctim;
|
||||||
dst->st_blksize = src->st_blksize;
|
dst->st_blksize = src->st_blksize;
|
||||||
dst->st_blocks = src->st_blocks;
|
dst->st_blocks = src->st_blocks;
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,6 +227,47 @@ to_time_t (FILETIME *ptr)
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Cygwin internal */
|
||||||
|
/* Convert a Win32 time to "UNIX" timestruc_t format. */
|
||||||
|
void __stdcall
|
||||||
|
to_timestruc_t (FILETIME *ptr, timestruc_t *out)
|
||||||
|
{
|
||||||
|
/* A file time is the number of 100ns since jan 1 1601
|
||||||
|
stuffed into two long words.
|
||||||
|
A timestruc_t is the number of seconds and microseconds since jan 1 1970
|
||||||
|
stuffed into a time_t and a long. */
|
||||||
|
|
||||||
|
long rem;
|
||||||
|
long long x = ((long long) ptr->dwHighDateTime << 32) + ((unsigned)ptr->dwLowDateTime);
|
||||||
|
|
||||||
|
/* pass "no time" as epoch */
|
||||||
|
if (x == 0)
|
||||||
|
{
|
||||||
|
out->tv_sec = 0;
|
||||||
|
out->tv_nsec = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
x -= FACTOR; /* number of 100ns between 1601 and 1970 */
|
||||||
|
rem = x % ((long long)NSPERSEC);
|
||||||
|
x /= (long long) NSPERSEC; /* number of 100ns in a second */
|
||||||
|
out->tv_nsec = rem * 100; /* as tv_nsec is in nanoseconds */
|
||||||
|
out->tv_sec = x;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Cygwin internal */
|
||||||
|
/* Get the current time as a "UNIX" timestruc_t format. */
|
||||||
|
void __stdcall
|
||||||
|
time_as_timestruc_t (timestruc_t * out)
|
||||||
|
{
|
||||||
|
SYSTEMTIME systemtime;
|
||||||
|
FILETIME filetime;
|
||||||
|
|
||||||
|
GetSystemTime (&systemtime);
|
||||||
|
SystemTimeToFileTime (&systemtime, &filetime);
|
||||||
|
to_timestruc_t (&filetime, out);
|
||||||
|
}
|
||||||
|
|
||||||
/* time: POSIX 4.5.1.1, C 4.12.2.4 */
|
/* time: POSIX 4.5.1.1, C 4.12.2.4 */
|
||||||
/* Return number of seconds since 00:00 UTC on jan 1, 1970 */
|
/* Return number of seconds since 00:00 UTC on jan 1, 1970 */
|
||||||
extern "C"
|
extern "C"
|
||||||
|
|
|
@ -206,6 +206,8 @@ extern "C" char *__stdcall strcasestr (const char *searchee, const char *lookfor
|
||||||
/* Time related */
|
/* Time related */
|
||||||
void __stdcall totimeval (struct timeval *dst, FILETIME * src, int sub, int flag);
|
void __stdcall totimeval (struct timeval *dst, FILETIME * src, int sub, int flag);
|
||||||
long __stdcall to_time_t (FILETIME * ptr);
|
long __stdcall to_time_t (FILETIME * ptr);
|
||||||
|
void __stdcall to_timestruc_t (FILETIME * ptr, timestruc_t * out);
|
||||||
|
void __stdcall time_as_timestruc_t (timestruc_t * out);
|
||||||
|
|
||||||
void __stdcall set_console_title (char *);
|
void __stdcall set_console_title (char *);
|
||||||
void early_stuff_init ();
|
void early_stuff_init ();
|
||||||
|
|
Loading…
Reference in New Issue