From owner-freebsd-current@FreeBSD.ORG Sun Nov 20 20:50:30 2005 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D709A16A4D4; Sun, 20 Nov 2005 20:50:30 +0000 (GMT) (envelope-from b.candler@pobox.com) Received: from thorn.pobox.com (thorn.pobox.com [208.210.124.75]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7330743D46; Sun, 20 Nov 2005 20:50:30 +0000 (GMT) (envelope-from b.candler@pobox.com) Received: from thorn (localhost [127.0.0.1]) by thorn.pobox.com (Postfix) with ESMTP id 7712A2BB; Sun, 20 Nov 2005 15:50:51 -0500 (EST) Received: from mappit.local.linnet.org (212-74-113-67.static.dsl.as9105.com [212.74.113.67]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by thorn.sasl.smtp.pobox.com (Postfix) with ESMTP id 25354F27; Sun, 20 Nov 2005 15:50:50 -0500 (EST) Received: from brian by mappit.local.linnet.org with local (Exim 4.54 (FreeBSD)) id 1Edw8o-00059W-H1; Sun, 20 Nov 2005 20:50:26 +0000 Date: Sun, 20 Nov 2005 20:50:26 +0000 From: Brian Candler To: Tim Kientzle Message-ID: <20051120205026.GA19791@uk.tiscali.com> References: <20051116161540.GB4383@uk.tiscali.com> <437F7E22.5050800@freebsd.org> <20051120192914.GC19572@uk.tiscali.com> <4380DC1A.9030201@freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4380DC1A.9030201@freebsd.org> User-Agent: Mutt/1.4.2.1i Cc: freebsd-current@freebsd.org Subject: Re: Order of files with 'cp' X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Nov 2005 20:50:31 -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.