This is the mail archive of the libc-alpha@sources.redhat.com 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]

[PATCH] enable nanosecond stat on ppc32


Hi,

I was chasing some strange problems with make and found the ppc32 stat
does not copy the nanosecond fields out of the kernel stat structure.
However when make is configured it wants to use nanosecond stat.

Quick test attached below, when I run this I see random stack garbage
in the nsec fields. It looks like the problem is a lack of _HAVE_STAT_NSEC. 
A patch is below.

As an aside should we be zeroing the nanosecond fields in the stat
conversion code on archs that dont support it?

Anton

--

--- libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h	2003-01-01 00:24:34.000000000 +1100
+++ libc_work/sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h	2004-02-05 21:45:49.829230270 +1100
@@ -42,6 +42,8 @@
 #define _HAVE_STAT___UNUSED5
 #define _HAVE_STAT___PAD1
 #define _HAVE_STAT___PAD2
+#define _HAVE_STAT_NSEC
 #define _HAVE_STAT64___UNUSED4
 #define _HAVE_STAT64___UNUSED5
 #define _HAVE_STAT64___PAD2
+#define _HAVE_STAT64_NSEC

--

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>

#define PRINTIT(STRUCT, FOO) printf("" #STRUCT "->" #FOO " %lx\n", STRUCT . FOO)
#define TMPFILE "/tmp/stattmpfile"

int main()
{
	int fd;
	struct stat before, after;

	fd = open(TMPFILE, O_CREAT|O_RDWR, 0600);
	if (fd == -1) {
		perror("open");
		exit(1);
	}
	if (stat(TMPFILE, &before)) {
		perror("stat");
		exit(1);
	}

	PRINTIT(before, st_atim.tv_sec);
	PRINTIT(before, st_atim.tv_nsec);
	PRINTIT(before, st_mtim.tv_sec);
	PRINTIT(before, st_mtim.tv_nsec);
	PRINTIT(before, st_ctim.tv_sec);
	PRINTIT(before, st_ctim.tv_nsec);

	usleep(500000);

	write(fd, "x", 1);
	close(fd);
	if (stat(TMPFILE, &after)) {
		perror("stat");
		exit(1);
	}

	PRINTIT(after, st_atim.tv_sec);
	PRINTIT(after, st_atim.tv_nsec);
	PRINTIT(after, st_mtim.tv_sec);
	PRINTIT(after, st_mtim.tv_nsec);
	PRINTIT(after, st_ctim.tv_sec);
	PRINTIT(after, st_ctim.tv_nsec);
}


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