Limits on 4.2BSD lseek(2)?

Greg Earle earle at smeagol.UUCP
Wed May 14 13:23:45 AEST 1986


In the Netnews 2.10.3 4.3bsd-beta 6/6/85 distibution, there is a program
called article (written by Peter Honeyman, down!honey) that comes in
the `misc' directory.  This program will take an article message ID
(like 1052 at ellie, 1424 at lll-crg, etc.), look it up in the dbm version
of the news history file, and if it finds it, will print out the
first pathname it finds for the article (if it was cross-posted), by 
fetching the line containing the article ID from the history file.
Example:
	% /usr/lib/news/misc/article 150 at hadron.UUCP
	/usr/spool/news/net/unix-wizards/XXXX (Your mileage may vary, here)
	%

The problem I have found, is that more often than not, the program will
blow up on a Bus Error.  This happens on a Sun 2-120 workstation, running
Sun OS 2.0 (4.2BSD based).  The cause of this Bus Error is an execution
of lseek(2).  A subroutine looks for the article ID in question, and returns
a datum that has a pointer to the entry in the history dbm file.
It then calls lseek(2) with this pointer dereferenced in order to get to 
that line in the history file.

Here is a snatch of the code (from ./misc/article.c in the distribution):

		...
                content = dofetch(*argv);
                if (content.dptr == 0) {
                        printf("%s: No such key\n", *argv);
                        continue;
                }
                if (lseek(fd, *(long *) content.dptr, 0) < 0)
                        continue;

So `content' gets the offset associated with argv, and lseek tries to
position to that spot.

I am finding that it retrieves some articles with no problem, but most of
them are gagging with the accompaning Bus Error.

Anyhow, this begs the basic question :
What are the limits on positioning in an lseek(2) under 4.2BSD?
What conditions are there, that allow successful completion of the call 
in some circumstances, and Bus Errors in (most) others?
This came about because my history (and .dbm) file is pretty big;
I made the assumption that the value returned in content.dptr was larger
than some cutoff value (Why should an lseek fail if the file has enough
bytes?  Arggghh ...), but I'm not sure ...

All ideas welcome ...
--

	Greg Earle		UUCP: sdcrdcf!smeagol!earle, attmail!earle
	JPL			ARPA: elroy!smeagol!earle at csvax.caltech.edu

My HAIRCUT is totally NON-TRADITIONAL!



More information about the Comp.bugs.4bsd.ucb-fixes mailing list