[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
Title: | DEC C Problem Reporting Forum |
Notice: | Report DEC C++ problems in TURRIS::C_PLUS_PLUS |
Moderator: | CXXC::REPETE TCHEON |
|
Created: | Fri Nov 13 1992 |
Last Modified: | Fri Jun 06 1997 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 1299 |
Total number of notes: | 6249 |
1268.0. "Representing values on UFS or ADVFS different 4.0B" by MDR01::ARANCHA (MCS Madrid) Wed Mar 05 1997 05:04
Hi,
My customer has reported the following error on Digital UNIX 4.0B.
This program osftest.c uses only system calls, it creates a file veria.bdf
of 18944 bytes, fills the first blocks with 1.1 and then writes from
address 6656 on 12000 bytes (representing 3000 floating point values going
from 0.0 to 29.99 in steps of 0.01).
All system calls execute successfully. But when you do
> od -f veria.bdf
you see that the last value written is only: 2.4309999e+01.
This happens on a directory which is set up with DEC's advanced file system.
If I do the same in a directory set up with DEC's UFS the program
works o.k. (last value = 2.9990000e+01)
This is very critical for the application customer.
Has anybody any idea ??
Thanks in the advance,
Arancha
*************************
Program : OSFTEST.C
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
/*
#define O_write (O_WRONLY | O_CREAT)
*/
#define O_write O_RDWR
/*
*/
long oskseek(fid, address)
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
.PURPOSE moves the file pointer.
The argument fid is the file identification
obtained from osdopen. The address defines
the pointer position in bytes relative to:
start of the file, current position or end of the file as
defined by the variable mode (FILE_START, FILE_CURRENT, FILE_END).
(see midas/osparms.h). (i.e. : an address=0 and OS_START set means
first byte of the file).
.RETURNS Upon successful completion, the resulting pointer position
.RETURNS measured in bytes is returned, in case of error -1L.
.REMARKS System dependencies:
-- UNIX: lseek(2)
------------------------------------------------------------*/
int fid; /* file identification */
long address; /* file pointer */
{
int mode;
off_t ret;
mode = SEEK_SET;
if ((ret = lseek(fid, (off_t)address, mode)) == (off_t)-1)
printf("oskseek: error...\n");
else
printf("oskseek: addr = %ld, retpntr = %ld\n",address,(long)ret);
return((long)ret);
}
/*
*/
main()
{
char *mypntr;
char *cbuf;
int size, status, kk;
int fid, nr, n, allbytes;
long int addr;
float *fpntr, fbuf[512];
for (nr=0; nr<512; nr++) fbuf[nr] = 1.1;
cbuf = (char *)fbuf;
/* create file on disk with size = 18944 bytes */
fid = creat("veria.bdf",0666);
if (fid < 0)
printf("creat: problems with creat...\n");
n = 18944;
addr = n - 1; /* move to last byte */
status = oskseek(fid,addr);
if (status != -1)
{
char c;
c = ' ';
n = 1; /* write 1 byte */
if ((kk = write(fid,&c,(unsigned int)n)) == -1)
printf("write failed...\n");
else
printf("write: nobyt = %d, ret = %d\n",n,kk);
}
if (close(fid) < 0) printf("'roblems with close...\n");
fid = open("veria.bdf",O_write,0666);
allbytes = 12000;
mypntr = (char *) malloc((size_t) allbytes);
printf("mypntr = %x\n",mypntr);
fpntr = (float *) mypntr;
for (nr=0; nr<3000; nr++)
{
*fpntr++ = 0.01 * nr;
}
addr = 0;
n = 512;
status = oskseek(fid,addr);
if (status != -1)
{
if ((kk = write(fid,cbuf,(unsigned int)n)) == -1)
printf("write failed...\n");
else
printf("write: nobyt = %d, ret = %d\n",n,kk);
}
addr += 512; /* 512 */
n = 2048;
status = oskseek(fid,addr);
if (status != -1)
{
if ((kk = write(fid,cbuf,(unsigned int)n)) == -1)
printf("write failed...\n");
else
printf("write: nobyt = %d, ret = %d\n",n,kk);
}
addr +=2048; /* 2560 */
n = 2048;
status = oskseek(fid,addr);
if (status != -1)
{
if ((kk = write(fid,cbuf,(unsigned int)n)) == -1)
printf("write failed...\n");
else
printf("write: nobyt = %d, ret = %d\n",n,kk);
}
addr +=2048; /* 4608 */
n = 2048;
status = oskseek(fid,addr);
if (status != -1)
{
if ((kk = write(fid,cbuf,(unsigned int)n)) == -1)
printf("write failed...\n");
else
printf("write: nobyt = %d, ret = %d\n",n,kk);
}
addr +=2048; /* 6656 */
status = oskseek(fid,addr);
if (status != -1)
{
if ((kk = write(fid,mypntr,(unsigned int)allbytes)) == -1)
printf("write failed...\n");
else
printf("write: nobyt = %d, ret = %d\n",allbytes,kk);
}
close(fid);
}
T.R | Title | User | Personal Name | Date | Lines |
---|
1268.1 | Sounds like a UNIX question. | DECC::VOGEL | | Wed Mar 05 1997 09:16 | 10 |
|
Arancha,
As this sounds like UNIX problem, and not a C problem, could you
re-post this question in TURRIS::DIGITAL_UNIX?
Ed
|