History log of /freebsd-10.0-release/bin/cp/
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
259065 07-Dec-2013 gjb

- Copy stable/10 (r259064) to releng/10.0 as part of the
10.0-RELEASE cycle.
- Update __FreeBSD_version [1]
- Set branch name to -RC1

[1] 10.0-CURRENT __FreeBSD_version value ended at '55', so
start releng/10.0 at '100' so the branch is started with
a value ending in zero.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


248342 15-Mar-2013 joel

Add a few examples.

Obtained from: OpenBSD


245960 27-Jan-2013 markj

Return with an error from copy_link(), copy_fifo() and copy_special() if
the -n option is specified and the destination file exists.

PR: bin/174489
Approved by: rstone (co-mentor)
MFC after: 2 weeks


245832 23-Jan-2013 obrien

Return "failure" as we do for 'cp -i' and a "n" answer.

Otherwise with '-v' we print out the file name as if it was copied:
/tmp/2gb-card/M0132.CTG not overwritten
/mnt/DCIM/CANONMSC/M0132.CTG -> /tmp/2gb-card/M0132.CTG


245535 17-Jan-2013 eadler

Remove useless variable 'Pflag':
-P is an alternative to -H and -L, and it is implemented using the Hflag and Lflag variables.

Approved by: cperciva
MFC after: 3 days


240088 04-Sep-2012 trasz

Explicitly mention that "cp -p" copies ACLs.

PR: docs/168962
MFC after: 1 month


208821 05-Jun-2010 trasz

Don't try to copy a socket after "xxx is a socket (not copied)." message.
Previously, it would either try to copy it anyway and fail (without -R),
or create fifo instead of the socket (with -R).

Found with: Coverity Prevent
CID: 5623
MFC after: 2 weeks


205793 28-Mar-2010 ed

Change all our own code to use st_*tim instead of st_*timespec.

Also remove some local patches to diff(1) which are now unneeded.


202461 17-Jan-2010 gavin

Implement an "-x" option to cp(1), for compatibility with Linux and
feature parity with du(1) and similar: When set, cp(1) will not traverse
mount points.

Initial patch by: Graham J Lee leeg teaching.physics.ox.ac.uk

PR: bin/88056
Initial patch by: Graham J Lee leeg teaching.physics.ox.ac.uk
Approved by: ed (mentor)
MFC after: 1 month


196754 02-Sep-2009 trasz

Add NFSv4 ACL support to cp(1) and fix a few memory leaks.

Note that this changes error reporting behaviour somewhat - before,
no error was reported if ACL couldn't be copied because the target
filesystem doesn't support ACLs. Now, it will be reported - of course,
only if there actually is an ACL to copy.

Reviewed by: rwatson


193086 30-May-2009 jilles

Preserve file flags on symlinks in cp -Rp.
This reported ENOSYS before.

PR: bin/111226 (part of)
Submitted by: Martin Kammerhofer
Approved by: ed (mentor)
MFC after: 3 weeks


192586 22-May-2009 trasz

Make 'struct acl' larger, as required to support NFSv4 ACLs. Provide
compatibility interfaces in both kernel and libc.

Reviewed by: rwatson


184471 30-Oct-2008 ivoras

Teach cat(1) and cp(1) to use a larger buffer if enough memory is present
in the system. A simple heuristics is used to detect what is "enough"
memory: if number of physmem pages is greater than 32k (equalling 128 MB
on machines with 4 kB pages).

Typical immediate result of these changes is reduction in context switches
and the goal is to increase efficiency by using large buffers:
before: /usr/bin/time -hlp cat file1 > file2
...
163 voluntary context switches
11194 involuntary context switches
after: /usr/bin/time -hlp ./cat file1 > file2
...
417 voluntary context switches
272 involuntary context switches

Reviewed by: hackers@ (no objections to earlier version of cat patch)
Approved by: gnn (mentor)
MFC after: 4 months


184342 27-Oct-2008 dds

Add fallback when mmap fails on regular files. Some filesystems,
like smbnetfs, do not support mmap.

Reported by: Harti Brandt
MFC after: 1 month


182889 09-Sep-2008 trasz

Remove redundant close(2).

Submitted by: kensmith
Approved by: rwatson (mentor)


181361 07-Aug-2008 trasz

Fix ACL preservation, apparently broken in 1.47.

Approved by: rwatson
MFC after: 3 weeks


177036 10-Mar-2008 jhb

Add an '-a' option which is identical to specifying '-RpP' for
compatibility with other implementations.

