scp doesn't work with large (>2GB) files

Jani Jaakkola jjaakkol at cs.Helsinki.FI
Wed Sep 12 23:47:06 EST 2001


On Wed, 12 Sep 2001, Jani Jaakkola wrote:

> My educated guess is, that if you include '#define _FILE_OFFSET_BITS 64'
> into every .c file (preferably by config.h) in openssh distribution or
> just use  '-D_FILE_OFFSET_BITS=64' while compiling it, it would work just
> fine with >2G files assuming you have glibc >= 2.1 and kernel >=2.4 (or
> 64 bit hardware, but then you won't need _FILE_OFFSET_BITS).

Now that I think of it, it should be simple as this:

$ pwd
/home/jjaakkol/src/openssh-2.9p2
$ CFLAGS=-D_FILE_OFFSET_BITS=64 ./configure
<SNIP configure output>
$ make
<SNIP compilation output>
$ strace -e open ./scp scp.c localhost:/dev/null
open("/etc/ld.so.preload", O_RDONLY)    = -1 ENOENT (No such file or
directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
open("/usr/lib/libz.so.1", O_RDONLY)    = 3
open("/lib/libnsl.so.1", O_RDONLY)      = 3
open("/lib/libutil.so.1", O_RDONLY)     = 3
open("/usr/lib/libcrypto.so.1", O_RDONLY) = 3
open("/lib/libcrypt.so.1", O_RDONLY)    = 3
open("/lib/libc.so.6", O_RDONLY)        = 3
open("/lib/libdl.so.2", O_RDONLY)       = 3
open("/etc/nsswitch.conf", O_RDONLY)    = 3
open("/etc/ld.so.cache", O_RDONLY)      = 3
open("/lib/libnss_files.so.2", O_RDONLY) = 3
open("/etc/passwd", O_RDONLY)           = 3
jjaakkol at localhost's password:
open("scp.c", O_RDONLY|O_LARGEFILE)     = 3
scp.c                100% |*****************************| 29441       00:00
$

So as you see, scp implicitly uses O_LARGEFILE when compiled with
-D_FILE_OFFSET_BITS=64. Just remember that you need to have it enabled
both in server and client for it to actually work assuming that
openssh does not expect sizeof(off_t)==sizeof(long). I did not bother to
actually test it, since most of my machines are still running 2.2 kernel.

- Jani




More information about the openssh-unix-dev mailing list