[PATCH RESEND] zic, various tests: use LFS I/O functions explicitly where needed
Paul Eggert
eggert@cs.ucla.edu
Sun Jun 25 22:17:00 GMT 2017
Nick Alcock wrote:
> - struct stat st;
> - int res = stat(name, &st);
> + struct stat64 st;
> + int res = stat64(name, &st);
If this change fixes zic, we should be compiling timezone/*.c with
-D_FILE_OFFSET_BITS=64, as the code is imported from tzcode and the .c files
should be left unchanged when possible.
However, I don't see why the change fixes zic, so could you please explain? The
code after the patch looks like the following, and this should do the right
thing even if stat(name, &st) returns -1 and sets errno to EOVERFLOW. So why
does switching to stat64 improve zic's behavior?
#ifdef S_ISDIR
if (res == 0)
return S_ISDIR(st.st_mode) != 0;
#endif
if (res == 0 || errno == EOVERFLOW) {
size_t n = strlen(name);
char *nameslashdot = emalloc(n + 3);
bool dir;
memcpy(nameslashdot, name, n);
strcpy(&nameslashdot[n], &"/."[! (n && name[n - 1] != '/')]);
dir = stat(nameslashdot, &st) == 0 || errno == EOVERFLOW;
free(nameslashdot);
return dir;
}
return false;
More information about the Libc-alpha
mailing list