Commit Graph

110 Commits

Author SHA1 Message Date
apb 81b1fb1df7 In all man pages that say:
The -H, -L and -P options are ignored unless the -R option is
    specified.  In addition, these options override each other and the
    command's actions are determined by the last one specified.

Add:

    The default is as if the -P option had been specified.
2013-12-17 09:54:08 +00:00
dholland 473e706d2d Remove entirely bogus /* NOTREACHED */ annotation. 2013-12-11 06:00:11 +00:00
wiz 43a44d853f From patch by Bug Hunting:
- bump the manpage's date (because of the next change);
- note that cp(1) does not preserve hard links (even with `-R'),
  and refer to pax(1) there as well as in the `SEE ALSO' section
  for such functionality (this change is based upon a similar note
  in FreeBSD's version of the manpage);
- change a wording, for more overall consistency.
2012-03-25 22:37:08 +00:00
christos eb8f42a53b Add siginfo support from Daniel Loffgren. 2012-01-04 15:58:37 +00:00
manu e3a6fc043c 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
2011-08-18 08:11:58 +00:00
dholland 7f03f2cad6 Adjust wording of previous and fix a couple grammar slipups/typos. 2011-08-03 15:44:15 +00:00
wiz 279244c214 New sentence, new line. Remove trailing whitespace. Bump date for previous. 2011-08-03 14:02:59 +00:00
manu a9ed0e9824 iExplain what happens to extended attriutes when -p is used. 2011-08-03 12:55:03 +00:00
manu 32c00d6291 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.
2011-08-03 04:11:15 +00:00
mbalmer 95f605c283 Wording fixes from Ryo HAYASAKA, thanks. 2011-04-02 08:38:56 +00:00
wiz daf77513cf Put -l compatibility note in STANDARDS section. 2011-02-06 12:49:32 +00:00
darcy d87812693f Add -l option to copy a tree as links.
Non-standard option similar to Gnutools cp(1)
Approved by core.
2011-02-06 12:37:48 +00:00
wiz b259bc7d81 Use Fx. 2011-01-24 07:22:57 +00:00
yamt 220d843f04 document what -a is for 2011-01-24 02:44:22 +00:00
wiz 59dc922deb Fix fd leak in error case. Found by cppcheck. 2011-01-04 10:35:10 +00:00
wiz 1e77407211 Sort option descriptions, bump date for -a. 2010-12-22 09:02:32 +00:00
christos 1d41baa0ed Say that -a is non-standard and -P is the default. 2010-12-22 05:46:25 +00:00
christos 9985da2181 Add -a archive flag. from Aleksey Cheusov 2010-12-21 20:56:01 +00:00
tron 1181f40421 Re-enable support for reading files of at most 8MB via mmap(2).
Write out the mmap-ed data in small chunks to avoid locking the output
file for a long time.

Suggested by David Holland on "source-changes-d" mailing list.
2010-10-25 08:19:47 +00:00
pooka efab5715bc Disable mmap path. With the current vnode locking scheme it has
a very annoying property: if the source media is slow (like a slow
network), the target file will be locked for the duration of the
entire max 8MB write and cause processes attempting to e.g. stat()
it to "tstile" (for several minutes in the worst case).  Revisit
this if/when vnode locking gets a little smarter.

chs ok (although he would rather see vnode locking improvements,
but that's a slightly larger project)
2010-10-22 17:56:06 +00:00
pooka 4515588628 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
2009-10-08 20:36:41 +00:00
pooka c817a14b24 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.
2009-09-29 13:30:17 +00:00
lukem 2fe2731d3f Remove the \n and tabs from the __COPYRIGHT() strings. 2008-07-20 00:52:39 +00:00
dholland b63851a8b9 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.)
2008-05-26 22:45:33 +00:00
christos 9655f5c24c PR/38755: murray armfield: /bin posix programs missing setprogname and/or
setlocale
2008-05-26 14:21:08 +00:00
hira e2c7784538 Sync SYNOPSIS with usage() (correct location of -P). 2007-10-26 16:31:16 +00:00
hira c710611df5 Add -N to usage. 2007-10-26 16:21:25 +00:00
jld eaef8d4ad7 Touching up the permissions to preserve set-ID bits is appropriate
only in the case where the destination did not previously exist, and
necessary only when -p isn't given.

Closes PR bin/30188.
2007-10-25 03:51:14 +00:00
alc 1d470e84d6 fix whitespace nits (space -> tab) 2006-12-26 00:13:24 +00:00
christos 640b35e022 c99 initializers 2006-10-15 23:55:30 +00:00
jschauma d59f01f8fb 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.
2006-08-15 23:03:51 +00:00
tron af4d285682 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.
2006-08-15 13:06:02 +00:00
jschauma 471c8a8e68 return functionality backed out yesterday after fixing the bug I had
introduced before.  A regression test will be added to src/regress
shortly.
2006-07-16 16:22:24 +00:00
jschauma d8c803bc48 The last commit introduced a bug. Revert until that's found and fixed. 2006-07-15 20:42:55 +00:00
jschauma 2b5fd7fd97 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).
2006-07-15 02:09:47 +00:00
erh a329a6a0ae Fix Coverity issue 1754. Call fts_close() after we're done copying. 2006-03-17 06:22:30 +00:00
christos 95355c05c7 - 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
2005-11-16 22:42:12 +00:00
kleink fd4c891ff8 Remove the "" -> "." target conversion kludge. 2005-10-24 12:59:07 +00:00
christos 509c72ef94 - 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.
2005-10-15 18:22:18 +00:00
wiz d8b6049e03 Sort options. Simplify macro usage. Use standard EXIT STATUS section. 2005-09-10 21:51:57 +00:00
elad 76ed05e8b1 Add and document -N: When used with -p, it will not copy the file flags.
PR 13645.
2005-08-15 17:13:35 +00:00
christos 6310b59691 sprinkle a little const, and now everything compiles with WARNS=3 2005-06-26 19:10:48 +00:00
jschauma ad8530d1eb remove unused code left from printescaped() backput as pointed out by Jeff
Ito in PR bin/23969 and PR bin/23970.
2004-01-04 16:04:18 +00:00
jschauma 6a75fbb636 Following private discussion with kleink@ and hubertf@ and public discussion
on tech-userlevel@, back out printescaped() functionality.
kleink: ``We sell rope.''
2003-09-14 19:20:16 +00:00
agc b5b2954259 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22249, verified by myself.
2003-08-07 09:05:01 +00:00
jschauma 458ed23412 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.
2003-08-04 22:31:21 +00:00
simonb 276fd1665c The Double-Semi-Colon Police. 2003-01-20 05:29:53 +00:00
wiz 99bdb6a773 For each, not Foreach; from Adrian Mrva. Begin new sentence on new line. 2002-12-21 13:09:57 +00:00
wiz 5911fe5347 Drop trailing whitespace. 2002-12-18 20:28:51 +00:00
kleink c8ae14b05c Add -v to SYNOPSIS, clean up STANDARDS a little. Also, bump date for -v. 2002-12-18 12:15:41 +00:00