smdb warp-around after 4 GB

Andreas Karrer karrer at
Mon Nov 5 06:58:03 GMT 2001

I run Samba 2.2.2 on any of there vendors/osversions/filesystems:

  o Solaris 8 / ufs
  o Tru64 Unix V5.0A / advfs
  o RedHat 7.1 / Kernel 2.4.2 / ext2fs

all these are capable of handling large files (files with a
64-bit-offset larger than 4GB). At configure time, samba selects the
proper compile flags (-D_LARGEFILE_SOURCE, -D_FILE_OFFSET_BITS=64)
for use with large files.

The problem: When I back up a Win2000 machine using ntbackup onto a
  file on a samba share, and the backup file is bigger than 4GB, the
  backup is corrupted. This has also been reported by others in the
  comp.protocols.smb newsgroup.

When I run tests using:

  smbclient //127.1/myshare
  smb: \> put 4200MB 4200remote

where `4200MB' is a plain file of 4200 MB, the resulting file will
be only a little bit bigger than 4GB. When I use "truss" or "strace"
on the smbd server, near the 4GB limit I get:

        _llseek(19, 18446744073709406208, [4294821888], SEEK_SET) = 0
        write(19, "UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU"..., 64512) = 64512
        _llseek(19, 18446744073709470720, [4294886400], SEEK_SET) = 0
        write(19, "UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU"..., 64512) = 64512
  [1]   _llseek(19, 18446744073709535232, [4294950912], SEEK_SET) = 0
  [2]   write(19, "UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU"..., 64512) = 64512
 ![3]   _llseek(19, 48128, [48128], SEEK_SET)   = 0
        write(19, "UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU"..., 64512) = 64512
        _llseek(19, 112640, [112640], SEEK_SET) = 0
        write(19, "UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU"..., 64512) = 64512

 [1] seek to (4GB - 16384 bytes)
 [2] write 64512, offset now (4GB + 48128 bytes) = 4295015424
 [3] seek to 48128 instead of (4GB + 48128 bytes) !!!!

This looks very much like a wrap-around of some offset variable that
was declared `unsigned long' instead of `off_t'. By looking at the
source, I cannot find an obvious point where this would happen, though.

When I read a file from a samba server bigger than 4GB with something like:

  smbclient //127.1/myshare 
  smb: \> get 4200MB 4200local

the file `4200local' grows without bounds. Using "truss", I find that there is a similar
warp-around after 4 GB.

Questions :
  o Is smbd supposed to be large-file-proof, e.g. capable of handling files
    larger than 4 GB?
      *  On Solaris 8?
      *  On Tru64 Unix?
      *  On RedHat 7.1 / Kernel 2.4.2 / ext2?

  o Is smbclient supposed to be large-file-proof? (I see a few minor
    problems in the source; the variables get_total_size,
    put_total_size, nread in client/client.c should be declared
    as off_t.

  o Am I missing something really obvious, such as a smb.conf file option?


 - Andi Karrer

More information about the samba mailing list