🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.sun
Article #7423

fwrite() and BUFSIZ

#7423
From: Douglas Harvey
Date: Wed, 17 Apr 1991 01:00
28 lines
1935 bytes
I am having a problem setting up my own buffers for fwrite using
setvbuf().  Incidently, I'm running on a Sun sparcstation running SunOS
4.1.

We work alot with tape files, both from clients (usually created on IBM
mainframe systems) and tapes we create internally by writing directly to
the device, eg. fopen("/dev/rst8","w").

However, I've come up against a couple of problems.  One, for some reason
I had to add eight (8) to the blocksize before the tape would get blocked
at the desired blocksize.  For example, if I wanted a blocksize of 10,000,
I would need to call setvbuf() with a size of 10,008 bytes.  Does fwrite()
reserve 8 bytes for a couple of 4-byte pointers or something?  I could not
find any mention of this.

The second problem I have yet to solve.  All of this works fine when the
size of the structure I'm fwrite()'ing is less than 1024 bytes in length.
Once I get above this size, the blocksize will be the same as the record
size.  This seems a little suspicious since the default buffer size for
fread/fwrite is 1,024 bytes.  Is this a bug with Sun OS, or is this just
the way it works?

Any comments, etc. welcomed.

Douglas Harvey                      Email: drharvey@chinet.UUCP
Ronald J. Krumm & Associates, Inc.  Compuserve: 72341,104
1 Riveside Road                     Phone: (708) 447-1771
Riverside, IL  60546
Technical Details
Message-ID: <2461@brchh104.bnr.ca>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!cunews!bnrgate!brtph3!brchh104!brchs1!bnr.ca!rice.edu!sun-spots-request

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!cunews!bnrgate!brtph3!brchh104!brchs1!bnr.ca!rice.edu!sun-spots-request
From: drharvey@chinet.chi.il.us (Douglas Harvey)
Newsgroups: comp.sys.sun
Subject: fwrite() and BUFSIZ
Keywords: Miscellaneous
Message-ID: <2461@brchh104.bnr.ca>
Date: 17 Apr 91 01:00:00 GMT
Sender: news@brchh104.bnr.ca
Organization: Sun-Spots
Lines: 28
Approved: Sun-Spots@rice.edu
X-Original-Date: Wed, 10 Apr 1991 18:12:17 GMT
X-Sun-Spots-Digest: Volume 10, Issue 81, message 18
X-Note: Submissions: sun-spots@rice.edu, Admin: sun-spots-request@rice.edu