[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#231358: libc6: ppc32 stat reports bogus nanosecond data



Package: libc6
Version: 2.3.2.ds1-11
Severity: important
Tags: patch

Hi,

ppc32 unstable glibc has a problem with nanosecond stat. Would it be 
possible to get the following patch in?

Thanks,
Anton

-- System Information:
Debian Release: testing/unstable
Architecture: powerpc
Kernel: Linux krispykreme 2.6.1-ben1 #6 Thu Jan 15 16:22:09 EST 2004 ppc
Locale: LANG=C, LC_CTYPE=C

Versions of packages libc6 depends on:
ii  libdb1-compat                 2.1.3-7    The Berkeley database routines [gl

-- no debconf information

>From anton@samba.org Fri Feb  6 00:58:21 2004
Date: Fri, 6 Feb 2004 00:58:21 +1100
From: Anton Blanchard <anton@samba.org>
To: libc-alpha@sources.redhat.com
Cc: sjmunroe@us.ibm.com
Subject: [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);
}





Reply to: