From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,9d35f8b9f52910ed,start X-Google-Attributes: gidfee84,public From: Dirk Pansegrau Subject: problems with setvbuf Date: 1996/08/15 Message-ID: <4uv6nf$5h0@sun0.urz.uni-heidelberg.de>#1/1 X-Deja-AN: 174373972 content-type: text/plain; charset=us-ascii organization: MPI fuer Kernphysik, Heidelberg x-url: newspost:comp.unix.osf.osf1 mime-version: 1.0 newsgroups: comp.unix.osf.osf1 x-mailer: Mozilla 1.1N (X11; I; OSF1 V3.0 alpha) In order to write data to tape buffered with 32K we used #include 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