Parag Warudkar wrote:On Nov 8, 2005, at 2:39 PM, Bob Copeland wrote:Why is this initialized?Isn't this just because the device size is > 2**32? What if you use fseeko(3)Yep. I got it to return the correct hard disk size (17Gb) using lseek64 and
and #define _FILE_OFFSET_BITS 64?
#define _LARGEFILE64_SOURCE
#define _FILE_OFFSET_BITS 64
Here is what I did
-------------------------------------------------
#define _LARGEFILE64_SOURCE
#define _FILE_OFFSET_BITS 64
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int main()
{
int f;
off64_t off=0;f = open("/dev/hda", O_RDONLY );Why do this? it always returns zero.
if(f <= 0){
perror("open");
exit(0);
}
off = lseek64(f, 0, SEEK_SET);
off = lseek64(f, 0, SEEK_END);RETURN VALUE
perror("llseek");
printf ("Size %lld\n", off);
close(f);
return 0;
}
Upon successful completion, lseek returns the resulting offset
location as measured in bytes from the beginning of the file.
Otherwise, a value of (off_t)-1 is returned and errno is
set to indicate the error.