Home | History | Annotate | Download | only in cp
History log of /src/bin/cp/cp.c
RevisionDateAuthorComments
 1.63  07-Jun-2024  andvar s/concatentation/concatenation/ in comment.
 1.62  22-May-2020  christos fix reversed test.
 1.61  17-May-2020  christos No ACL support for install media (SMALLPROG)
 1.60  16-May-2020  christos Add ACL support for FFS. From FreeBSD.
 1.59  05-Mar-2016  uwe branches: 1.59.16;
The '-i' flag should work regardless of whether the standard input is
a terminal. The Open Group notes this historic behavior and correctly
notes that it doesn't make much sense. Note also, that mv(1) has
always respected its '-i' regardless of whether the standard input is
a terminal.

From Timo Buhrmester.
 1.58  04-Jan-2012  christos branches: 1.58.2; 1.58.20;
Add siginfo support from Daniel Loffgren.
 1.57  18-Aug-2011  manu branches: 1.57.2;
Remove warning about system extended attributes that cannot be copied, since
it will always be displayed when an unprivilegied user moves files across
filesystems (mv(1) uses cp -p in that case). After all, there is no warning
that we loose a setuid bit during a move or copy, so this makes sense.

Fixes bin/45259
 1.56  03-Aug-2011  manu Make cp -p and mv preverve extended attributes, and complain if they cannot.

Also introduce library functions for copying extended attributes from one
file to another:
- extattr_copy_file, extattr_copy_fd, extattr_copy_link, with FreeBSD style,
where a namespace is to be supplied
- cpxattr, fcpxattr, lcpxattr, with Linux style, where all namespaces
accessible to the caller are copied, and the others are silently ignored.
 1.55  06-Feb-2011  darcy Add -l option to copy a tree as links.
Non-standard option similar to Gnutools cp(1)
Approved by core.
 1.54  21-Dec-2010  christos branches: 1.54.2;
Add -a archive flag. from Aleksey Cheusov
 1.53  08-Oct-2009  pooka Fix the "dne" handling and chmod behaviour properly: values of dne
need to be on a stack instead of being a single variable since
directories are processed depth-first. Otherwise dne randomly
depends on the previously processed entry.

This fixes both chmod of non-created directories (they used to be
chmod'd even when not created if their last child element did not
exist in the target subtree) and a "foo exists" bug exposed by my
last commit which removed directory sorting.

all regression tests passed
 1.52  29-Sep-2009  pooka 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.
 1.51  20-Jul-2008  lukem Remove the \n and tabs from the __COPYRIGHT() strings.
 1.50  26-May-2008  dholland Distinguish "this file failed" from "any file failed", to make cp -v
output behave itself. PR bin/37018 from Dieter Roelants.

(I used a slightly different patch to make sure "any file failed"
didn't get lost in the shuffle, and renamed the variables in the name
of greater clarity.)
 1.49  26-May-2008  christos PR/38755: murray armfield: /bin posix programs missing setprogname and/or
setlocale
 1.48  26-Dec-2006  alc branches: 1.48.10; 1.48.12;
fix whitespace nits (space -> tab)
 1.47  15-Oct-2006  christos c99 initializers
 1.46  15-Aug-2006  jschauma initialize dne variable in the beginning, then move the resetting of
this variable down into the second (ie post-order) pass to make cp
pass all regression tests again.
 1.45  15-Aug-2006  tron Avoid errors like "cp: /foo/bar/directory" exists if cp(1) is used to
copy multiple directories and the first one doesn't exist in the
target directiry but another one (e.g. the second) does.
 1.44  16-Jul-2006  jschauma branches: 1.44.2;
return functionality backed out yesterday after fixing the bug I had
introduced before. A regression test will be added to src/regress
shortly.
 1.43  15-Jul-2006  jschauma The last commit introduced a bug. Revert until that's found and fixed.
 1.42  15-Jul-2006  jschauma As suggested on tech-userlevel:
"-R" claims:
-R [...] Created directories have the same mode as the corre-
sponding source directory, unmodified
by the process' umask.

Make this actually true.

