Pyramid lseek gotcha
ansok at ucbvax.berkeley.edu
ansok at ucbvax.berkeley.edu
Wed Jan 8 19:12:03 AEST 1986
I came across a gotcha recently while trying to port a program onto
our Pyramid. This program wanted to get information out of the
kernel, so it opened up /dev/kmem, got some addresses via nlist,
and tried to seek to those addresses. Unfortunately, the program
kept reporting an error whenever it tried to seek (to an address
in the neighborhood of 0xff05000). After some trial and error,
I discovered the culprit was a line in the program that looked like:
if (lseek(fd,addr,L_SET) != addr)
/* error... */
and that the Pyramid returned 0 from lseek for addresses >= 0x80000000.
(I suppose because such a number cannot be represented in the signed
long that lseek returns.) Of course, the documentation fails to
mention this little fact, and states that the return from lseek is
*always* addr or -1. Admittedly, there may not be a better way to
deal with a return value which could range from 0 to 0xffffffff and
still have a value left over for error. But it would have been nice
if this hadn't been a total surprise.
Gary Ansok
trwrb!trwspp!spp3!ansok
More information about the Comp.unix.wizards
mailing list