summaryrefslogtreecommitdiff
path: root/bin/cp
diff options
context:
space:
mode:
authorpooka <pooka@NetBSD.org>2009-09-29 13:30:17 +0000
committerpooka <pooka@NetBSD.org>2009-09-29 13:30:17 +0000
commitc817a14b24129820f3d9be15041b07dc50e4416e (patch)
tree0425f32c4aa4bd2785d671f652e27f6a1b177f74 /bin/cp
parentc33877d5b2baf29f6ea451871a7a1f4bf63fcb7d (diff)
Remove fts sorting. It was originally put there to copy files
before directories since files (usually) are in the same cylinder group and subdirectories aren't. However, this mostly changed with the new ffs dirpref algorithm in 2001. No sorting has two effects: 1) copy appears to be somewhat faster (e.g. on my laptop cp'ing build objdir to tmpfs is 7% faster after the change) 2) source file parameters no longer get randomly shuffled due to fts doing an unstable sort of them. this means that "cp 1 2 3 4 dest/" will copy the files in that order instead of e.g. 3 4 1 2.
Diffstat (limited to 'bin/cp')
-rw-r--r--bin/cp/cp.c33
1 files changed, 3 insertions, 30 deletions
diff --git a/bin/cp/cp.c b/bin/cp/cp.c
index 4590df52d33..2efe9c667bf 100644
--- a/bin/cp/cp.c
+++ b/bin/cp/cp.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cp.c,v 1.51 2008/07/20 00:52:39 lukem Exp $ */
+/* $NetBSD: cp.c,v 1.52 2009/09/29 13:30:17 pooka Exp $ */
/*
* Copyright (c) 1988, 1993, 1994
@@ -43,7 +43,7 @@ __COPYRIGHT(
#if 0
static char sccsid[] = "@(#)cp.c 8.5 (Berkeley) 4/29/95";
#else
-__RCSID("$NetBSD: cp.c,v 1.51 2008/07/20 00:52:39 lukem Exp $");
+__RCSID("$NetBSD: cp.c,v 1.52 2009/09/29 13:30:17 pooka Exp $");
#endif
#endif /* not lint */
@@ -92,7 +92,6 @@ enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE };
int main(int, char *[]);
int copy(char *[], enum op, int);
-int mastercmp(const FTSENT **, const FTSENT **);
int
main(int argc, char *argv[])
@@ -295,7 +294,7 @@ copy(char *argv[], enum op type, int fts_options)
dne = 0;
base = 0; /* XXX gcc -Wuninitialized (see comment below) */
- if ((ftsp = fts_open(argv, fts_options, mastercmp)) == NULL)
+ if ((ftsp = fts_open(argv, fts_options, NULL)) == NULL)
err(EXIT_FAILURE, "%s", argv[0]);
/* NOTREACHED */
for (any_failed = 0; (curr = fts_read(ftsp)) != NULL;) {
@@ -515,29 +514,3 @@ copy(char *argv[], enum op type, int fts_options)
(void)fts_close(ftsp);
return (any_failed);
}
-
-/*
- * 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.
- */
-int
-mastercmp(const FTSENT **a, const FTSENT **b)
-{
- int a_info, b_info;
-
- a_info = (*a)->fts_info;
- if (a_info == FTS_ERR || a_info == FTS_NS || a_info == FTS_DNR)
- return (0);
- b_info = (*b)->fts_info;
- if (b_info == FTS_ERR || b_info == FTS_NS || b_info == FTS_DNR)
- return (0);
- if (a_info == FTS_D)
- return (-1);
- if (b_info == FTS_D)
- return (1);
- return (0);
-}