Skip to contentSkip to conversation

smbfs: lseek returns EINVAL when using large files.

DISCUSSION Mathieu Fluhr 2 participants 2 messages Apr 11, 2005

lore
Share & tools
lore
#0 lore raw

Hello

It seems that the smbfs driver does not handle correctly large files (>2GB). The thing is that statting them is correct (for example, the st_size field is correctly set), but as soon as you try to make a lseek with an offset larget than INT_MAX, you get a EINVAL error.

Note: This is not coming out of the remote samba server (Tested with under windows, and it is working fine).

I'm using a 2.6.10 kernel without external patches. I parsed the 2.6.11 changelog to see if this problem has been fixed, but I didn't found anything related. If this has already been discussed, just let me know ;-)

You can reproduce this bug with this little program:

-8<------------------------------------------

/* Enable large file support for x86 */
#define _FILE_OFFSET_BITS 64

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <limits.h>
#include <stdio.h>

int main(int argc, char **argv)
{
int fd = open(argv[1], O_RDONLY);
if(fd == -1)

    perror("open");
  struct stat st;
  fstat(fd, &st);

  printf("filesize: %llu\n", st.st_size);

  /* Go at end... */
  if(lseek(fd, 0, SEEK_END) == (off_t)(-1))
    perror("lseek");

close(fd);
return 0;
}

-8<------------------------------------------

Best Regards,
Mathieu Fluhr

#1 lore raw
Quoted 6 lines · Mathieu Fluhr

Hello

It seems that the smbfs driver does not handle correctly large files (>2GB). The thing is that statting them is correct (for example, the st_size field is correctly set), but as soon as you try to make a lseek with an offset larget than INT_MAX, you get a EINVAL error.

have you tried the cifs client, which is new in 2.6 and is the more actively maintained way to access windows shares and samba ?