MFC after: 1 month


174912 26-Dec-2007 edwin

As suggested, replace earlier changed warnx() / exit() with an errx()

Submitted by: Peter Jeremy <peterjeremy@optushome.com.au>


174890 25-Dec-2007 edwin

When copying multiple files to a directory, make sure that a proper
warning is given when the directory doesn't exist.

PR: bin/50656
Submitted by: Edwin Groothuis <edwin@mavetju.org>
Approved by: grog@
Not reviewed by: grog@


163919 02-Nov-2006 ceri

Fix typo.


163716 27-Oct-2006 trhodes

Wording nits.


163666 24-Oct-2006 trhodes

Flesh out the compatibility section a little bit. Bump doc date.


163233 11-Oct-2006 trhodes

Fix style(9) bugs in previous commit.

Lesson from: bde


163109 07-Oct-2006 trhodes

Make -r a synonym for -R, similar to behavior on Linux while being backwards
compatible with old -r behavior with regards to -L. You can now copy fifos
and other special files with -r.

Reviewed by: -standards (long ago), das, bde
Approved by: bde (recently)


163075 07-Oct-2006 maxim

o Style(9).

Submitted by: bde


163074 07-Oct-2006 maxim

o Avoid division by zero.
o Place error checking code near to the syscall.

Submitted by: bde


163049 06-Oct-2006 maxim

o Hold copied bytes counter in off_t. This prevents statistics
displayed by SIGINFO handler from overflow.

PR: bin/104039
Submitted by: Geoffrey Giesemann
MFC after: 2 weeks


162763 29-Sep-2006 ru

Move the -l option processing to where it belongs.
Overall still not kosher but better matches style(9).


161608 25-Aug-2006 ru

- Fix options order.
- Touch manpage's document date.


161607 25-Aug-2006 ru

Remove a stray -a option that probably sneaked in from julian's
attempt to enter append mode twice in vi(1). :-)


161586 24-Aug-2006 julian

Add an option to allow copying of a hierarchy while linking he regular files.
Bikeshedded to death on: hackers
Submitted by:andersonatcenttech.com
MFC in: 1 month


160098 04-Jul-2006 maxim

o Call fts_close() before exit.

Obtained from: NetBSD, Coverity ID 1754


149790 05-Sep-2005 csjp

Attempt to complete the userspace integration of POSIX.1e extended ACLs.
This includes adding support for ACLs into cp(1) and mv(1) userspace
utilities.

For mv(1), if _PC_ACL_EXTENDED is in effect for the source AND destination
operands, the destination file's ACLs shall reflect the source.

For cp(1), if _PC_ACL_EXTENDED is in effect for both source and destination
operands, and -p has been specified, the ACLs from the source shall be
preserved on the destination.

MFC after: 1 month


142412 25-Feb-2005 trhodes

Fix a few markup nits in previous commit.

Noticed by: ru, who else? :)


142346 24-Feb-2005 trhodes

Note how cp(1) handles directories ending in "/."

PR: 75774
Submitted by: Mike Meyer <mwm@mired.org> (original version)


141578 09-Feb-2005 ru

Sync program's usage() with manpage's SYNOPSIS.


140353 16-Jan-2005 ru

Add the new standard EXIT STATUS section where appropriate.
Sort standard sections in the (documented) preferred order.


139969 10-Jan-2005 imp

