|
From: Eli Z. <el...@gn...> - 2013-10-12 12:18:41
|
I'm posting this here first because I might be missing something. If
my observations are correct, and this is a bug, I will open a ticket.
The layout of 'struct dirent' in WSL 4.0 uses the time_t type:
struct dirent
{
long d_ino; /* Always zero. */
unsigned short d_reclen; /* Always zero. */
unsigned short d_namlen; /* Length of name in d_name. */
/* The following exactly mimic the layout of _finddata_t ...
*/
unsigned d_type; /* File attributes */
time_t d_time_create;
time_t d_time_access; /* always midnight local time */
time_t d_time_write;
_fsize_t d_size;
/*
* ...so that we may map a union of _finddata_t at the
* location of d_type (corresponding to _finddata_t.attrib),
* and thus map this directly to the _findfirst/_findnext
* returned field.
*/
char d_name[FILENAME_MAX]; /* File name. */
};
However, the width of time_t can be either 32 bits or 64 bits, with
the latter being the default in 4.0:
#if defined(_USE_32BIT_TIME_T)
typedef __time32_t time_t;
#else
typedef __time64_t time_t;
#endif /* _USE_32BIT_TIME_T */
Presumably, when the dirent functions were compiled for inclusion in
the libmingwex library, the compilation used the 64-bit default
definition of time_t.
This means that applications that define _USE_32BIT_TIME_T will use an
incompatible definition of 'struct dirent', which will break any code
that calls the dirent functions.
Am I missing something? If not, it sounds like 'struct dirent32' and
readdir32 etc. functions will be needed to allow use of both 32-bit
time_t and dirent functions in the same program, similarly to what is
already done with time-related functions, 'stat', etc.
|