Commit Graph

62 Commits

Author SHA1 Message Date
christos
c4078bc63f fix reversed test. 2020-05-22 14:54:30 +00:00
christos
f6a91933fb No ACL support for install media (SMALLPROG) 2020-05-17 23:34:11 +00:00
christos
9aa2a9c323 Add ACL support for FFS. From FreeBSD. 2020-05-16 18:31:45 +00:00
uwe
0d7369c54b 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.
2016-03-05 19:48:55 +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
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
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
christos
9985da2181 Add -a archive flag. from Aleksey Cheusov 2010-12-21 20:56:01 +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
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
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
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
jrf
4e81454aa9 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. 2002-12-16 14:44:14 +00:00
wiz
633b06fe1e ANSIfication and some KNF fixes by Petri Koistinen from bin/13681. 2001-09-13 09:53:59 +00:00
itojun
a1e2f21a4c errx?/warnx? audit. do not pass variable alone, use %s. idea from openbsd 2000-07-07 12:50:15 +00:00
matt
e2056eada9 include <stdlib.h>, <string.h>, or whatever as appropriate to shut up
gcc 2.96
2000-07-03 03:26:17 +00:00
kleink
89e0b77a2f Initialize locale on startup. 1999-09-05 16:14:43 +00:00
mjl
382ab5ae40 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.
1999-03-01 18:57:29 +00:00
dean
033ff5b1e1 Got rid of redundant error message (X is a directory (not copied). was
printed twice)
1999-02-25 05:43:04 +00:00
wsanchez
8a99d7cf5d 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.
1998-10-08 17:43:24 +00:00
thorpej
8d68a9dce5 Add some braces to keep egcs happy. 1998-08-19 01:29:11 +00:00
mycroft
ee9e50eacb Be more retentive about use of NOTREACHED and noreturn. 1998-07-28 11:41:40 +00:00
mycroft
9dc385beb1 Delint. 1998-07-28 05:31:22 +00:00
mycroft
29bf463dcb Delint. 1998-07-28 04:01:03 +00:00
mycroft
ce7d757530 Delint. 1998-07-28 03:47:14 +00:00
lukem
df49b6cc7f * getopt returns -1 not EOF
* cleanup use of .Nm in manpage
1997-09-14 07:15:25 +00:00
thorpej
efc20a3095 - Use __COPYRIGHT() and __RCSID()
- Fix compiler warnings.
1997-07-20 05:13:36 +00:00
kleink
8385a5edde Fix one remaining botch when copying directory trees using -R. 1997-05-21 09:48:33 +00:00
kleink
bdad0c3627 Fix thinko in last commit, causing "cp file /" to succeed but
"cp file1 file2 /" to fail badly; fixes PR/3646 from Paul Kranenburg.
1997-05-19 01:07:33 +00:00
kleink
3a978953a9 Fix lossage with new namei() when the destination given is "/";
reported by Bernd Ernesti.
1997-04-09 12:06:13 +00:00
jtc
5fc5415e25 Sync with 4.4lite2 1995-09-07 06:12:53 +00:00
mycroft
50130476f4 Fix typo in S_FIFO case when copying recursively. 1995-04-02 01:45:25 +00:00