-/* $OpenBSD: cp.c,v 1.47 2018/09/07 07:11:16 martijn Exp $ */
+/* $OpenBSD: cp.c,v 1.48 2018/09/07 07:17:14 martijn Exp $ */
/* $NetBSD: cp.c,v 1.14 1995/09/07 06:14:51 jtc Exp $ */
/*
switch (curr->fts_statp->st_mode & S_IFMT) {
case S_IFLNK:
- if (copy_link(curr, !fts_dne(curr)))
+ if ((cval = copy_link(curr, !fts_dne(curr))) == 1)
rval = 1;
- else if (vflag)
+ if (!cval && vflag)
(void)fprintf(stdout, "%s -> %s\n",
curr->fts_path, to.p_path);
break;
case S_IFBLK:
case S_IFCHR:
if (Rflag) {
- if (copy_special(curr->fts_statp,
- !fts_dne(curr)))
+ if ((cval = copy_special(curr->fts_statp,
+ !fts_dne(curr))) == 1)
rval = 1;
} else
if ((cval = copy_file(curr, fts_dne(curr))) == 1)
break;
case S_IFIFO:
if (Rflag) {
- if (copy_fifo(curr->fts_statp, !fts_dne(curr)))
+ if ((cval = copy_fifo(curr->fts_statp,
+ !fts_dne(curr))) == 1)
rval = 1;
} else
if ((cval = copy_file(curr, fts_dne(curr))) == 1)
-/* $OpenBSD: utils.c,v 1.42 2018/09/07 07:14:25 martijn Exp $ */
+/* $OpenBSD: utils.c,v 1.43 2018/09/07 07:17:14 martijn Exp $ */
/* $NetBSD: utils.c,v 1.6 1997/02/26 14:40:51 cgd Exp $ */
/*-
int len;
char name[PATH_MAX];
+ if (exists && !copy_overwrite())
+ return (2);
if ((len = readlink(p->fts_path, name, sizeof(name)-1)) == -1) {
warn("readlink: %s", p->fts_path);
return (1);
int
copy_fifo(struct stat *from_stat, int exists)
{
+ if (exists && !copy_overwrite())
+ return (2);
if (exists && unlink(to.p_path)) {
warn("unlink: %s", to.p_path);
return (1);
int
copy_special(struct stat *from_stat, int exists)
{
+ if (exists && !copy_overwrite())
+ return (2);
if (exists && unlink(to.p_path)) {
warn("unlink: %s", to.p_path);
return (1);