This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH RESEND] zic, various tests: use LFS I/O functions explicitly where needed
- From: Paul Eggert <eggert at cs dot ucla dot edu>
- To: Nick Alcock <nix at esperi dot org dot uk>, libc-alpha at sourceware dot org
- Date: Sun, 25 Jun 2017 15:17:51 -0700
- Subject: Re: [PATCH RESEND] zic, various tests: use LFS I/O functions explicitly where needed
- Authentication-results: sourceware.org; auth=none
- References: <87zicvkbqw.fsf@esperi.org.uk>
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;