[comp.unix.questions] Limitations of cp and mv?

maryhc@hpcc01.HP.COM (Mary Hsia-Coron) (05/17/91)

I read in the AT&T System V release 4 manual pages that:

    - cp and mv cannot transfer DIRECTORIES across
      different file systems.

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?

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

3) Does this limitation exist on your system? Please include info on:
    * What flavor of UNIX you have (ULTRIX, SUN, ZENIX, HP-UX, etc.)
    * Whether your UNIX system is based on AT&T system V, BSD 4.3, or a hybrid.
       
Thanks for any info you can provide!
Hewlett-Packard Customer Training
Mary Hsia-Coron

urban@cbnewsl.att.com (john.urban) (05/17/91)

In article <2570004@hpcc01.HP.COM> maryhc@hpcc01.HP.COM (Mary Hsia-Coron) writes:
>
>I read in the AT&T System V release 4 manual pages that:
>
>    - cp and mv cannot transfer DIRECTORIES across
>      different file systems.
>
>I'm writing some documentation and cannot verify this limitation
>of cp and mv on a wide range of UNIX systems.
>
>Questions:
>----------
>
>2) Does this limitation exist on System V systems PRIOR to release 4?
	Yes
>
>3) Does this limitation exist on your system? Please include info on:
>    * What flavor of UNIX you have (ULTRIX, SUN, ZENIX, HP-UX, etc.)
>    * Whether your UNIX system is based on AT&T system V, BSD 4.3, or a hybrid.

	Yes.  I'm running AT&T UNIX System V/x86 Release 4.0 Version 2.1

mv(1) has changed between 3.2 and 4.0.   Prior to 4.0, you could not even
mv directories within a filesystem!  This is why the mvdir(1M) command existed
prior to 4.0.  Now in 4.0 you can mv directories around on the same filesystem
but you still cannot move them across filesystem.

i.e:
$ mount
/ on /dev/root read/write/setuid on Tue May  7 15:31:27 1991
/home on /dev/dsk/0s4 setuid/read/write/noquota on Tue  7 15:35:49 1991
$ mkdir /tmp/T
$ cp /etc/passwd /tmp/T/P
$ pwd
/home/install
$ mv /tmp/T /home/install
mv: can't mv directories across file systems
$ mv /tmp/T /tmp/apples
$

Sincerely,

John Ben Urban

jfv@cbnewsk.att.com (j.f.van valkenburg) (05/17/91)

In article <2570004@hpcc01.HP.COM>, maryhc@hpcc01.HP.COM (Mary Hsia-Coron) writes:
> 
> I read in the AT&T System V release 4 manual pages that:
> 
>     - cp and mv cannot transfer DIRECTORIES across
>       different file systems.
> 

This is correct, the files in a directory can but the directory itself
cannot be moved using cp or mv. However; the cpio -pdvu command can copy
whole directory tree's across file systems.

> 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?
> 
> 2) Does this limitation exist on System V systems PRIOR to release 4?

it is under SVr2 ->

> 
> 3) Does this limitation exist on your system? Please include info on:
>     * What flavor of UNIX you have (ULTRIX, SUN, ZENIX, HP-UX, etc.)
>     * Whether your UNIX system is based on AT&T system V, BSD 4.3, or a hybrid.
we use ( big suprise) ATT 3B2 line of unix boxes, and ATT UNIX too.

>        
> Thanks for any info you can provide!
> Hewlett-Packard Customer Training
> Mary Hsia-Coron


------------------------
James F. Van Valkenburg         a.k.a.  "van"
AT&T 				Attmail: !jfv               jfv@cbnewsk.att.com
Atlanta, GA.			Voice  404-873-7920
===============================================================================

   ---- Standard Disclaimers included -- Just another grunt at AT&T ----

===============================================================================

Dan_Jacobson@ATT.COM (05/19/91)

>>>>> On Fri, 17 May 1991 12:54:35 GMT, urban@cbnewsl.att.com (john.urban) said:

john.urban> mv(1) has changed between 3.2 and 4.0.  Prior to 4.0, you
john.urban> could not even mv directories within a filesystem!

Well, you could rename directories:

ihlpz 15:18 1..mail> cd /tmp
ihlpz 15:19 1./tmp> mkdir a
ihlpz 15:19 1./tmp> mv a b
ihlpz 15:19 1./tmp> mv b /usr/tmp/b
mv: directory rename only
2ihlpz 15:19 1./tmp> uname -a
uts ihlpz 5.2.6b 5 5890

guy@auspex.auspex.com (Guy Harris) (05/20/91)

>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.

djm@eng.umd.edu (David J. MacKenzie) (05/20/91)

In the next few years, I expect that most systems' cp and mv will
start picking up the ability to properly copy or move directory
hierarchies, because POSIX.2 will require them to do so.
cp -R (uppercase) will copy while preserving file types, and
mv (no special option needed -- I don't like that part) will move
entire directory trees across filesystems transparently.
--
David J. MacKenzie <djm@eng.umd.edu> <djm@ai.mit.edu>

gwyn@smoke.brl.mil (Doug Gwyn) (05/21/91)

In article <DJM.91May19175716@egypt.eng.umd.edu> djm@eng.umd.edu (David J. MacKenzie) writes:
>mv (no special option needed -- I don't like that part) will move
>entire directory trees across filesystems transparently.

Well, it CAN'T.  Hard links into the hierarchy from outside it cannot be
preserved by such a move.

Where in the world did POSIX.2 get the idea of -R?  I've already determined
that we are NOT going to be specifying POSIX.2 in any procurements I'm
involved in -- why would I want to specify an incompatible, non-UNIX system
instead of the subset of UNIX that I really need?