History log of /freebsd-10.1-release/bin/cp/utils.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 272461 02-Oct-2014 gjb

Copy stable/10@r272459 to releng/10.1 as part of
the 10.1-RELEASE process.

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


# 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


# 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


# 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


# 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


# 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


# 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


# 141578 09-Feb-2005 ru

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


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


# 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


# 113209 07-Apr-2003 mdodd

Add a SIGINFO handler.


# 105395 18-Oct-2002 markm

Constify and staticify for lint.


# 101093 31-Jul-2002 markm

Fix some easy WARNS.


# 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


# 99363 03-Jul-2002 markm

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


# 99109 30-Jun-2002 obrien

Consistently use __FBSDID


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


# 87652 11-Dec-2001 mckay

Typo in warning message (chown should be chmod).


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


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


# 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


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


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


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


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


# 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


# 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 29-May-1995 rgrimes

Remove trailing whitespace.

Reviewed by: phk


# 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