From: Dirk Pansegrau <pansegra@pluto.mpi-hd.mpg.de>
Subject: problems with setvbuf
Date: 1996/08/15 [thread overview]
Message-ID: <4uv6nf$5h0@sun0.urz.uni-heidelberg.de> (raw)
In order to write data to tape buffered with 32K we used
#include <stdio.h>
char buf[32768],data[32768];
FILE *fp;
main()
{
fp=fopen("/dev/nrmt0h","w");
setvbuf(fp,buf,_IOFBF,sizeof(buf));
fwrite(data,1,sizeof(data),fp);
fclose(fp);
}
trace-output of write:
a.out
Tracing process /proc/1044
4
..
getdtablesize () = 4096
write (4, 0x140000230, 32768) = 32768
..
exit (0) = (0)
EXIT [status=0]
When we tried to read in the data with a corresponding routine (fread), we
found out, that the length of the buffer read from tape was 32K-16Byte=32752
Byte.
trace-output of read:
a.out
Tracing process /proc/1083
4
..
getdtablesize () = 4096
read (4, 0x40000238, 32752) = 32752 [, 0x140000238, ]
read (4, 0x40000238, 32752) = 16 [, 0x140000238, ]
..
exit (0) = (0)
EXIT [status=0]
The read and write system calls cannot be used directly because output has to
be buffered.
Any suggestions to solve this problem would be greatly appreciated.
Thanks
Dirk Pansegrau
reply other threads:[~1996-08-15 4:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox