Commit Graph

71 Commits

Author SHA1 Message Date
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
Stephen McKay
b931f9b350 In the hope of saving others from hours of tedious recovery work,
document that cp still isn't very useful for recursive copies even
with the -R flag.  This is because hard links are broken by cp.
2001-02-04 02:02:38 +00:00
Ruslan Ermilov
be8b149795 mdoc(7) police: use the new features of the Nm macro. 2000-11-20 11:39:41 +00:00
Garrett Wollman
eb2fc78027 Don't depend on <sys/stat.h> bogusly including <sys/time.h> (and thereby
<time.h>).
2000-10-10 01:50:26 +00:00
Michael Haro
127432d7e2 fix cp -vi bug
Submitted by:	Dan Papasian (bugg_ on irc)
2000-01-23 03:04:49 +00:00
Michael Haro
0efa204039 brucify
Reviewed by:	obrien
1999-11-28 09:34:21 +00:00
Michael Haro
fcb2f1b389 brucify and move printf() to catch cases of special files 1999-08-29 07:58:19 +00:00
Peter Wemm
2a4562393f $Id$ -> $FreeBSD$ 1999-08-27 23:15:48 +00:00
Michael Haro
4506e9078e Add a verbose mode to show what files are being copied.
Idea taken from obrien.

Reviewed by:	obrien
1999-08-26 02:44:56 +00:00
Kris Kennaway
1f2dedd83d Add -W and fix the warning due to missing struct initializer 1999-07-10 05:46:44 +00:00
Kris Kennaway
46be34b902 Various spelling/formatting changes.
Submitted by: Philippe Charnier <charnier@xp11.frmug.org>
1999-05-08 10:22:15 +00:00
Warner Losh
426e9c1dcc First set of fixes to keep egcs happy. These include {} around single
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
1999-04-25 21:13:34 +00:00
Bruce Evans
40fc4ee2de Don't use mmap() for non-regular files, since st_size is only meaningful
for regular files.  This fixes recent breakage of cp'ing from /dev/zero.
/dev/zero doesn't support mmap(), but the device driver mmap routines are
not called for mapping 0 bytes, so the error was not detected.  mmap()
can't even be used for cp'ing special files that support mmap(), since
there is general way to determine the file size.
1998-11-18 11:47:45 +00:00
Wolfram Schneider
146726f36f Use mmap for file coping. 5-10% faster than the read system call. 1998-11-14 23:43:11 +00:00
Joseph Koshy
22f6653381 Correct a grammatical nit and remove ambiguity about the effect of
the -p option.

PR:		8229
Submitted-by:	Sheldon Hearn <axl@iafrica.com>
1998-10-13 08:52:29 +00:00
Peter Wemm
4faaa03777 Don't attempt to change owner/mode/flags that don't need to changed.
This should calm down attempts to `cp -p' to a nfs mount or some other
filesystem that doesn't accept flags or all combinations of flags.
It will warn if it fails to change flags though.
1998-06-10 06:29:23 +00:00
Dmitrij Tejblum
f6fa1b35fd Print correct error message if we copy an unreadable directory. 1998-06-09 13:42:51 +00:00
Warner Losh
e00e592a7a Make sure we pass the length - 1 to readlink, since it adds its own
NUL at the end of the path.
Inspired by: OpenBSD's changes in this area by theo de raadt
1998-06-09 03:38:43 +00:00
Philippe Charnier
c194af34bd Restore Lite-2 sccsid. 1998-05-13 07:25:17 +00:00
Philippe Charnier
cbf6f7d358 Correct use of .Nm and other cosmetics. Add rcsid. Remove unused #inc. 1998-05-06 06:51:42 +00:00