Commit graph

190 commits

Author SHA1 Message Date
Bryan Drewery ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Warner Losh fbbd9655e5 Renumber copyright clause 4
Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by:	Jan Schaumann <jschauma@stevens.edu>
Pull Request:	https://github.com/freebsd/freebsd/pull/96
2017-02-28 23:42:47 +00:00
Glen Barber ac2875fa16 Explicitly add unmarked bin/ binaries to the runtime package.
Note: tcsh(1) has a MK_TCSH=no test, so this should be a separate
package, which requires pre-install/post-install scripts, to be
added later.

Sponsored by:	The FreeBSD Foundation
2016-02-09 16:58:50 +00:00
Simon J. Gerraty ccfb965433 Add META_MODE support.
Off by default, build behaves normally.
WITH_META_MODE we get auto objdir creation, the ability to
start build from anywhere in the tree.

Still need to add real targets under targets/ to build packages.

Differential Revision:       D2796
Reviewed by: brooks imp
2015-06-13 19:20:56 +00:00
Simon J. Gerraty 44d314f704 dirdeps.mk now sets DEP_RELDIR 2015-06-08 23:35:17 +00:00
Bryan Drewery 724fd44827 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
2015-06-08 19:24:18 +00:00
Bryan Drewery 7ea2450f42 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
2015-06-07 06:30:25 +00:00
Bryan Drewery 14376e1f21 Cleanup some indentation issues. 2015-06-07 03:49:41 +00:00
Simon J. Gerraty 98e0ffaefb Merge sync of head 2015-05-27 01:19:58 +00:00
Jilles Tjoelker c633f8dc04 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
2015-05-05 13:23:03 +00:00
Jilles Tjoelker 347b9f6de0 cp,mv: Use futimens() instead of utimensat() if possible. 2015-03-23 17:35:05 +00:00
Jilles Tjoelker 5faf2ae160 cp,mv,touch: Set timestamps with nanosecond precision.
This uses utimensat().
2015-01-24 13:50:13 +00:00
Simon J. Gerraty fae50821ae Updated dependencies 2014-05-16 14:09:51 +00:00
Simon J. Gerraty 76b28ad6ab Updated dependencies 2014-05-10 05:16:28 +00:00
Simon J. Gerraty 69e6d7b75e sync from head 2013-04-12 20:48:55 +00:00
Joel Dahl e9e3a1ab1f Add a few examples.
Obtained from:	OpenBSD
2013-03-15 20:12:54 +00:00
Simon J. Gerraty 7cf3a1c6b2 Updated dependencies 2013-03-11 17:21:52 +00:00
Simon J. Gerraty f5f7c05209 Updated dependencies 2013-02-16 01:23:54 +00:00
David E. O'Brien d9a447559b Sync with HEAD. 2013-02-08 16:10:16 +00:00
Mark Johnston 111a5d7c78 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
2013-01-27 05:59:28 +00:00
David E. O'Brien e4573a9a7b 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
2013-01-23 02:06:20 +00:00
Eitan Adler 76d916f1f5 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
2013-01-17 04:20:31 +00:00
Simon J. Gerraty 23090366f7 Sync from head 2012-11-04 02:52:03 +00:00
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
Marcel Moolenaar 7750ad47a9 Sync FreeBSD's bmake branch with Juniper's internal bmake branch.
Requested by: Simon Gerraty <sjg@juniper.net>
2012-08-22 19:25:57 +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
Mark Murray 13fcef50d0 Fix some easy WARNS. 2002-07-31 16:52:16 +00:00
Johan Karlsson 786c276fe4 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
2002-07-23 00:42:56 +00:00
Sheldon Hearn ced4deb156 Revert previous delta, which is not required with rev 1.5 of
src/contrib/gcc/c-format.c .
2002-07-15 12:08:21 +00:00
Sheldon Hearn a3ee32f3f7 Set WFORMAT=0, because our compiler currently complains about NULL
arg 2 to err() and friends, and warnings are promoted to errors.

This allows the following revisions to be reverted:

	rev 1.39	src/bin/cp/cp.c
	rev 1.26	src/bin/chmod/chmod.c
	rev 1.40	src/bin/rm/rm.c

The following revisions can already be reverted, because they were
already covered by WFORMAT=0:

	rev 1.8		src/bin/ls/lomac.c
	rev 1.63	src/bin/ls/ls.c
	rev 1.8		src/bin/ps/lomac.c
	rev 1.34	src/bin/rcp/rcp.c
2002-07-11 08:45:38 +00:00
Matthew Dillon 5ad9e45f96 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.
2002-07-10 20:44:55 +00:00
Mark Murray 7ede89e44b Fix some low-hanging lint-fruit: endianness and staticness warnings. 2002-07-03 16:35:20 +00:00
David E. O'Brien 5eb43ac2f7 Consistently use __FBSDID 2002-06-30 05:13:54 +00:00
Tim J. Robbins f9dc2a8b93 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
2002-06-13 15:48:36 +00:00
Andrey A. Chernov 486d038778 Optimize prev. commit code a bit 2002-05-17 12:24:19 +00:00
Andrey A. Chernov 27d3ae3587 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.
2002-05-17 11:52:48 +00:00
Alfred Perlstein 64baebf95b Add semicolon to empty default case to silence warning. 2002-05-11 00:21:00 +00:00
Bruce Evans b909fa9cd0 Fixed some style bugs in revs 1.1 and 1.4. 2002-02-23 17:05:32 +00:00
Mark Murray 8bd08b5fac Fix warnings inspired by lint, a commercial lint and WARNS=4. 2002-02-22 21:24:14 +00:00
Warner Losh 5dce647c1b 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)
2002-02-02 06:15:22 +00:00
Stephen McKay 16ef4ac3a3 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. :-)
2002-01-01 06:14:26 +00:00
Stephen McKay 62de071bfb 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
2001-12-23 11:16:14 +00:00
Stephen McKay 4a5db7acfb 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
2001-12-11 13:18:10 +00:00
Stephen McKay 048e497627 Typo in warning message (chown should be chmod). 2001-12-11 13:14:15 +00:00
David E. O'Brien a748290789 Default to WARNS=2. Binary builds that cannot handle this must explicitly
set WARNS=0.

Reviewed by:	mike
2001-12-04 01:57:47 +00:00
Ruslan Ermilov d628d776c4 mdoc(7) police: utilize the new .Ex macro. 2001-08-15 09:09:47 +00:00
Dima Dorfman 7ebcc426ef Remove whitespace at EOL. 2001-07-15 07:53:42 +00:00
Ruslan Ermilov caa2db3be9 mdoc(7) police: removed HISTORY info from the .Os call. 2001-07-10 10:04:09 +00:00
Dag-Erling Smørgrav 26f6b0fbe8 Add more headers that are required with -fno-builtin (stdlib and strings) 2001-06-19 15:41:57 +00:00
Bruce Evans e1d071dbfd 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
2001-06-11 13:57:54 +00:00
Ruslan Ermilov 95a09b0557 Make it clear that -P is the default.
PR:		docs/27629
2001-05-25 07:32:58 +00:00
Warner Losh 34f9c106b9 Migrate from using MAXPATHLEN to MAX_PATH. Use strlcpy to copy the
strings.
2001-05-16 19:10:40 +00:00