summaryrefslogtreecommitdiffstats
path: root/bin/cp/cp.c
Commit message (Collapse)AuthorAgeFilesLines
* MFC r284105,r284106,r284163:bdrewery2015-12-041-17/+23
| | | | | | | | | | | | r284105: Cleanup some indentation issues. r284106: Implement '-s' to copy as symlink, similar to the current -l link(2) handling. r284163: Cleanup some style(9) issues. Relnotes: yes
* MFC r282482: cp: Remove fts sorting.jilles2015-05-141-28/+1
| | | | | | | | | | | | | | | | | | | | | 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)
* Remove useless variable 'Pflag':eadler2013-01-171-7/+5
| | | | | | | -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
* Don't try to copy a socket after "xxx is a socket (not copied)." message.trasz2010-06-051-0/+1
| | | | | | | | | 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
* Implement an "-x" option to cp(1), for compatibility with Linux andgavin2010-01-171-2/+5
| | | | | | | | | | | | 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
* Add an '-a' option which is identical to specifying '-RpP' forjhb2008-03-101-1/+7
| | | | | | compatibility with other implementations. MFC after: 1 month
* As suggested, replace earlier changed warnx() / exit() with an errx()edwin2007-12-261-4/+3
| | | | Submitted by: Peter Jeremy <peterjeremy@optushome.com.au>
* When copying multiple files to a directory, make sure that a properedwin2007-12-251-1/+1
| | | | | | | | | 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@
* Fix style(9) bugs in previous commit.trhodes2006-10-111-7/+4
| | | | Lesson from: bde
* Make -r a synonym for -R, similar to behavior on Linux while being backwardstrhodes2006-10-071-11/+9
| | | | | | | | 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)
* Move the -l option processing to where it belongs.ru2006-09-291-4/+4
| | | | Overall still not kosher but better matches style(9).
* Add an option to allow copying of a hierarchy while linking he regular files.julian2006-08-241-2/+8
| | | | | | Bikeshedded to death on: hackers Submitted by:andersonatcenttech.com MFC in: 1 month
* o Call fts_close() before exit.maxim2006-07-041-0/+1
| | | | Obtained from: NetBSD, Coverity ID 1754
* Attempt to complete the userspace integration of POSIX.1e extended ACLs.csjp2005-09-051-1/+4
| | | | | | | | | | | | | | 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
* /*- or .\"- or #- to begin license clauses.imp2005-01-101-1/+1
|
* Remove clause 3 from the UCB licenses.markm2004-04-061-4/+0
| | | | OK'ed by: imp, core
* pass -1 to setfile in cp.cjmg2003-06-301-1/+1
| | | | Submitted by: Jun Kuriyama
* Quiet warnings about copyright[].obrien2003-05-011-2/+2
|
* Include <signal.h> instead of depending on namespace pollution inbde2003-04-131-1/+2
| | | | | <sys/param.h>. Include <sys/types.h> instead of of <sys/param.h> so that further such dependencies don't develop.
* Fixed some style bugs in rev.1.44.bde2003-04-131-3/+2
|
* Use the correct data type and qualifier for signal flag.mdodd2003-04-071-1/+1
|
* Add a SIGINFO handler.mdodd2003-04-071-0/+11
|
* Constify and staticify for lint.markm2002-10-181-2/+2
|
* cp -p could report success even if a file copy failed. This was due tomckay2002-09-221-3/+4
| | | | | | | | | | | 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
* Make the threatened fts(3) ABI fix. FTSENT now avoids the use of the structwollman2002-09-211-2/+2
| | | | | | | | | | | | | | | | 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
* Add the -n option, which automatically answers "no" to the overwrite question.johan2002-07-231-5/+9
| | | | | | | PR: 7828 Suggested by: Daniel O'Connor <doconnor@gsoft.com.au> Approved by: sheldonh (mentor) MFC after: 2 weeks
* err() is documented as allowing NULL for the format string but GCC isn'tdillon2002-07-101-1/+1
| | | | happy about it any more so change the usage to make buildworld work again.
* Fix some low-hanging lint-fruit: endianness and staticness warnings.markm2002-07-031-2/+2
|
* Consistently use __FBSDIDobrien2002-06-301-2/+2
|
* When -R is not specified, fail to copy the contents of dangling symlinkstjr2002-06-131-3/+11
| | | | | | instead of making a copy of the link itself (SUSv3) Obtained from: NetBSD
* Optimize prev. commit code a bitache2002-05-171-4/+4
|
* Trailing slash fixes.ache2002-05-171-2/+12
| | | | | | | | | | 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.
* Add semicolon to empty default case to silence warning.alfred2002-05-111-0/+1
|
* Fix warnings inspired by lint, a commercial lint and WARNS=4.markm2002-02-221-4/+10
|
* Modernization effort for bin/c*:imp2002-02-021-11/+5
| | | | | | | | | | | | 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)
* Bruce thought some of the comments I added were not clear enough. This ismckay2002-01-011-8/+8
| | | | a combination of my words and his. We will stop fiddling now. :-)
* The previous fix caused cp to emit spurious warnings under somemckay2001-12-231-22/+26
| | | | | | | 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
* Preserve directory timestamps with -p. Allow non-empty read-onlymckay2001-12-111-11/+39
| | | | | | | | | | directories to be copied. Apply umask to newly created directories when -p is not specified. PR: 27970 PR: 31633 MFC after: 4 days
* Add more headers that are required with -fno-builtin (stdlib and strings)des2001-06-191-0/+1
|
* Removed the broken code which claimed to lose the set[ug]id bits inbde2001-06-111-8/+0
| | | | | | | | | | | | | | | | | | | | | 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
* Migrate from using MAXPATHLEN to MAX_PATH. Use strlcpy to copy theimp2001-05-161-3/+3
| | | | strings.
* brucifymharo1999-11-281-16/+16
| | | | Reviewed by: obrien
* brucify and move printf() to catch cases of special filesmharo1999-08-291-2/+2
|
* $Id$ -> $FreeBSD$peter1999-08-271-1/+1
|
* Add a verbose mode to show what files are being copied.mharo1999-08-261-3/+9
| | | | | | Idea taken from obrien. Reviewed by: obrien
* Add -W and fix the warning due to missing struct initializerkris1999-07-101-2/+2
|
* Various spelling/formatting changes.kris1999-05-081-2/+2
| | | | Submitted by: Philippe Charnier <charnier@xp11.frmug.org>
* First set of fixes to keep egcs happy. These include {} around singleimp1999-04-251-2/+3
| | | | | | | | | | 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
* Print correct error message if we copy an unreadable directory.dt1998-06-091-1/+2
|
* Restore Lite-2 sccsid.charnier1998-05-131-2/+2
|
OpenPOWER on IntegriCloud