Subject: lseek() continued! DOH!
To: None <netbsd-help@NetBSD.ORG>
From: None <tooleym@douglas.bc.ca>
List: netbsd-help
Date: 02/04/1998 03:31:55
After having received a number of helpful hints as to what might be the
problem, I am still colossally stumped and would like to put my feelers
out there one more time before trying an entirely different tack.

Here's some output from my new program:

status:21562
status:21562
status 21708

Explanation: The actual file length is 21708. See:

7464 -rw-r--r--   1 root  wheel       21708 Feb  4 01:59 player.records

Upon seeking to the end of the file, MINUS the size of my data structure
I print out the lseek()'d return value. 21562. This is a good thing.
I read in the structure..  file pointer should be at SEEK_END once more.
Indeed it is (yea, I checked. :)

I examine the data record. I alter it. I lseek() back to the beginning of
the record, upon which time the SECOND status: value is spit out. Fine!
Perfect!

I write() the data structure back to disk. write returns (sizeof(struct
record)) perfectly. I lseek(datafile, 0, SEEK_END) and thereafter I print
out lseek()'s return value. (Note that status=lseek(), I'm not lseek()'ing
again for printf())

Thus it spits out the THIRD value: 21708, the original size of the file.

THIS SHOULD DO IT..  Right?  Wrong!

ls -lia:

7462 -rw-r--r--   1 root  wheel  4294989004 Feb  4 03:14 player.records

Argh!!!!

I'm probably doing something wrong right? I'm sitting here tearing my hair
out over it! :)  Please show me something that will make me feel
sheepish.. 

Thanks for all your help in the past--and for any you may volunteer in the
future!

Marc Tooley
tooleym@douglas.bc.ca