This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH RESEND] zic, various tests: use LFS I/O functions explicitly where needed

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;
	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;
		return dir;
	return false;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]