aboutsummaryrefslogtreecommitdiff
path: root/bin/cp/cp.c
diff options
context:
space:
mode:
authorSteve Price <steve@FreeBSD.org>1996-12-14 05:51:58 +0000
committerSteve Price <steve@FreeBSD.org>1996-12-14 05:51:58 +0000
commit890acb955471d216b422af74ba8dfd47c1771129 (patch)
tree447afd24de0cc1372c018635be4f5a093235e666 /bin/cp/cp.c
parent1686b60268692ad91b2f95460bedaaec14a22d5e (diff)
downloadsrc-890acb955471d216b422af74ba8dfd47c1771129.tar.gz
src-890acb955471d216b422af74ba8dfd47c1771129.zip
Merge Lite2 mods and -Wall cleaning.
Notes
Notes: svn path=/head/; revision=20412
Diffstat (limited to 'bin/cp/cp.c')
-rw-r--r--bin/cp/cp.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/bin/cp/cp.c b/bin/cp/cp.c
index 83f8a9cd0f29..6176ed46f6d8 100644
--- a/bin/cp/cp.c
+++ b/bin/cp/cp.c
@@ -33,17 +33,17 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: cp.c,v 1.9 1996/02/19 05:56:33 pst Exp $
+ * $Id: cp.c,v 1.10 1996/03/08 06:58:06 wosch Exp $
*/
#ifndef lint
-static char copyright[] =
+static char const copyright[] =
"@(#) Copyright (c) 1988, 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)cp.c 8.2 (Berkeley) 4/1/94";
+static char const sccsid[] = "@(#)cp.c 8.2 (Berkeley) 4/1/94";
#endif /* not lint */
/*
@@ -51,7 +51,7 @@ static char sccsid[] = "@(#)cp.c 8.2 (Berkeley) 4/1/94";
*
* The global PATH_T structure "to" always contains the path to the
* current target file. Since fts(3) does not change directories,
- * this path can be either absolute or dot-realative.
+ * this path can be either absolute or dot-relative.
*
* The basic algorithm is to initialize "to" and use fts(3) to traverse
* the file hierarchy rooted in the argument list. A trivial case is the
@@ -253,7 +253,7 @@ copy(argv, type, fts_options)
struct stat to_stat;
FTS *ftsp;
FTSENT *curr;
- int base, dne, nlen, rval;
+ int base = 0, dne, nlen, rval;
char *p, *target_mid;
if ((ftsp = fts_open(argv, fts_options, mastercmp)) == NULL)
@@ -341,6 +341,13 @@ copy(argv, type, fts_options)
(void)fts_set(ftsp, curr, FTS_SKIP);
continue;
}
+ if (!S_ISDIR(curr->fts_statp->st_mode) &&
+ S_ISDIR(to_stat.st_mode)) {
+ warnx("cannot overwrite directory %s with non-directory %s",
+ to.p_path, curr->fts_path);
+ rval = 1;
+ continue;
+ }
dne = 0;
}