/*- or .\"- or #- to begin license clauses.


131484 02-Jul-2004 ru

Mechanically kill hard sentence breaks.


130102 05-Jun-2004 tjr

Plug file descriptor leak in implementation of -n option.


127958 06-Apr-2004 markm

Remove clause 3 from the UCB licenses.

OK'ed by: imp, core


122601 13-Nov-2003 alc

Don't mmap(2) and munmap(2) zero-length files.

Submitted by: Wiktor Niesiobedzki <bsd@w.evip.pl>


117065 30-Jun-2003 jmg

pass -1 to setfile in cp.c

Submitted by: Jun Kuriyama


116673 22-Jun-2003 jmg

support saving both user/group and permissions on symlinks (from PR)

also fix a slight bogon that assumed an fd of 0 was not valid. Changed
it to be -1.

PR: bin/25017
Submitted by: Martin Kammerhofer


115938 07-Jun-2003 ru

Clarify what -p option does.

Prodded by: marcel

While here, spell the "set-{user,group}-ID bit" correctly.


114433 01-May-2003 obrien

Quiet warnings about copyright[].


113431 13-Apr-2003 bde

Include <signal.h> instead of depending on namespace pollution in
<sys/param.h>. Include <sys/types.h> instead of of <sys/param.h>
so that further such dependencies don't develop.


113430 13-Apr-2003 bde

Fixed some style bugs in rev.1.44.


113218 07-Apr-2003 mdodd

Use the correct data type and qualifier for signal flag.


113209 07-Apr-2003 mdodd

Add a SIGINFO handler.


105395 18-Oct-2002 markm

Constify and staticify for lint.


103801 22-Sep-2002 mckay

cp -p could report success even if a file copy failed. This was due to
the cumulative exit status being overwritten when directory permissions
were being set. This was particularly bad when called from mv(1) to
perform a cross-device move as the original files were deleted even if
the copy failed.

Reported by: Slaven Rezic <slaven.rezic@berlin.de>
Patch by: bde
PR: 42789


103726 21-Sep-2002 wollman

Make the threatened fts(3) ABI fix. FTSENT now avoids the use of the struct
hack, thereby allowing future extensions to the structure (e.g., for extended
attributes) without rebreaking the ABI. FTSENT now contains a pointer to the
parent stream, which fts_compar() can then take advantage of, avoiding the
undefined behavior previously warned about. As a consequence of this change,
the prototype of the comparison function passed to fts_open() has changed
to reflect the required amount of constness for its use. All callers in the
tree are updated to use the correct prototype.

Comparison functions can now make use of the new parent pointer to access
the new stream-specific private data pointer, which is intended to assist
creation of reentrant library routines which use fts(3) internally.

Not objected to in spirit by: -arch


101961 16-Aug-2002 johan

Bump document date for the -n option.

Approved by: sheldonh (mentor)


101570 09-Aug-2002 ru

mdoc(7) police: grammar.


101093 31-Jul-2002 markm

Fix some easy WARNS.


100538 23-Jul-2002 johan

Add the -n option, which automatically answers "no" to the overwrite question.

PR: 7828
Suggested by: Daniel O'Connor <doconnor@gsoft.com.au>
Approved by: sheldonh (mentor)
MFC after: 2 weeks


100069 15-Jul-2002 sheldonh

Revert previous delta, which is not required with rev 1.5 of
src/contrib/gcc/c-format.c .


99767 11-Jul-2002 sheldonh

Set WFORMAT=0, because our compiler currently complains about NULL
arg 2 to err() and friends, and warnings are promoted to errors.

This allows the following revisions to be reverted:

rev 1.39 src/bin/cp/cp.c
rev 1.26 src/bin/chmod/chmod.c
rev 1.40 src/bin/rm/rm.c

The following revisions can already be reverted, because they were
already covered by WFORMAT=0:

rev 1.8 src/bin/ls/lomac.c
rev 1.63 src/bin/ls/ls.c
rev 1.8 src/bin/ps/lomac.c
rev 1.34 src/bin/rcp/rcp.c


99744 10-Jul-2002 dillon

err() is documented as allowing NULL for the format string but GCC isn't
happy about it any more so change the usage to make buildworld work again.


99363 03-Jul-2002 markm

Fix some low-hanging lint-fruit: endianness and staticness warnings.


99109 30-Jun-2002 obrien

Consistently use __FBSDID


98171 13-Jun-2002 tjr

When -R is not specified, fail to copy the contents of dangling symlinks
instead of making a copy of the link itself (SUSv3)

Obtained from: NetBSD


96809 17-May-2002 ache

Optimize prev. commit code a bit


96808 17-May-2002 ache

Trailing slash fixes.

Fix the case:
cp file nonexistent/
which create nonextstent as file while trailing slash clearly indicates
that nonexistent must be a directory.
Also fix the case:
cp file1 file2/
which should produce error.


96371 11-May-2002 alfred

Add semicolon to empty default case to silence warning.


91146 23-Feb-2002 bde

Fixed some style bugs in revs 1.1 and 1.4.


91087 22-Feb-2002 markm

Fix warnings inspired by lint, a commercial lint and WARNS=4.


90107 02-Feb-2002 imp

Modernization effort for bin/c*:

o __P has been reoved
o Old-style K&R declarations have been converted to new C89 style
o register has been removed
o prototype for main() has been removed (gcc3 makes it an error)
o int main(int argc, char *argv[]) is the preferred main definition.
o Attempt to not break style(9) conformance for declarations more than
they already are.

Approved by: arch@, new style(9)


88755 01-Jan-2002 mckay

Bruce thought some of the comments I added were not clear enough. This is
a combination of my words and his. We will stop fiddling now. :-)


88439 23-Dec-2001 mckay

The previous fix caused cp to emit spurious warnings under some
circumstances. This is a reworked version of the same fix, that does
not have this defect, and which fixes some style bugs at the same time.

Bug reported and fix reviewed by: bde


87655 11-Dec-2001 mckay

Preserve directory timestamps with -p. Allow non-empty read-only
directories to be copied. Apply umask to newly created directories
when -p is not specified.

PR: 27970
PR: 31633

MFC after: 4 days


87652 11-Dec-2001 mckay

Typo in warning message (chown should be chmod).


87323 04-Dec-2001 obrien

Default to WARNS=2. Binary builds that cannot handle this must explicitly
set WARNS=0.

Reviewed by: mike


81687 15-Aug-2001 ru

mdoc(7) police: utilize the new .Ex macro.


79754 15-Jul-2001 dd

Remove whitespace at EOL.


79526 10-Jul-2001 ru

mdoc(7) police: removed HISTORY info from the .Os call.


78469 19-Jun-2001 des

Add more headers that are required with -fno-builtin (stdlib and strings)


78070 11-Jun-2001 bde

Removed the broken code which claimed to lose the set[ug]id bits in
the !(pflag && setfile()) case for regular files unless the copy is
owned by the same user and group. These bits have already been lost
(or never gained) in the correct way. The code didn't actually lose
the bits; it depended on them being lost already (apparently in all
cases) and attempted to gain them as necessary, but it often gained
them (and sometimes collateral bits) when wrong:
- pflag && setfile() == 0 case (i.e., for a successful cp -p):
setfile() copies all the attributes as correctly as possible (as
specified by POSIX), and we sometimes messed up the up the mode by
setting it again. Also, if the file is immutable, then setting the
mode again gave spurious errors (PR 20646).
- !pflag case. If the target is created, POSIX requires it to not
have the set[ug]id bits, but we sometimes copied them from the source.
If the target already exists, POSIX requires its mode to be unchanged,
but we sometimes copied the whole mode from the source.

PR: 20646
MFC after: 4 weeks


77160 25-May-2001 ru

Make it clear that -P is the default.

PR: docs/27629


76693 16-May-2001 imp

Migrate from using MAXPATHLEN to MAX_PATH. Use strlcpy to copy the
strings.


71977 04-Feb-2001 mckay

In the hope of saving others from hours of tedious recovery work,
document that cp still isn't very useful for recursive copies even
with the -R flag. This is because hard links are broken by cp.


68935 20-Nov-2000 ru

mdoc(7) police: use the new features of the Nm macro.


66907 10-Oct-2000 wollman

Don't depend on <sys/stat.h> bogusly including <sys/time.h> (and thereby
<time.h>).


56420 23-Jan-2000 mharo

fix cp -vi bug

Submitted by: Dan Papasian (bugg_ on irc)


53819 28-Nov-1999 mharo

brucify

Reviewed by: obrien


50543 29-Aug-1999 mharo

brucify and move printf() to catch cases of special files


50471 27-Aug-1999 peter

$Id$ -> $FreeBSD$


50381 26-Aug-1999 mharo

Add a verbose mode to show what files are being copied.
Idea taken from obrien.

Reviewed by: obrien


48725 10-Jul-1999 kris

Add -W and fix the warning due to missing struct initializer


46684 08-May-1999 kris

Various spelling/formatting changes.

Submitted by: Philippe Charnier <charnier@xp11.frmug.org>


46073 25-Apr-1999 imp

First set of fixes to keep egcs happy. These include {} around single
statement if blocks[*] when the else could be ambiguous, not defaulting
to int type and removal of some unused variables.

[*] This is explicitly allowed by style(9) when the single statement
spans more than one line.

Reviewed by: obrien, chuckr


41238 18-Nov-1998 bde

Don't use mmap() for non-regular files, since st_size is only meaningful
for regular files. This fixes recent breakage of cp'ing from /dev/zero.
/dev/zero doesn't support mmap(), but the device driver mmap routines are
not called for mapping 0 bytes, so the error was not detected. mmap()
can't even be used for cp'ing special files that support mmap(), since
there is general way to determine the file size.


41156 14-Nov-1998 wosch

Use mmap for file coping. 5-10% faster than the read system call.


40288 13-Oct-1998 jkoshy

Correct a grammatical nit and remove ambiguity about the effect of
the -p option.

PR: 8229
Submitted-by: Sheldon Hearn <axl@iafrica.com>


36838 10-Jun-1998 peter

Don't attempt to change owner/mode/flags that don't need to changed.
This should calm down attempts to `cp -p' to a nfs mount or some other
filesystem that doesn't accept flags or all combinations of flags.
It will warn if it fails to change flags though.


36812 09-Jun-1998 dt

Print correct error message if we copy an unreadable directory.


36784 09-Jun-1998 imp

Make sure we pass the length - 1 to readlink, since it adds its own
NUL at the end of the path.
Inspired by: OpenBSD's changes in this area by theo de raadt


36003 13-May-1998 charnier

Restore Lite-2 sccsid.


35773 06-May-1998 charnier

Correct use of .Nm and other cosmetics. Add rcsid. Remove unused #inc.


32588 17-Jan-1998 bde

Fixed syntax error in normally-unconfigured code in previous commit.


32540 16-Jan-1998 bde

Fixed handling of short writes. Previously, we stopped copying and
printed a bogus warning with a stale errno if write() returns a short
count. Now we continue copying. We still print a bogus warning if
write() returns an "impossible" short count of 0.


30088 03-Oct-1997 wosch

cp(1) is too silent if used with the option -i. It should
print which input cp(1) expect (y/n) and print a warning if the
file was not overwritten.


24348 28-Mar-1997 imp

compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.


22988 22-Feb-1997 peter

Revert $FreeBSD$ to $Id$


21786 16-Jan-1997 alex

Sweep through the tree fixing mmap() usage:

- Use MAP_FAILED instead of the constant -1 to indicate
failure (required by POSIX).
- Removed flag arguments of '0' (required by POSIX).
- Fixed code which expected an error return of 0.
- Fixed code which thought any address with the high bit set
was an error.
- Check for failure where no checks were present.

Discussed with: bde


21673 14-Jan-1997 jkh

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


20412 14-Dec-1996 steve

Merge Lite2 mods and -Wall cleaning.


17891 29-Aug-1996 wosch

[HISTORY] command appeared in Version 1 AT&T UNIX
Obtained from: A Quarter Century of UNIX, Peter H. Salus, page 41


14416 08-Mar-1996 wosch

Option -f implemented (remove + create)
option -f and -i are exclusive
respond `Y' is equal to `y'
fix usage string
remove isatty(3) check

Reviewed by: pst


14157 19-Feb-1996 pst

Don't initialize udata, remove bogus case, fix usage string


14154 19-Feb-1996 wosch

delete my last commit
Submitted by: pst, ache


14145 18-Feb-1996 wosch

Option -f implemented (remove + create)
option -f and -i are exclusive
all flag variables initialized with zero
respond `Y' is equal to `y'
update usage string


11146 03-Oct-1995 bde

Preserve sticky bit for `cp -pR'. It was already preserved for `cp -R'.
This also fixes loss of the sticky bit for `mv' across file systems.


9220 14-Jun-1995 bde

Don't unlink the target file if the copy failed. This behaviour isn't
documented and is incompatible with gnu cp. It has very few good effects
(it recovers some disk space) and many bad ones:
- special files are unlinked after certain errors.
- the data may not be recoverable if the source is a special file or fifo.
- unlinking destroys the target attributes as well as the target data.
- unlinking doesn't actually remove the target data if the target is multiply
linked.


8855 30-May-1995 rgrimes

Remove trailing whitespace.

Reviewed by: phk


7572 02-Apr-1995 bde

Add braces to fix wrong if-if-else-if nesting that broke `cp -pR' for
fifos.


5879 25-Jan-1995 dg

Fix bogus format string; fixes problem reported by Wolfram Schneider.


5292 30-Dec-1994 bde

Don't strip off the last slash in the pathname "/". cp used to
stat the pathname "" in order to decide that the pathname "/" is
a directory. This caused `cp kernel /' to fail if the kernel has
the POSIX behaviour of not allowing the pathname "" to be an alias
for ".". It presumably also caused `cp /etc/motd /' to fail in
the unlikely event that "." is not stat'able.

Be more careful about concatenating pathnames: don't check that
the pathname fits until prefixes have been discarded (the check
was too strict). Print the final pathname in error messages.
Terminate the target directory name properly for error messages.
Don't add a slash between components if there is already a slash.


3044 24-Sep-1994 dg

Added $Id$


1557 26-May-1994 rgrimes

This commit was generated by cvs2svn to compensate for changes in r1556,
which included commits to RCS files with non-trunk default branches.