Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Oct 1998 08:17:08 -0800
From:      Graeme Tait <graeme@echidna.com>
To:        Peihan Wang <peihanw@mx.cei.gov.cn>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: size command under ftp
Message-ID:  <3634A084.5419@echidna.com>
References:  <36346432.2DE86605@mx.cei.gov.cn>

next in thread | previous in thread | raw e-mail | index | archive | help
Peihan Wang wrote:
> 
> I am running an ftp server under FreeBSD 2.2.6.
> When I do the following there is something strange.
> 
> $ ftp localhost
> ... (omit login process)
> ftp> cd pub
> ftp> ls
> total 656
> -rw-r--r--  1 root  operator  321381 Sep  5 04:05 mc-4.1.31.tgz
> ftp> size mc-4.1.31.tgz
> mc-4.1.31.tgz   322545
> ftp> quit
> $
> 
> Why does 'ls' says the file size is 321381 while 'size' indicates
> that the file is 322545 bytes long ???


I believe "size" reports the size the file would have if transferred. By 
default, ftp is in ascii mode, so if you have a file with UNIX newline 
line breaks (LF not preceded by CR) you will gain one byte for each. 
Selecting binary mode should give the raw size. The state of the cr 
toggle may also affect the result with size.

I've seen this mess up a Windows FTP client, which was SIZE-ing the 
remote file in order to resume a failed upload. Trouble was, although the 
file was being transferred in binary mode, the client put the server into 
ascii mode for a directory listing immediately prior to the SIZE request, 
so it got the wrong size number.

I can't find this behaviour of size or SIZE documented in the ftp or ftpd 
man pages, but I do remember having to investigate it in regard to the 
incident mentioned. You might find it in the appropriate RFC. 


-- 
Graeme Tait - Echidna

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3634A084.5419>