[[ This message never made it to the list. For the archives, here's
the fix: #include <unistd.h> in leapsecs_read.c. ]]
I've got a weird problem with libtai on my NetBSD/macppc 4.0 system,
which I ran into while trying to use some mess822 programs. Here's a
simple illustration of the problem without mess822:
$ nowutc
utcnow: fatal: unable to init leapsecs
$ sudo gzip /etc/leapsecs.dat
$ nowutc
2008-07-30 09:15:21.510625500000000000
$
Looking at leapsecs_read(), I understand why nowutc proceeds in the
absence of /etc/leapsecs.dat. However, I'm not understanding why it
fails when the file does exist. I added some incredulously redundant
debug output as follows:
--- leapsecs_read.c.orig 1998-09-04 22:33:37.000000000 -0400
+++ leapsecs_read.c 2008-07-30 05:27:25.000000000 -0400
@@ -32,10 +32,15 @@
t = (struct tai *) malloc(st.st_size);
if (!t) { close(fd); return -1; }
+ printf("malloc succeeded, can we read?\n");
n = read(fd,(char *) t,st.st_size);
close(fd);
+ printf("n is %zd, st.st_size is %zd\n", n, st.st_size);
+ printf("n == st.st_size: %d\n", n == st.st_size);
+ printf("n != st.st_size: %d\n", n != st.st_size);
if (n != st.st_size) { free(t); return -1; }
+ /* we never get this far */
n /= sizeof(struct tai);
for (i = 0;i < n;++i) {
And here's what happens when I run nowutc again:
$ nowutc
malloc succeeded, can we read?
n is 0, st.st_size is 0
n == st.st_size: 0
n != st.st_size: 1
utcnow: fatal: unable to init leapsecs
$
Can anyone help me figure out what's going on here? I've included the
ktrace output below.
FWIW, I can survive without precise leap-second adjustments, I'm just
really really curious what the problem is. :-)
- Amitai
22189 1 ktrace EMUL "netbsd"
22189 1 ktrace CALL execve(0xffffd8f8,0xffffddd8,0xffffdde0)
22189 1 ktrace NAMI "/home/schmonz/bin/nowutc"
22189 1 ktrace RET execve -1 errno 2 No such file or directory
22189 1 ktrace CALL execve(0xffffd8f8,0xffffddd8,0xffffdde0)
22189 1 ktrace NAMI "/bin/nowutc"
22189 1 ktrace RET execve -1 errno 2 No such file or directory
22189 1 ktrace CALL execve(0xffffd8f8,0xffffddd8,0xffffdde0)
22189 1 ktrace NAMI "/sbin/nowutc"
22189 1 ktrace RET execve -1 errno 2 No such file or directory
22189 1 ktrace CALL execve(0xffffd8f8,0xffffddd8,0xffffdde0)
22189 1 ktrace NAMI "/usr/bin/nowutc"
22189 1 ktrace RET execve -1 errno 2 No such file or directory
22189 1 ktrace CALL execve(0xffffd8f8,0xffffddd8,0xffffdde0)
22189 1 ktrace NAMI "/usr/sbin/nowutc"
22189 1 ktrace RET execve -1 errno 2 No such file or directory
22189 1 ktrace CALL execve(0xffffd8f8,0xffffddd8,0xffffdde0)
22189 1 ktrace NAMI "/usr/X11R6/bin/nowutc"
22189 1 ktrace RET execve -1 errno 2 No such file or directory
22189 1 ktrace CALL execve(0xffffd8f8,0xffffddd8,0xffffdde0)
22189 1 ktrace NAMI "/usr/pkg/bin/nowutc"
22189 1 ktrace NAMI "/usr/libexec/ld.elf_so"
22189 1 nowutc EMUL "netbsd"
22189 1 nowutc RET execve JUSTRETURN
22189 1 nowutc CALL mmap(0,0x8000,3,0x1002,0xffffffff,0,0,0)
22189 1 nowutc RET mmap -268533760/0xeffe8000
22189 1 nowutc CALL open(0xefffb980,0,0xefffb980)
22189 1 nowutc NAMI "/etc/ld.so.conf"
22189 1 nowutc RET open -1 errno 2 No such file or directory
22189 1 nowutc CALL
__sysctl(0xffffdcb8,2,0xefffcee8,0xffffdcc0,0,0)
22189 1 nowutc RET __sysctl 0
22189 1 nowutc CALL open(0xffffd678,0,0xffffd698)
22189 1 nowutc NAMI "/usr/pkg-20080723/lib/libc.so.12"
22189 1 nowutc RET open -1 errno 2 No such file or directory
22189 1 nowutc CALL open(0xffffd678,0,0xffffd688)
22189 1 nowutc NAMI "/usr/lib/libc.so.12"
22189 1 nowutc RET open 3
22189 1 nowutc CALL __fstat30(3,0xffffd5d8)
22189 1 nowutc RET __fstat30 0
22189 1 nowutc CALL mmap(0,0x1000,1,1,3,0,0,0)
22189 1 nowutc RET mmap -268537856/0xeffe7000
22189 1 nowutc CALL munmap(0xeffe7000,0x1000)
22189 1 nowutc RET munmap 0
22189 1 nowutc CALL mmap(0,0x11d000,5,0x10000002,3,0,0,0)
22189 1 nowutc RET mmap -269746176/0xefec0000
22189 1 nowutc CALL mmap(0xeffc1000,0x9000,7,0x12,3,0,0,0xf1000)
22189 1 nowutc RET mmap -268693504/0xeffc1000
22189 1 nowutc CALL
mmap(0xeffca000,0x13000,7,0x1012,0xffffffff,0,0,0)
22189 1 nowutc RET mmap -268656640/0xeffca000
22189 1 nowutc CALL mprotect(0xeffb1000,0x10000,0)
22189 1 nowutc RET mprotect 0
22189 1 nowutc CALL close(3)
22189 1 nowutc RET close 0
22189 1 nowutc CALL
__sysctl(0xefffce98,2,0xefffe0f0,0xffffdca8,0,0)
22189 1 nowutc RET __sysctl 0
22189 1 nowutc CALL __sysctl(0xffffdcec,
2,0xeffd1500,0xffffdce8,0,0)
22189 1 nowutc RET __sysctl 0
22189 1 nowutc CALL open(0x180203c,4,0xffffdde4)
22189 1 nowutc NAMI "/etc/leapsecs.dat"
22189 1 nowutc RET open 3
22189 1 nowutc CALL __fstat30(3,0xffffdcc0)
22189 1 nowutc RET __fstat30 0
22189 1 nowutc CALL __sysctl(0xffffdb90,2,0xffffdb8c,
0xffffdb88,0,0)
22189 1 nowutc RET __sysctl 0
22189 1 nowutc CALL readlink(0xeffb0670,0xffffdbf4,0x3f)
22189 1 nowutc NAMI "/etc/malloc.conf"
22189 1 nowutc RET readlink -1 errno 2 No such file or
directory
22189 1 nowutc CALL mmap(0,0x1000,3,0x1002,0xffffffff,0,0,0)
22189 1 nowutc RET mmap -268537856/0xeffe7000
22189 1 nowutc CALL break(0x18124ec)
22189 1 nowutc RET break 0
22189 1 nowutc CALL break(0x18134ec)
22189 1 nowutc RET break 0
22189 1 nowutc CALL break(0x1814000)
22189 1 nowutc RET break 0
22189 1 nowutc CALL break(0x1815000)
22189 1 nowutc RET break 0
22189 1 nowutc CALL __fstat30(1,0xffffdb58)
22189 1 nowutc RET __fstat30 0
22189 1 nowutc CALL break(0x1825000)
22189 1 nowutc RET break 0
22189 1 nowutc CALL ioctl(1,TIOCGETA,0xffffdb98)
22189 1 nowutc GIO fd 1 read 44 bytes
"\0\0+\^B\0\0\0\a\0\0K\0 \0\^E\M-K\^D\M^?\M^?\^?\^W\^U\^R\M^?\^C
\^\\^Z\
\^Y\^Q\^S\^V\^O\^A\0\^T\M^?\0\0%\M^@\0\0%\M^@"
22189 1 nowutc RET ioctl 0
22189 1 nowutc CALL write(1,0x1815000,0x1f)
22189 1 nowutc GIO fd 1 wrote 31 bytes
"malloc succeeded, can we read?
"
22189 1 nowutc RET write 31/0x1f
22189 1 nowutc CALL read(3,0x1814000,0)
22189 1 nowutc GIO fd 3 read 0 bytes
""
22189 1 nowutc RET read 0
22189 1 nowutc CALL close(3)
22189 1 nowutc RET close 0
22189 1 nowutc CALL write(1,0x1815000,0x18)
22189 1 nowutc GIO fd 1 wrote 24 bytes
"n is 0, st.st_size is 0
"
22189 1 nowutc RET write 24/0x18
22189 1 nowutc CALL write(1,0x1815000,0x13)
22189 1 nowutc GIO fd 1 wrote 19 bytes
"n == st.st_size: 0
"
22189 1 nowutc RET write 19/0x13
22189 1 nowutc CALL write(1,0x1815000,0x13)
22189 1 nowutc GIO fd 1 wrote 19 bytes
"n != st.st_size: 1
"
22189 1 nowutc RET write 19/0x13
22189 1 nowutc CALL write(2,0x1801ff4,0x27)
22189 1 nowutc GIO fd 2 wrote 39 bytes
"utcnow: fatal: unable to init leapsecs
"
22189 1 nowutc RET write 39/0x27
22189 1 nowutc CALL exit(0x6f)