Commit Graph

116 Commits

Author SHA1 Message Date
Edward Tomasz Napierala
c55e0c62a1 Explicitly mention that "cp -p" copies ACLs.
PR:		docs/168962
MFC after:	1 month
2012-09-04 12:27:23 +00:00
Edward Tomasz Napierala
9fa5f90fbf 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
2010-06-05 08:50:39 +00:00
Ed Schouten
99742a231f 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.
2010-03-28 13:16:08 +00:00
Gavin Atkinson
f815125fbc 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
2010-01-17 09:37:31 +00:00
Edward Tomasz Napierala
2689ba2720 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
2009-09-02 08:08:57 +00:00
Jilles Tjoelker
f2db75739c 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
2009-05-30 10:36:14 +00:00
Edward Tomasz Napierala
ae1add4e55 Make 'struct acl' larger, as required to support NFSv4 ACLs. Provide
compatibility interfaces in both kernel and libc.

Reviewed by:	rwatson
2009-05-22 15:56:43 +00:00
Ivan Voras
e9cbc9a770 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
2008-10-30 14:05:57 +00:00
Diomidis Spinellis
cce2092c73 Add fallback when mmap fails on regular files. Some filesystems,
like smbnetfs, do not support mmap.

Reported by:	Harti Brandt
MFC after:	1 month
2008-10-27 15:21:15 +00:00
Edward Tomasz Napierala
70583fbb77 Remove redundant close(2).
Submitted by:	kensmith
Approved by:	rwatson (mentor)
2008-09-09 12:31:42 +00:00
Edward Tomasz Napierala
2aafc4d48c Fix ACL preservation, apparently broken in 1.47.
Approved by:	rwatson
MFC after:	3 weeks
2008-08-07 07:29:26 +00:00
John Baldwin
d140946cf3 Add an '-a' option which is identical to specifying '-RpP' for
compatibility with other implementations.

MFC after:	1 month
2008-03-10 19:58:41 +00:00
Edwin Groothuis
a76b9b6973 As suggested, replace earlier changed warnx() / exit() with an errx()
Submitted by:	Peter Jeremy <peterjeremy@optushome.com.au>
2007-12-26 08:32:20 +00:00
Edwin Groothuis
0d5ee457ad 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@
2007-12-25 00:40:32 +00:00
Ceri Davies
b873ae5ca9 Fix typo. 2006-11-02 19:10:05 +00:00
Tom Rhodes
f3955abb6f Wording nits. 2006-10-27 08:26:24 +00:00
Tom Rhodes
6138defa43 Flesh out the compatibility section a little bit. Bump doc date. 2006-10-24 18:42:42 +00:00
Tom Rhodes
43d8847e0b Fix style(9) bugs in previous commit.
Lesson from:	bde
2006-10-11 10:26:34 +00:00
Tom Rhodes
ba3fe6d1ab 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)
2006-10-07 22:14:43 +00:00
Maxim Konovalov
9bdb7f2e54 o Style(9).
Submitted by:	bde
2006-10-07 12:14:50 +00:00
Maxim Konovalov
eb82e1a1f8 o Avoid division by zero.
o Place error checking code near to the syscall.

Submitted by:	bde
2006-10-07 12:11:21 +00:00
Maxim Konovalov
6a861e9bfb 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
2006-10-06 08:30:33 +00:00
Ruslan Ermilov
64941e9d80 Move the -l option processing to where it belongs.
Overall still not kosher but better matches style(9).
2006-09-29 06:06:39 +00:00
Ruslan Ermilov
cbae88b901 - Fix options order.
- Touch manpage's document date.
2006-08-25 09:58:13 +00:00
Ruslan Ermilov
d9c7237d04 Remove a stray -a option that probably sneaked in from julian's
attempt to enter append mode twice in vi(1).  :-)
2006-08-25 09:42:16 +00:00
Julian Elischer
6fa363774d 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
2006-08-24 20:45:38 +00:00
Maxim Konovalov
867e6caf17 o Call fts_close() before exit.
Obtained from:	NetBSD, Coverity ID 1754
2006-07-04 20:52:36 +00:00
Christian S.J. Peron
9b4261c9b4 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
2005-09-05 04:36:08 +00:00
Tom Rhodes
61001d7506 Fix a few markup nits in previous commit.
Noticed by:	ru, who else? :)
2005-02-25 00:40:46 +00:00
Tom Rhodes
a5e1813654 Note how cp(1) handles directories ending in "/."
PR:		75774
Submitted by:	Mike Meyer <mwm@mired.org> (original version)
2005-02-24 00:06:22 +00:00
Ruslan Ermilov
a89237ae95 Sync program's usage() with manpage's SYNOPSIS. 2005-02-09 17:37:39 +00:00
Ruslan Ermilov
6fca4c7c3f Add the new standard EXIT STATUS section where appropriate.
Sort standard sections in the (documented) preferred order.
2005-01-16 16:41:59 +00:00
Warner Losh
9ddb49cbe4 /*- or .\"- or #- to begin license clauses. 2005-01-10 08:39:26 +00:00
Ruslan Ermilov
eccea571a7 Mechanically kill hard sentence breaks. 2004-07-02 21:04:19 +00:00
Tim J. Robbins
7807cb2439 Plug file descriptor leak in implementation of -n option. 2004-06-05 02:32:21 +00:00
Mark Murray
6195fb4102 Remove clause 3 from the UCB licenses.
OK'ed by:	imp, core
2004-04-06 20:06:54 +00:00
Alan Cox
b9e25f436b Don't mmap(2) and munmap(2) zero-length files.
Submitted by:	Wiktor Niesiobedzki <bsd@w.evip.pl>
2003-11-13 05:26:55 +00:00
John-Mark Gurney
529a7167bd pass -1 to setfile in cp.c
Submitted by:	Jun Kuriyama
2003-06-30 06:16:06 +00:00
John-Mark Gurney
a6b05ab6ea 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
2003-06-22 07:02:17 +00:00
Ruslan Ermilov
7d2191c827 Clarify what -p option does.
Prodded by:	marcel

While here, spell the "set-{user,group}-ID bit" correctly.
2003-06-07 06:35:36 +00:00
David E. O'Brien
09a80d4867 Quiet warnings about copyright[]. 2003-05-01 16:58:57 +00:00
Bruce Evans
82fdc5e61b 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.
2003-04-13 08:47:30 +00:00
Bruce Evans
4901f51b4e Fixed some style bugs in rev.1.44. 2003-04-13 08:27:35 +00:00
Matthew N. Dodd
947193d93f Use the correct data type and qualifier for signal flag. 2003-04-07 12:09:17 +00:00
Matthew N. Dodd
00d321a2b3 Add a SIGINFO handler. 2003-04-07 11:00:56 +00:00
Mark Murray
ba8acd9de2 Constify and staticify for lint. 2002-10-18 14:45:00 +00:00
Stephen McKay
eedc99e7b5 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
2002-09-22 11:15:56 +00:00
Garrett Wollman
0d3bcc2e80 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
2002-09-21 01:28:41 +00:00
Johan Karlsson
e849cfacaa Bump document date for the -n option.
Approved by: sheldonh (mentor)
2002-08-16 03:13:59 +00:00
Ruslan Ermilov
c3ff3e424c mdoc(7) police: grammar. 2002-08-09 10:38:34 +00:00