In addition, make '-P' (no symbolic links are followed) apply even if
'-R' is not specified. This allows users to overwrite symbolic links
with files and/or to copy symbolic links over a file without indirecting
through the link (ie a copy of a link turns the target into a link, not
a copy of the file pointed to by the source).
 1.41  17-Mar-2006  erh Fix Coverity issue 1754. Call fts_close() after we're done copying.
 1.40  16-Nov-2005  christos - Better detect pathname overflow (from FreeBSD)
- Change destination normal file detection to match with FreeBSD
- Trim trailing slashes from source filenames so that cp foo/ == cp foo
 1.39  24-Oct-2005  kleink Remove the "" -> "." target conversion kludge.
 1.38  15-Oct-2005  christos - Don't output 'src -> dst' when -v and there was an error.
- Mark usage as noreturn, and remove extraneous exit.
- Pass lint.
Reported by Liam Foy.
 1.37  15-Aug-2005  elad Add and document -N: When used with -p, it will not copy the file flags.
PR 13645.
 1.36  26-Jun-2005  christos sprinkle a little const, and now everything compiles with WARNS=3
 1.35  14-Sep-2003  jschauma Following private discussion with kleink@ and hubertf@ and public discussion
on tech-userlevel@, back out printescaped() functionality.
kleink: ``We sell rope.''
 1.34  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22249, verified by myself.
 1.33  04-Aug-2003  jschauma As discusses a little while back on tech-userlevel:

If stdout is a tty, use vis(3) to print any filenames to prevent garbage
from being printed if the filename contains control- or other non-printable
characters.

While here, sprinkle some EXIT_FAILURE and NOTREACHED where appropriate.
 1.32  16-Dec-2002  jrf Added a -v verbose option to the cp(1) command. Updated man page and utils as well. This applies to PR bin/16834. This change was approved by Christos.
 1.31  13-Sep-2001  wiz ANSIfication and some KNF fixes by Petri Koistinen from bin/13681.
 1.30  07-Jul-2000  itojun errx?/warnx? audit. do not pass variable alone, use %s. idea from openbsd
 1.29  03-Jul-2000  matt include <stdlib.h>, <string.h>, or whatever as appropriate to shut up
gcc 2.96
 1.28  05-Sep-1999  kleink branches: 1.28.8;
Initialize locale on startup.
 1.27  01-Mar-1999  mjl Correct behaviour in case of dangling symlinks: they would be (contrary
to what the manpage and POSIX say) copied as symlinks, even without -R.
Return ENOENT instead. Closes PR 6975 by Johan Danielsson <joda@pdc.kth.se>.

From FreeBSD: return correct error message if source directory is
unreadable; remove unnecessarily included headers.
 1.26  25-Feb-1999  dean Got rid of redundant error message (X is a directory (not copied). was
printed twice)
 1.25  08-Oct-1998  wsanchez Fix bug where "cp -f" didn't work.
It's suppsed to remove the file and then copy, which it wasn't doing.
But no wait, it turns out that the described behaviour in the manual doesn't
agree with POSIX. So we change the above fix and the manual to "try copy, and
if fail, try remove, then copy".
Fix bug where "cp -R" didn't work on read-only directories:
It would make the directory, set the mode, and not be able to write files into it.
Don't bother mmap()ing files of zero length. Was a workaround for a bug in Rhapsody
mmap(), which didn't get along with such files, but makes sense anyway.
Fix race condition where "cp -p" would set the mod time of a file before close()ing
the file, which would update the mod time and therefore screw up the "-p" idea,
except, of course, while running in gdb, which sucked.
Add -f option to usage message in binary and man page. Already documented in man page.
 1.24  19-Aug-1998  thorpej Add some braces to keep egcs happy.
 1.23  28-Jul-1998  mycroft Be more retentive about use of NOTREACHED and noreturn.
 1.22  28-Jul-1998  mycroft Delint.
 1.21  28-Jul-1998  mycroft Delint.
 1.20  28-Jul-1998  mycroft Delint.
 1.19  14-Sep-1997  lukem * getopt returns -1 not EOF
* cleanup use of .Nm in manpage
 1.18  20-Jul-1997  thorpej - Use __COPYRIGHT() and __RCSID()
- Fix compiler warnings.
 1.17  21-May-1997  kleink Fix one remaining botch when copying directory trees using -R.
 1.16  19-May-1997  kleink Fix thinko in last commit, causing "cp file /" to succeed but
