History log of /freebsd-11-stable/bin/cp/cp.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 331722 29-Mar-2018 eadler

Revert r330897:

This was intended to be a non-functional change. It wasn't. The commit
message was thus wrong. In addition it broke arm, and merged crypto
related code.

Revert with prejudice.

This revert skips files touched in r316370 since that commit was since
MFCed. This revert also skips files that require $FreeBSD$ property
changes.

Thank you to those who helped me get out of this mess including but not
limited to gonzo, kevans, rgrimes.

Requested by: gjb (re)


# 330897 14-Mar-2018 eadler

Partial merge of the SPDX changes

These changes are incomplete but are making it difficult
to determine what other changes can/should be merged.

No objections from: pfg


# 302408 07-Jul-2016 gjb

Copy head@r302406 to stable/11 as part of the 11.0-RELEASE cycle.
Prune svn:mergeinfo from the new branch, as nothing has been merged
here.

Additional commits post-branch will follow.

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


/freebsd-11-stable/MAINTAINERS
/freebsd-11-stable/cddl
/freebsd-11-stable/cddl/contrib/opensolaris
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/zfs
/freebsd-11-stable/cddl/contrib/opensolaris/lib/libzfs
/freebsd-11-stable/contrib/amd
/freebsd-11-stable/contrib/apr
/freebsd-11-stable/contrib/apr-util
/freebsd-11-stable/contrib/atf
/freebsd-11-stable/contrib/binutils
/freebsd-11-stable/contrib/bmake
/freebsd-11-stable/contrib/byacc
/freebsd-11-stable/contrib/bzip2
/freebsd-11-stable/contrib/com_err
/freebsd-11-stable/contrib/compiler-rt
/freebsd-11-stable/contrib/dialog
/freebsd-11-stable/contrib/dma
/freebsd-11-stable/contrib/dtc
/freebsd-11-stable/contrib/ee
/freebsd-11-stable/contrib/elftoolchain
/freebsd-11-stable/contrib/elftoolchain/ar
/freebsd-11-stable/contrib/elftoolchain/brandelf
/freebsd-11-stable/contrib/elftoolchain/elfdump
/freebsd-11-stable/contrib/expat
/freebsd-11-stable/contrib/file
/freebsd-11-stable/contrib/gcc
/freebsd-11-stable/contrib/gcclibs/libgomp
/freebsd-11-stable/contrib/gdb
/freebsd-11-stable/contrib/gdtoa
/freebsd-11-stable/contrib/groff
/freebsd-11-stable/contrib/ipfilter
/freebsd-11-stable/contrib/ldns
/freebsd-11-stable/contrib/ldns-host
/freebsd-11-stable/contrib/less
/freebsd-11-stable/contrib/libarchive
/freebsd-11-stable/contrib/libarchive/cpio
/freebsd-11-stable/contrib/libarchive/libarchive
/freebsd-11-stable/contrib/libarchive/libarchive_fe
/freebsd-11-stable/contrib/libarchive/tar
/freebsd-11-stable/contrib/libc++
/freebsd-11-stable/contrib/libc-vis
/freebsd-11-stable/contrib/libcxxrt
/freebsd-11-stable/contrib/libexecinfo
/freebsd-11-stable/contrib/libpcap
/freebsd-11-stable/contrib/libstdc++
/freebsd-11-stable/contrib/libucl
/freebsd-11-stable/contrib/libxo
/freebsd-11-stable/contrib/llvm
/freebsd-11-stable/contrib/llvm/projects/libunwind
/freebsd-11-stable/contrib/llvm/tools/clang
/freebsd-11-stable/contrib/llvm/tools/lldb
/freebsd-11-stable/contrib/llvm/tools/llvm-dwarfdump
/freebsd-11-stable/contrib/llvm/tools/llvm-lto
/freebsd-11-stable/contrib/mdocml
/freebsd-11-stable/contrib/mtree
/freebsd-11-stable/contrib/ncurses
/freebsd-11-stable/contrib/netcat
/freebsd-11-stable/contrib/ntp
/freebsd-11-stable/contrib/nvi
/freebsd-11-stable/contrib/one-true-awk
/freebsd-11-stable/contrib/openbsm
/freebsd-11-stable/contrib/openpam
/freebsd-11-stable/contrib/openresolv
/freebsd-11-stable/contrib/pf
/freebsd-11-stable/contrib/sendmail
/freebsd-11-stable/contrib/serf
/freebsd-11-stable/contrib/sqlite3
/freebsd-11-stable/contrib/subversion
/freebsd-11-stable/contrib/tcpdump
/freebsd-11-stable/contrib/tcsh
/freebsd-11-stable/contrib/tnftp
/freebsd-11-stable/contrib/top
/freebsd-11-stable/contrib/top/install-sh
/freebsd-11-stable/contrib/tzcode/stdtime
/freebsd-11-stable/contrib/tzcode/zic
/freebsd-11-stable/contrib/tzdata
/freebsd-11-stable/contrib/unbound
/freebsd-11-stable/contrib/vis
/freebsd-11-stable/contrib/wpa
/freebsd-11-stable/contrib/xz
/freebsd-11-stable/crypto/heimdal
/freebsd-11-stable/crypto/openssh
/freebsd-11-stable/crypto/openssl
/freebsd-11-stable/gnu/lib
/freebsd-11-stable/gnu/usr.bin/binutils
/freebsd-11-stable/gnu/usr.bin/cc/cc_tools
/freebsd-11-stable/gnu/usr.bin/gdb
/freebsd-11-stable/lib/libc/locale/ascii.c
/freebsd-11-stable/sys/cddl/contrib/opensolaris
/freebsd-11-stable/sys/contrib/dev/acpica
/freebsd-11-stable/sys/contrib/ipfilter
/freebsd-11-stable/sys/contrib/libfdt
/freebsd-11-stable/sys/contrib/octeon-sdk
/freebsd-11-stable/sys/contrib/x86emu
/freebsd-11-stable/sys/contrib/xz-embedded
/freebsd-11-stable/usr.sbin/bhyve/atkbdc.h
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.c
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.h
/freebsd-11-stable/usr.sbin/bhyve/console.c
/freebsd-11-stable/usr.sbin/bhyve/console.h
/freebsd-11-stable/usr.sbin/bhyve/pci_fbuf.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.h
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.c
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.h
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.c
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.h
/freebsd-11-stable/usr.sbin/bhyve/rfb.c
/freebsd-11-stable/usr.sbin/bhyve/rfb.h
/freebsd-11-stable/usr.sbin/bhyve/sockstream.c
/freebsd-11-stable/usr.sbin/bhyve/sockstream.h
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.c
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.h
/freebsd-11-stable/usr.sbin/bhyve/usb_mouse.c
/freebsd-11-stable/usr.sbin/bhyve/vga.c
/freebsd-11-stable/usr.sbin/bhyve/vga.h
# 284163 08-Jun-2015 bdrewery

