Re: lseek: Value too large for defined data type
- From: guru <guru.naveen@xxxxxxxxx>
- Date: Tue, 24 Jul 2007 07:09:43 -0000
I am unable to seek. again same error it is giving.
First i will write 21GB then run the below program
The program
#define _GNU_SOURCE
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <fcntl.h>
#include<sys/types.h>
#include<sys/stat.h>
main()
{
int file = 0;
char *buff = NULL;
int bytewr,count=0,loopcount,choice;
long long seekOffset = 0;
buff = (char *)malloc(1024 * 1024);
if(buff == NULL)
{
printf("Memory Allocation failed\n");
return -1;
}
else
{
printf("Memory allocation success\n");
}
file = open("/HDR1/test1.txt", O_LARGEFILE|O_RDWR);
if(file == -1)
{
printf("Error opening file\n");
return -1;
}
else
{
printf("File opening success\n");
}
/*1MB seek*/
seekOffset = lseek(file,(1024*1024),SEEK_CUR);
if(seekOffset == -1)
{
printf("Seek Fail\n");
return -1;
}
else
{
printf("Seek Success=%d\n",seekOffset);
}
memset(buff,0x44,(1024*1024));
loopcount = 10240; /*do it for this many times*/
{
count = 0;
do {
bytewr = write(file, buff,(1024*1024));
if(bytewr == (1024*1024))
{
printf("Count: %d Write Success\n",count); }
else
{
printf("Write fail\n");
return -1;
}
if((count%100) == 0)
{
/*Seek afterevery
100MB*/
seekOffset = lseek(file,(1024),SEEK_CUR);
if(seekOffset == -1)
{
printf("Seek Fail\n");
return -1;
}
else
{
printf("Seek Success=%Ld\n",seekOffset);
}
}
}while(count++ < loopcount);
close(file);
free(buff);
}
while compiling i have to give
gcc -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE append.c -o append
after 2100 loop, it is failing.
is there any problem with application.
Regards
Gururaja
spacecriter (Bill C) wrote:
guru wrote:
Hi All,
I have written 21GB file and updating the file by seeking 1K and
writing 100MB of data consecutively 10240 times. when after writing
2GB(2100 times) of file it was giving
lseek: Value too large for defined data type error.
What is got is the value passed to 'Offset' argument is too large to
handle.
The last return value of seek is '2099270656'
Is there any way to overcome this.
As others have said, add -D_FILE_OFFSET_BITS=64 to the compiler command line
I have found that it is a good idea to also add -D_LARGEFILE64_SOURCE to the
command line as well.
--
Bill C.
.
- Follow-Ups:
- Re: lseek: Value too large for defined data type
- From: Tim Southerwood
- Re: lseek: Value too large for defined data type
- References:
- lseek: Value too large for defined data type
- From: guru
- Re: lseek: Value too large for defined data type
- From: spacecriter \(Bill C\)
- lseek: Value too large for defined data type
- Prev by Date: Re: lseek: Value too large for defined data type
- Next by Date: Process D state
- Previous by thread: Re: lseek: Value too large for defined data type
- Next by thread: Re: lseek: Value too large for defined data type
- Index(es):
Relevant Pages
|
|