Limitations of cp and mv?

Guy Harris guy at auspex.auspex.com
Mon May 20 04:29:40 AEST 1991


>I read in the AT&T System V release 4 manual pages that:
>
>    - cp and mv cannot transfer DIRECTORIES across
>      different file systems.

That's interesting, because the S5R4 manual *I* have indicates that "cp"
has the "-r" flag, which means it can, sort of, transfer a directory
*hierarchy* across different file systems, or even across the same one. 
It probably has, of course, limitations similar to BSD's "cp -r", namely
that it doesn't "lstat()" files and, as such, doesn't preserve symbolic
links.

>I'm writing some documentation and cannot verify this limitation
>of cp and mv on a wide range of UNIX systems.
>
>Questions:
>----------
>
>1) Does this limitation of cp and mv exist on BSD 4.3 based systems?

Yes.

For "mv" to move directories between file systems, on all UNIX file
systems with which I'm familiar, it'd have to, in effect, do a recursive
copy of the hierarchy under that directory (and preserve symbolic links,
if you want it to act in a fashion similar the the way it acts when
moving a directory within a file system), and then a recursive remove of
the old hierarchy when the copy is done.  I don't know if anybody's ever
bothered tweaking "mv" to do that....

"cp"ing a directory pretty much means "cp -r"ing it, in any case; see
above for a discussion of that.

>2) Does this limitation exist on System V systems PRIOR to release 4?

Yes.  See previous paragraph; prior to S5R4, S5 from AT&T didn't have
the "-r" flag, so it's even more limited (although, given that "cp -r"
doesn't preserve symbolic links, you're often better off using "cpio" or
"tar", rather than "cp -r", to copy the hierarchy in any case).

>3) Does this limitation exist on your system?

It probably does for most if not all values of "your system".  See above.



More information about the Comp.unix.questions mailing list