"cp file1 file2 /" to fail badly; fixes PR/3646 from Paul Kranenburg.
 1.15  09-Apr-1997  kleink Fix lossage with new namei() when the destination given is "/";
reported by Bernd Ernesti.
 1.14  07-Sep-1995  jtc Sync with 4.4lite2
 1.13  02-Apr-1995  mycroft Fix typo in S_FIFO case when copying recursively.
 1.12  21-Mar-1995  cgd convert to new RCS id conventions.
 1.11  26-Jan-1995  mycroft Fix core dump reported by Wolfram Schneider.
 1.10  22-Sep-1994  mycroft Merge 4.4-Lite version.
 1.9  28-Mar-1994  cgd no more MAP_FILE
 1.8  25-Feb-1994  jtc POSIX.2 (and common sense) says that you can't overwrite a directory with
a non-directory.
 1.7  09-Nov-1993  jtc Check user's response against both 'Y' and 'y' --- this is really supposed
to be a locale specific regular expression. This change hard codes POSIX
locale behavior, and will be replaced by a locale independant equivalent
as soon as locales are fully implemented.
 1.6  30-Oct-1993  mycroft From Lennart Augustsson:
If we mmap() the file, make sure we munmap() when we're done.
 1.5  07-Aug-1993  mycroft New version from uunet. Uses mmap().
 1.4  01-Aug-1993  mycroft Add RCS identifiers.
 1.3  23-Mar-1993  cgd changed "Id" to "Header" for rcsids
 1.2  22-Mar-1993  cgd added rcs ids to all files
 1.1  21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3  07-Sep-1995  jtc imported from 44lite2
 1.1.1.2  22-Sep-1994  mycroft Import original 4.4-Lite version.
 1.1.1.1  21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.28.8.1  27-Jul-2000  itojun pullup (approved by releng-1-5)
printf-like format pedant. do not pass string variable alone. use "%s".
from openbsd.

/cvsroot/basesrc/bin/dd/conv.c 1.8 -> 1.9
/cvsroot/basesrc/bin/cp/cp.c 1.29 -> 1.30
/cvsroot/basesrc/bin/chmod/chmod.c 1.22 -> 1.23
 1.44.2.1  21-Aug-2006  ghen Pull up following revision(s) (requested by tron in ticket #30):
regress/bin/cp/cp.sh: revision 1.2
regress/bin/cp/cp.sh: revision 1.3
bin/cp/cp.c: revision 1.45
bin/cp/cp.c: revision 1.46
Avoid errors like "cp: /foo/bar/directory" exists if cp(1) is used to
copy multiple directories and the first one doesn't exist in the
target directiry but another one (e.g. the second) does.
initialize dne variable in the beginning, then move the resetting of
this variable down into the second (ie post-order) pass to make cp
pass all regression tests again.
allow each dir_to_dir test to be run individually without having to
rely on previous tests that set up the files and directories;
while here, clarify in each error message where exactly the error occurred
add a regression test for copying several subdirs into a target directory
where some subdirs already exist
 1.48.12.2  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.48.12.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.48.10.1  04-Jun-2008  yamt sync with head
 1.54.2.1  08-Feb-2011  bouyer Sync with HEAD
 1.57.2.1  17-Apr-2012  yamt sync with head
 1.58.20.1  06-Mar-2016  martin Pull up following revision(s) (requested by uwe in ticket #1131):
bin/cp/cp.c: revision 1.59
The '-i' flag should work regardless of whether the standard input is
a terminal. The Open Group notes this historic behavior and correctly
notes that it doesn't make much sense. Note also, that mv(1) has
always respected its '-i' regardless of whether the standard input is
a terminal.
From Timo Buhrmester.
 1.58.2.1  27-Aug-2016  bouyer Pull up following revision(s) (requested by uwe in ticket #1372):
bin/cp/cp.c: revision 1.59
The '-i' flag should work regardless of whether the standard input is
a terminal. The Open Group notes this historic behavior and correctly
notes that it doesn't make much sense. Note also, that mv(1) has
always respected its '-i' regardless of whether the standard input is
a terminal.
From Timo Buhrmester.
 1.59.16.2  21-Apr-2020  martin Ooops, restore accidently removed files from merge mishap
 1.59.16.1  21-Apr-2020  martin Sync with HEAD

RSS XML Feed