aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncaen <mail@duncano.de>2017-05-24 03:05:28 +0200
committerDuncaen <mail@duncano.de>2017-05-24 03:20:11 +0200
commit575e5008b898c51ae7f786e0a4a9a99b4ea4b542 (patch)
tree47a22eb9d08dd1496a0f87fb615d3171a97852b7
parent6142aa55810a8a85f17727fa1f6ff9f814c5f728 (diff)
downloadlobase-575e5008b898c51ae7f786e0a4a9a99b4ea4b542.tar.gz
bin/mv: update to OPENBSD_6_1
-rw-r--r--bin/mv/mv.c4
-rw-r--r--bin/mv/pathnames.h36
-rw-r--r--bin/mv/rm.c118
3 files changed, 4 insertions, 154 deletions
diff --git a/bin/mv/mv.c b/bin/mv/mv.c
index b26338b..714886f 100644
--- a/bin/mv/mv.c
+++ b/bin/mv/mv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mv.c,v 1.43 2015/11/17 18:34:00 tedu Exp $ */
+/* $OpenBSD: mv.c,v 1.44 2016/10/11 16:16:44 millert Exp $ */
/* $NetBSD: mv.c,v 1.9 1995/03/21 09:06:52 cgd Exp $ */
/*
@@ -49,8 +49,6 @@
#include <pwd.h>
#include <grp.h>
-#include "pathnames.h"
-
extern char *__progname;
int fflg, iflg;
diff --git a/bin/mv/pathnames.h b/bin/mv/pathnames.h
index 3931d23..e69de29 100644
--- a/bin/mv/pathnames.h
+++ b/bin/mv/pathnames.h
@@ -1,36 +0,0 @@
-/* $OpenBSD: pathnames.h,v 1.3 2003/06/02 23:32:08 millert Exp $ */
-/* $NetBSD: pathnames.h,v 1.6 1995/03/21 09:06:55 cgd Exp $ */
-
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)pathnames.h 8.1 (Berkeley) 5/31/93
- */
-
-#define _PATH_RM "/bin/rm"
-#define _PATH_CP "/bin/cp"
diff --git a/bin/mv/rm.c b/bin/mv/rm.c
index afb60b8..7ad5fcf 100644
--- a/bin/mv/rm.c
+++ b/bin/mv/rm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rm.c,v 1.7 2015/11/27 17:32:16 tedu Exp $ */
+/* $OpenBSD: rm.c,v 1.11 2016/10/10 18:13:21 tedu Exp $ */
/* $NetBSD: rm.c,v 1.19 1995/09/07 06:48:50 jtc Exp $ */
/*-
@@ -31,8 +31,6 @@
*/
#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mount.h>
#include <err.h>
#include <errno.h>
@@ -42,46 +40,20 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <limits.h>
-#include <pwd.h>
-#include <grp.h>
-#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b))
+static int eval;
-extern char *__progname;
-
-static int eval, stdin_ok;
-
-static int check(char *, char *, struct stat *);
static void checkdot(char **);
-static void rm_file(char **);
static void rm_tree(char **);
-static void __dead
-usage(void)
-{
- (void)fprintf(stderr, "usage: %s [-dfiPRr] file ...\n", __progname);
- exit(1);
-}
-
-/*
- * rm --
- * This rm is different from historic rm's, but is expected to match
- * POSIX 1003.2 behavior. The most visible difference is that -f
- * has two specific effects now, ignore non-existent files and force
- * file removal.
- */
int
rmmain(int argc, char *argv[])
{
checkdot(argv);
- if (*argv) {
- stdin_ok = isatty(STDIN_FILENO);
-
+ if (*argv)
rm_tree(argv);
- }
return (eval);
}
@@ -93,12 +65,6 @@ rm_tree(char **argv)
FTSENT *p;
int flags;
- /*
- * If the -i option is specified, the user can skip on the pre-order
- * visit. The fts_number field flags skipped directories.
- */
-#define SKIPPED 1
-
flags = FTS_PHYSICAL;
flags |= FTS_NOSTAT;
if (!(fts = fts_open(argv, flags, NULL)))
@@ -114,20 +80,8 @@ rm_tree(char **argv)
continue;
case FTS_ERR:
errc(1, p->fts_errno, "%s", p->fts_path);
- case FTS_NS:
- /*
- * FTS_NS: assume that if can't stat the file, it
- * can't be unlinked.
- */
- break;
case FTS_D:
- /* Pre-order: give user chance to skip. */
continue;
- case FTS_DP:
- /* Post-order: see if user skipped. */
- if (p->fts_number == SKIPPED)
- continue;
- break;
default:
break;
}
@@ -160,72 +114,6 @@ rm_tree(char **argv)
fts_close(fts);
}
-static void
-rm_file(char **argv)
-{
- struct stat sb;
- int rval;
- char *f;
-
- /*
- * Remove a file. POSIX 1003.2 states that, by default, attempting
- * to remove a directory is an error, so must always stat the file.
- */
- while ((f = *argv++) != NULL) {
- /* Assume if can't stat the file, can't unlink it. */
- if (lstat(f, &sb)) {
- if (errno != ENOENT) {
- warn("%s", f);
- eval = 1;
- }
- continue;
- }
-
- if (S_ISDIR(sb.st_mode)) {
- warnx("%s: is a directory", f);
- eval = 1;
- continue;
- }
- if (S_ISDIR(sb.st_mode))
- rval = rmdir(f);
- else {
- rval = unlink(f);
- }
- if (rval && (errno != ENOENT)) {
- warn("%s", f);
- eval = 1;
- }
- }
-}
-
-static int
-check(char *path, char *name, struct stat *sp)
-{
- int ch, first;
- char modep[15];
-
- /*
- * If it's not a symbolic link and it's unwritable and we're
- * talking to a terminal, ask. Symbolic links are excluded
- * because their permissions are meaningless. Check stdin_ok
- * first because we may not have stat'ed the file.
- */
- if (!stdin_ok || S_ISLNK(sp->st_mode) || !access(name, W_OK) ||
- errno != EACCES)
- return (1);
- strmode(sp->st_mode, modep);
- (void)fprintf(stderr, "override %s%s%s/%s for %s? ",
- modep + 1, modep[9] == ' ' ? "" : " ",
- user_from_uid(sp->st_uid, 0),
- group_from_gid(sp->st_gid, 0), path);
- (void)fflush(stderr);
-
- first = ch = getchar();
- while (ch != '\n' && ch != EOF)
- ch = getchar();
- return (first == 'y' || first == 'Y');
-}
-
/*
* POSIX.2 requires that if "." or ".." are specified as the basename
* portion of an operand, a diagnostic message be written to standard