[comp.unix.questions] ftp/rcp can't copy devices

hulsebos@philmds.UUCP (Rob Hulsebos) (08/29/88)

When I use the 'ftp' or 'rcp' command, and want to copy a disk-partition
(accessed via /dev/rdsk/*) to the other end, both utilities
complain: "not a plain file".

Of course, the manual doesn't mention that only plain files can be
transferred. Does anybody know why ftp and rcp behave this way?

Suprisingly, copying _to_ a device is allowed. An ftp-command like
"put /unix /dev/null" works fine, and is a nice trick to test the overhead
incurred by the filesystem on the receiving end.

------------------------------------------------------------------------------
R.A. Hulsebos                                       ...!mcvax!philmds!hulsebos
Philips I&E Automation Modules                            phone: +31-40-785723
Building TQ-III-1, room 11
Eindhoven, The Netherlands                                # cc -O disclaimer.c
------------------------------------------------------------------------------

chris@mimsy.UUCP (Chris Torek) (08/30/88)

In article <779@philmds.UUCP> hulsebos@philmds.UUCP (Rob Hulsebos) writes:
>When I use the 'ftp' or 'rcp' command, and want to copy a disk-partition
>(accessed via /dev/rdsk/*) to the other end, both utilities
>complain: "not a plain file".
>
>Of course, the manual doesn't mention that only plain files can be
>transferred. Does anybody know why ftp and rcp behave this way?

Both attempt to determine the size of the file before sending it.
(Only rcp's protocol actually requires this.)  There is no way to
find the size of a special file without reading it, and in the process
the data may vanish (e.g., reading /dev/tty or a socket).
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris

dupuy@douglass.columbia.edu (Alexander Dupuy) (08/30/88)

Actually, it is possible to copy from a device, using a somewhat obscurely
documented feature of ftp.  You can specify a shell command as the source or
destination of a tranfer - the command runs on the local machine in either
case.  An example which I used just a few weeks ago:

% ftp another_machine
				# password/login deleted
ftp> send "|dd if=/dev/rst8" somefile.tar
				# silly messages from dd and ftp deleted
ftp> bye
%

You don't need the quotes if the command is one word.  This can be quite useful
for spooling dumps to a remote machine which doesn't support /etc/rmt - a big
IBM mainframe with _lots_ of disk space is ideal.  By creating a ~/.netrc file,
you can even have ftp batch jobs to spool your dumps.

As Chris Torek noted, the rcp protocol requires that the size of the file be
known, which is not possible in general for devices.  There is no equivalent
feature (that I know of) in rcp to allow sending from programs.

@alex

-- 
inet: dupuy@columbia.edu
uucp: ...!rutgers!columbia!dupuy