Cleanup some style(9) issues.

- Whitespace.
- Comments.
- Wrap long lines.

MFC after: 2 weeks
X-MFC-with: r284105,r284106
Sponsored by: EMC / Isilon Storage Division


# 284106 07-Jun-2015 bdrewery

Implement '-s' to copy as symlink, similar to the current -l link(2) handling.

This is also implemented in at least GNU coreutils cp.

While here also improve the '-l' handling to not open(2) the source file as
it does not actually need the descriptor.

Sponsored by: EMC / Isilon Storage Division


# 282482 05-May-2015 jilles

cp: Remove fts sorting.

In an attempt to improve performance, cp reordered directories first
(although the comment says directories last). This is not effective with new
UFS layout policies.

The sorting reorders multiple arguments passed to cp, which may be
undesirable.

Additionally, the comparison function does not induce a total order. Per
POSIX, this causes undefined behaviour in qsort().

NetBSD removed the sorting in 2009.

On filesystems that return directory entries in hash/btree order, sorting by
d_fileno before statting improves performance on large directories. However,
this can only be implemented in fts(3).

PR: 53475
Reviewed by: bde (in 2004)
MFC after: 1 week


# 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


# 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


# 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


# 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 24-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@


# 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)


# 162763 29-Sep-2006 ru

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


# 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


# 139969 10-Jan-2005 imp

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


# 127958 06-Apr-2004 markm

Remove clause 3 from the UCB licenses.

OK'ed by: imp, core


# 117065 30-Jun-2003 jmg

pass -1 to setfile in cp.c

Submitted by: Jun Kuriyama


# 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 20-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


# 100538 22-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


# 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 10-May-2002 alfred

Add semicolon to empty default case to silence warning.


# 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


# 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


# 76693 16-May-2001 imp

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


# 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


# 36812 09-Jun-1998 dt

Print correct error message if we copy an unreadable directory.


# 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.


# 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$


# 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.


# 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 18-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


# 8855 29-May-1995 rgrimes

Remove trailing whitespace.

Reviewed by: phk


# 7572 01-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.


# 1556 26-May-1994 rgrimes

BSD 4.4 Lite bin Sources