summaryrefslogtreecommitdiff
path: root/src/mv.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2002-03-08 16:45:51 +0000
committerJim Meyering <jim@meyering.net>2002-03-08 16:45:51 +0000
commit9419e88fc4336f802bff829f49897cc8b8f567ce (patch)
tree3106885b5bface714fd31b9a7f0a952d325fdbf2 /src/mv.c
parent2c929257dc6042827f059f90ab8f7c3e6898a7b9 (diff)
downloadcoreutils-9419e88fc4336f802bff829f49897cc8b8f567ce.tar.xz
(do_move): The first time we resort to copy/remove,
call lstat `.' to get the device/inode numbers now required for rm.
Diffstat (limited to 'src/mv.c')
-rw-r--r--src/mv.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/mv.c b/src/mv.c
index a500d9f1c..b2dff121c 100644
--- a/src/mv.c
+++ b/src/mv.c
@@ -1,5 +1,5 @@
/* mv -- move or rename files
- Copyright (C) 86, 89, 90, 91, 1995-2001 Free Software Foundation, Inc.
+ Copyright (C) 86, 89, 90, 91, 1995-2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -241,6 +241,19 @@ do_move (const char *source, const char *dest, const struct cp_options *x)
struct rm_options rm_options;
struct File_spec fs;
enum RM_status status;
+ static int first_rm = 1;
+ static struct dev_ino cwd_dev_ino;
+
+ if (first_rm)
+ {
+ struct stat cwd_sb;
+ if (lstat (".", &cwd_sb))
+ error (EXIT_FAILURE, errno, _("cannot lstat `.'"));
+
+ first_rm = 0;
+ cwd_dev_ino.st_dev = cwd_sb.st_dev;
+ cwd_dev_ino.st_ino = cwd_sb.st_ino;
+ }
rm_option_init (&rm_options);
rm_options.verbose = x->verbose;
@@ -253,7 +266,7 @@ do_move (const char *source, const char *dest, const struct cp_options *x)
took the else branch of movefile. */
strip_trailing_slashes (fs.filename);
- status = rm (&fs, 1, &rm_options);
+ status = rm (&fs, 1, &rm_options, &cwd_dev_ino);
assert (VALID_STATUS (status));
if (status == RM_ERROR)
fail = 1;