From 70698e5bc7fa5bb7862b8adaecea37b0a9778440 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 9 Nov 2003 21:06:16 +0000 Subject: [PATCH] Include "root-dev-ino.h". (remove_cwd_entries): Remove now-obsolete FIXME comment. (remove_dir): Support rm's new --preserve-root option. --- src/remove.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/remove.c b/src/remove.c index 0e0a970f2e..06071677af 100644 --- a/src/remove.c +++ b/src/remove.c @@ -35,6 +35,7 @@ #include "obstack.h" #include "quote.h" #include "remove.h" +#include "root-dev-ino.h" /* Avoid shadowing warnings because these are functions declared in dirname.h as well as locals used below. */ @@ -889,10 +890,6 @@ remove_cwd_entries (Dirstack_state *ds, char **subdir, struct stat *subdir_sb, error (EXIT_FAILURE, errno, _("cannot lstat %s"), quote (full_filename (f))); - /* FIXME: here (if F is a command line argument) is at least one - place in which we'll have to compare the dev/ino against those - of `/', in implementing fail-to-remove-root-dir semantics. */ - if (chdir (f)) { /* It is much more common that we reach this point for an @@ -1020,6 +1017,12 @@ remove_dir (Dirstack_state *ds, char const *dir, struct saved_cwd **cwd_state, return RM_ERROR; } + if (ROOT_DEV_INO_CHECK (x->root_dev_ino, &dir_sb)) + { + ROOT_DEV_INO_WARN (full_filename (dir)); + return 1; + } + AD_push (ds, dir, &dir_sb); AD_INIT_OTHER_MEMBERS (); -- 2.47.2