summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-11-09 20:53:21 +0000
committerJim Meyering <jim@meyering.net>2003-11-09 20:53:21 +0000
commitc3a7cbe2253751e14af2c19ca04332f6cb7e0640 (patch)
treec6eabd2989ad5268055a9f05d44d04c617116b31 /src
parente172def2ecf330d8933fa6135b256a4257d295ec (diff)
downloadcoreutils-c3a7cbe2253751e14af2c19ca04332f6cb7e0640.tar.xz
Include "root-dev-ino.h".
(process_file): Use newly-factored-out ROOT_DEV_INO_CHECK and ROOT_DEV_INO_WARN macros. (get_root_dev_ino): Remove function definition, now that it's been moved to a separate file.
Diffstat (limited to 'src')
-rw-r--r--src/chmod.c31
1 files changed, 5 insertions, 26 deletions
diff --git a/src/chmod.c b/src/chmod.c
index 0a71d04b7..6493343b1 100644
--- a/src/chmod.c
+++ b/src/chmod.c
@@ -29,6 +29,7 @@
#include "filemode.h"
#include "modechange.h"
#include "quote.h"
+#include "root-dev-ino.h"
#include "savedir.h"
#include "xfts.h"
@@ -87,10 +88,10 @@ enum
static struct option const long_options[] =
{
- {"recursive", no_argument, 0, 'R'},
{"changes", no_argument, 0, 'c'},
- {"preserve-root", no_argument, 0, PRESERVE_ROOT},
+ {"recursive", no_argument, 0, 'R'},
{"no-preserve-root", no_argument, 0, NO_PRESERVE_ROOT},
+ {"preserve-root", no_argument, 0, PRESERVE_ROOT},
{"quiet", no_argument, 0, 'f'},
{"reference", required_argument, 0, REFERENCE_FILE_OPTION},
{"silent", no_argument, 0, 'f'},
@@ -167,7 +168,6 @@ process_file (FTS *fts, FTSENT *ent, const struct mode_change *changes)
return 1;
case FTS_ERR:
- /* if (S_ISDIR (ent->fts_statp->st_mode) && FIXME */
error (0, ent->fts_errno, _("%s"), quote (file_full_name));
return 1;
@@ -185,16 +185,9 @@ process_file (FTS *fts, FTSENT *ent, const struct mode_change *changes)
if (ent->fts_info == FTS_DP)
return 0;
- if (root_dev_ino && SAME_INODE (*sb, *root_dev_ino))
+ if (ROOT_DEV_INO_CHECK (root_dev_ino, sb))
{
- if (STREQ (file_full_name, "/"))
- error (0, 0, _("it is dangerous to operate recursively on %s"),
- quote (file_full_name));
- else
- error (0, 0,
- _("it is dangerous to operate recursively on %s (same as %s)"),
- quote_n (0, file_full_name), quote_n (1, "/"));
- error (0, 0, _("use --no-preserve-root to override this failsafe"));
+ ROOT_DEV_INO_WARN (file_full_name);
return 1;
}
@@ -303,20 +296,6 @@ one or more of the letters rwxXstugo.\n\
exit (status);
}
-/* Call lstat to get the device and inode numbers for `/'.
- Upon failure, return NULL. Otherwise, set the members of
- *ROOT_D_I accordingly and return ROOT_D_I. */
-static struct dev_ino *
-get_root_dev_ino (struct dev_ino *root_d_i)
-{
- struct stat statbuf;
- if (lstat ("/", &statbuf))
- return NULL;
- root_d_i->st_ino = statbuf.st_ino;
- root_d_i->st_dev = statbuf.st_dev;
- return root_d_i;
-}
-
/* Parse the ASCII mode given on the command line into a linked list
of `struct mode_change' and apply that to each file argument. */