Kevin Lawton wrote:
> I turned on compiler warnings, and not only was llseek not
> defined, but the linker warned against its use and suggested
> using lseek64.
If your libc really doen't have llseek, try using the syscall
directly. This version should work across (nearly) all Linux
kernels / libcs ...
Bye,
Ulrich
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/unistd.h>
_syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, loff_t *, res, uint, wh);
int _llseek(unsigned int fd, unsigned long offset_high,
unsigned long offset_low, loff_t *result, unsigned int whence);
loff_t my_llseek( unsigned int fd, loff_t offset, unsigned int whence )
{
loff_t res;
int retv;
retv = _llseek( fd, (unsigned long)( offset >> 32 ),
(unsigned long) offset, &res, whence );
if ( retv < 0 )
{
errno = -retv;
return (loff_t)-1;
}
return res;
}
int main( void )
{
char buf[0x100];
int fd, count;
loff_t off, target;
fd = open( "/dev/hda", O_RDONLY );
if ( fd < 0 )
{
perror( "open" );
exit( 1 );
}
target = (loff_t)(1ULL << 32);
off = my_llseek( fd, target, SEEK_SET );
printf( "off = 0x%llx\n", off );
if ( off != target )
{
perror( "llseek" );
exit( 1 );
}
count = read( fd, buf, 0x100 );
printf( "count = %d\n", count );
if ( count != 0x100 )
{
perror( "read" );
exit( 1 );
}
return 0;
}
--
Dr. Ulrich Weigand
[EMAIL PROTECTED]