Re: Order of files with 'cp'

From: Brian Candler <B.Candler_at_pobox.com>
Date: Sun, 20 Nov 2005 20:50:26 +0000
On Sun, Nov 20, 2005 at 12:27:06PM -0800, Tim Kientzle wrote:
> >Erm, but that just undoes the reason for calling fts_open with mastercmp in
> >the first place, which is to get it to pick files before directories (or
> >vice versa, as its behaviour seems to be) as an 'optimisation'.
> 
> Why is that an optimization?

I'm only regurgitating what is written in /usr/src/bin/cp/cp.c:

/*
 * mastercmp --
 *      The comparison function for the copy order.  The order is to copy
 *      non-directory files before directory files.  The reason for this
 *      is because files tend to be in the same cylinder group as their
 *      parent directory, whereas directories tend not to be.  Copying the
 *      files first reduces seeking.
 */

> I thought the whole point of this thread was that users
> expect utilities to process the command-line arguments
> in the order they're given.

That wasn't the point I made at the start of the thread - somebody else
brought up POLA - although I would be happy for cp to process command-line
arguments strictly in the order they are given (in which case, you just
replace mastercmp with NULL when calling fts_open)

I suggested that if the above 'optimisation' makes sense, it should still be
possible to make cp copy arguments in the order given if they are all files
or all directories. I gave some suggested ways of achieving this.

Regards,

Brian.
Received on Sun Nov 20 2005 - 19:50:30 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:48 UTC