fwrite,fread - Is this a bug or a known feature
Hi,
once again I don't know whether this is the right list for this question.
We see a problem with the functions fwrite/fread from glibc under ia64.
Code:
f = fopen(key, "wb");
wrote_elements = fwrite((long*)(shm + table->ebene3Index),
sizeof(char),
table->ebene3Count,
f);
fclose(f);
If we write anything below two giga elements (element size is one byte)
=> 2GB data everything works perfect.
Trace from gdb with table->ebene3Count = 2147483592 (Below 2GB)
1112 wrote_elements = fwrite((long*)(shm + table->ebene3Index), sizeof(char), table->ebene3Count, f);
(gdb) next
1113 fclose(f)
(gdb) print wrote_elements
$2 = 2147483592
OK !!
Trace from gdb with table->ebene3Count = 2147483656 (Over 2GB)
1112 wrote_elements = fwrite((long*)(shm + table->ebene3Index), sizeof(char), table->ebene3Count, f);
(gdb) next
1113 fclose(f)
(gdb) print wrote_elements
$1 = 0
Problems:
1. wrote_elements is 0
2. File on disk is only 2147483648 bytes big.
It looks to me, that the file size is rounded down to a multiple of
the pagesize (16KB).
The same happens, if you use fread to read the files in again.
Is this a known feature of fwrite/fread?
We compile using the falgs -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE.
Are they ok for ia-64?
Yours,
markus
Reply to: