bin/89100: premature EOF with ftpd on some large files

Deomid Ryabkov myself at
Mon Dec 5 21:00:22 GMT 2005

The following reply was made to PR bin/89100; it has been noted by GNATS.

From: Deomid Ryabkov <myself at>
To: bug-followup at, dkelly at
Subject: Re: bin/89100: premature EOF with ftpd on some large files
Date: Mon, 05 Dec 2005 23:44:05 +0300

 i have similar problem: sendfile(2) returns prematurely,
 when exactly 2^32 bytes left to transfer.
 this is demonstrated by ftpd (which uses sendfile), but applies to
 apache too (if configured with enablesendfile yes).
 in my case, sendfile misbehaves only when asked to send file residing on
 NFS-mounted filesystem.
 this seems to happen to all files > 4G resiging on NFS-mounted
 filesystems. those same files can be read without problem with read(2),
 therefore copying with cp(1) succeeds.
 while tracking down the problem i set up a local ftp server on my
 notebook, rooted at /stuff/ftp.
 i was able to download a large file residing on local hard disk without
 nb[/stuff/ftp]# fetch -o /dev/null
 /dev/null                                     100% of 4469 MB   14 MBps
 then i tried downloading the same file from NFS-mounted filesystem:
 nb[/stuff/ftp]# mount
 tux:/spool on /stuff/ftp/spool (nfs)
 nb[/stuff/ftp]# fetch -o /dev/null
 /dev/null                                       8% of 4469 MB 7310 kBps
 fetch: /dev/null appears to be truncated: 391739392/4686706688 bytes
 and another one:
 nb[/stuff/ftp]# fetch -o /dev/null
 /dev/null                                       3% of 4223 MB 7367 kBps
 fetch: /dev/null appears to be truncated: 133883904/4428851200 bytes
 in both cases, transfer ends at exactly 4294967296=2^32 bytes before
 actual end of file.
 one line of debug output added to ftpd.c shows that sendfile actually
 returns without error, with correct amount of transferred bytes:
 Dec  5 23:34:26 nb ftpd[55338]: sendfile returned 0, errno=2,
 Dec  5 23:39:21 nb ftpd[55352]: sendfile returned 0, errno=2,

More information about the freebsd-bugs mailing list