summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authordduvall <none@none>2006-09-15 16:31:24 -0700
committerdduvall <none@none>2006-09-15 16:31:24 -0700
commitff2b18550948b1149db5d915293d7c25db25bba4 (patch)
tree8a0815ec220ded48c1b58fafb8294627bc9b5cb4 /usr/src
parentface03d980f55a1b4dd2f07b212696410648b390 (diff)
downloadillumos-gate-ff2b18550948b1149db5d915293d7c25db25bba4.tar.gz
backout 6459526: fix is too aggressive; needs more work
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/rm/Makefile8
-rw-r--r--usr/src/cmd/rm/rm.c28
2 files changed, 8 insertions, 28 deletions
diff --git a/usr/src/cmd/rm/Makefile b/usr/src/cmd/rm/Makefile
index 5bceb7cbbe..d1346e02d4 100644
--- a/usr/src/cmd/rm/Makefile
+++ b/usr/src/cmd/rm/Makefile
@@ -2,8 +2,9 @@
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
+# Common Development and Distribution License, Version 1.0 only
+# (the "License"). You may not use this file except in compliance
+# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
@@ -21,7 +22,7 @@
#
#ident "%Z%%M% %I% %E% SMI"
#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
@@ -33,7 +34,6 @@ include ../Makefile.cmd
CFLAGS += $(CCVERBOSE)
$(XPG4) := CFLAGS += -DXPG4
CPPFLAGS += -D_FILE_OFFSET_BITS=64
-LDLIBS += -lcmdutils
.KEEP_STATE:
diff --git a/usr/src/cmd/rm/rm.c b/usr/src/cmd/rm/rm.c
index 7824a9156c..bbdbadf588 100644
--- a/usr/src/cmd/rm/rm.c
+++ b/usr/src/cmd/rm/rm.c
@@ -46,8 +46,6 @@
#include <stdlib.h>
#include <errno.h>
#include <sys/resource.h>
-#include <sys/avl.h>
-#include <libcmdutils.h>
#define ARGCNT 5 /* Number of arguments */
#define CHILD 0
@@ -89,7 +87,6 @@ static rlim_t maxfiles; /* maximum number of open files */
static int first_dir = 1; /* flag set when first trying to remove a dir */
/* flag set when can't get dev/inode of a parent dir */
static int parent_err = 0;
-static avl_tree_t *tree; /* tree to keep track of nodes visited */
struct dir_id {
dev_t dev;
@@ -171,10 +168,10 @@ main(int argc, char *argv[])
maxfiles = rl.rlim_cur - 2;
while (argc-- > 0) {
- tree = NULL;
rm(*argv, 1);
argv++;
}
+
cleanup();
return (errcode ? 2 : 0);
/* NOTREACHED */
@@ -187,7 +184,6 @@ rm(char *path, int first)
char *filepath;
char *p;
char resolved_path[PATH_MAX];
- int ret;
/*
* Check file to see if it exists.
@@ -200,24 +196,6 @@ rm(char *path, int first)
return;
}
- /*
- * Add this node to the search tree so we don't
- * get into a endless loop. If the add fails then
- * we have visited this node before.
- */
- ret = add_tnode(&tree, buffer.st_dev, buffer.st_ino);
- if (ret != 1) {
- if (ret == 0) {
- filepath = get_filename(path);
- (void) fprintf(stderr,
- gettext("rm: cycle detected for %s\n"), filepath);
- } else if (ret == -1) {
- perror("rm");
- }
- errcode++;
- return;
- }
-
/* prevent removal of / but allow removal of sym-links */
if (!S_ISLNK(buffer.st_mode) && realpath(path, resolved_path) != NULL &&
strcmp(resolved_path, "/") == 0) {
@@ -261,6 +239,7 @@ rm(char *path, int first)
undir(path, first, buffer.st_dev, buffer.st_ino);
return;
}
+
filepath = get_filename(path);
/*
@@ -739,6 +718,7 @@ static void
pop_name(int first)
{
char *slash;
+
if (first) {
*fullpath = '\0';
return;
@@ -961,6 +941,7 @@ check_homedir(void)
static void
cleanup(void) {
+
struct dir_id *lastdir, *curdir;
curdir = homedir.next;
@@ -970,5 +951,4 @@ cleanup(void) {
curdir = curdir->next;
free(lastdir);
}
- destroy_tree(tree);
}