Rename dne in copy_file to exists to be more consistent with the other
authormartijn <martijn@openbsd.org>
Fri, 7 Sep 2018 07:44:15 +0000 (07:44 +0000)
committermartijn <martijn@openbsd.org>
Fri, 7 Sep 2018 07:44:15 +0000 (07:44 +0000)
copy_* functions.

OK stsp@

bin/cp/cp.c
bin/cp/utils.c

index 7df4358..23f4245 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: cp.c,v 1.48 2018/09/07 07:17:14 martijn Exp $ */
+/*     $OpenBSD: cp.c,v 1.49 2018/09/07 07:44:15 martijn Exp $ */
 /*     $NetBSD: cp.c,v 1.14 1995/09/07 06:14:51 jtc Exp $      */
 
 /*
@@ -434,7 +434,7 @@ copy(char *argv[], enum op type, int fts_options)
                                    !fts_dne(curr))) == 1)
                                        rval = 1;
                        } else
-                               if ((cval = copy_file(curr, fts_dne(curr))) == 1)
+                               if ((cval = copy_file(curr, !fts_dne(curr))) == 1)
                                        rval = 1;
                        if (!cval && vflag)
                                (void)fprintf(stdout, "%s -> %s\n",
@@ -447,7 +447,7 @@ copy(char *argv[], enum op type, int fts_options)
                                    !fts_dne(curr))) == 1)
                                        rval = 1;
                        } else
-                               if ((cval = copy_file(curr, fts_dne(curr))) == 1)
+                               if ((cval = copy_file(curr, !fts_dne(curr))) == 1)
                                        rval = 1;
                        if (!cval && vflag)
                                (void)fprintf(stdout, "%s -> %s\n",
@@ -458,7 +458,7 @@ copy(char *argv[], enum op type, int fts_options)
                        warnc(EOPNOTSUPP, "%s", curr->fts_path);
                        break;
                default:
-                       if ((cval = copy_file(curr, fts_dne(curr))) == 1)
+                       if ((cval = copy_file(curr, !fts_dne(curr))) == 1)
                                rval = 1;
                        if (!cval && vflag)
                                (void)fprintf(stdout, "%s -> %s\n",
index 1b431f4..fd2af24 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: utils.c,v 1.43 2018/09/07 07:17:14 martijn Exp $      */
+/*     $OpenBSD: utils.c,v 1.44 2018/09/07 07:44:15 martijn Exp $      */
 /*     $NetBSD: utils.c,v 1.6 1997/02/26 14:40:51 cgd Exp $    */
 
 /*-
@@ -50,7 +50,7 @@
 int copy_overwrite(void);
 
 int
-copy_file(FTSENT *entp, int dne)
+copy_file(FTSENT *entp, int exists)
 {
        static char *buf;
        static char *zeroes;
@@ -82,7 +82,7 @@ copy_file(FTSENT *entp, int dne)
         * In -f (force) mode, we always unlink the destination first
         * if it exists.  Note that -i and -f are mutually exclusive.
         */
-       if (!dne && fflag)
+       if (exists && fflag)
                (void)unlink(to.p_path);
 
        /*
@@ -92,7 +92,7 @@ copy_file(FTSENT *entp, int dne)
         * other choice is 666 or'ed with the execute bits on the from file
         * modified by the umask.)
         */
-       if (!dne && !fflag) {
+       if (exists && !fflag) {
                if (!copy_overwrite()) {
                        (void)close(from_fd);
                        return 2;
@@ -174,7 +174,7 @@ copy_file(FTSENT *entp, int dne)
         */
 #define        RETAINBITS \
        (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
-       if (!pflag && dne &&
+       if (!pflag && !exists &&
            fs->st_mode & (S_ISUID | S_ISGID) && fs->st_uid == myuid) {
                if (fstat(to_fd, &to_stat)) {
                        warn("%s", to.p_path);