Debian Bug report logs - #376749
coreutils: Incorrect error message in mv (due to incorrect behavior)

version graph

Package: coreutils; Maintainer for coreutils is Michael Stone <mstone@debian.org>; Source for coreutils is src:coreutils.

Reported by: Florent Bayle <florent@sarcelle.net>

Date: Tue, 4 Jul 2006 18:33:02 UTC

Severity: normal

Found in versions coreutils/5.96-5, coreutils/5.97-5.4

Fixed in version 6.10-1

Done: Michael Stone <mstone@debian.org>

Bug is archived. No further changes may be made.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, Michael Stone <mstone@debian.org>:
Bug#376749; Package coreutils. Full text and rfc822 format available.

Acknowledgement sent to Florent Bayle <florent@sarcelle.net>:
New Bug report received and forwarded. Copy sent to Michael Stone <mstone@debian.org>. Full text and rfc822 format available.

Message #5 received at submit@bugs.debian.org (full text, mbox):

From: Florent Bayle <florent@sarcelle.net>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: coreutils: Incorrect error message in mv (due to incorrect behavior)
Date: Tue, 04 Jul 2006 20:06:30 +0200
Package: coreutils
Version: 5.96-5
Severity: normal

Hi,

To be brief :
root@jupiter:/tmp# mkdir -p test1/test test2/test; touch test1/test/file; mv test2/* test1/
mv: cannot move `test2/test' to a subdirectory of itself, `test1/test'
root@jupiter:/tmp#

It seems to be an incorrect error message, but I think that this bug is
related to #376743 because with version 5.94-1 of coreutils, I have this
output :
root@jupiter:/tmp# mkdir -p test1/test test2/test; touch test1/test/file; mv test2/* test1/
mv: cannot overwrite directory `test1/test'
root@jupiter:/tmp#


Regards.

-- 
Florent

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/dash
Kernel: Linux 2.6.17-1-686
Locale: LANG=fr_FR@euro, LC_CTYPE=fr_FR@euro (charmap=ISO-8859-15)

Versions of packages coreutils depends on:
ii  libacl1                       2.2.39-1   Access control list shared library
ii  libc6                         2.3.6-15   GNU C Library: Shared libraries
ii  libselinux1                   1.30-1     SELinux shared libraries

coreutils recommends no packages.

-- no debconf information



Information forwarded to debian-bugs-dist@lists.debian.org, Michael Stone <mstone@debian.org>:
Bug#376749; Package coreutils. Full text and rfc822 format available.

Acknowledgement sent to Jim Meyering <jim@meyering.net>:
Extra info received and forwarded to list. Copy sent to Michael Stone <mstone@debian.org>. Full text and rfc822 format available.

Message #10 received at 376749@bugs.debian.org (full text, mbox):

From: Jim Meyering <jim@meyering.net>
To: Florent Bayle <florent@sarcelle.net>
Cc: 376749@bugs.debian.org, bug-coreutils@gnu.org
Subject: Re: Bug#376749: coreutils: Incorrect error message in mv (due to incorrect behavior)
Date: Wed, 05 Jul 2006 11:51:19 +0200
Florent Bayle <florent@sarcelle.net> wrote:
> Package: coreutils
> Version: 5.96-5
> Severity: normal
>
> To be brief :
> root@jupiter:/tmp# mkdir -p test1/test test2/test; touch test1/test/file; mv test2/* test1/
> mv: cannot move `test2/test' to a subdirectory of itself, `test1/test'
> root@jupiter:/tmp#
>
> It seems to be an incorrect error message, but I think that this bug is
> related to #376743 because with version 5.94-1 of coreutils, I have this
> output :
> root@jupiter:/tmp# mkdir -p test1/test test2/test; touch test1/test/file; mv test2/* test1/
> mv: cannot overwrite directory `test1/test'
> root@jupiter:/tmp#

Thank you for reporting that.
Note that this is file-system dependent for me.
On tmpfs, reiserfs, and ext3, my results match yours:

    $ rm -rf a b; mkdir -p a/t b/t; touch a/t/f; mv b/t a
    /cu/src/mv: cannot move `b/t' to a subdirectory of itself, `a/t'

But on xfs, I get this:

    $ rm -rf a b; mkdir -p a/t b/t; touch a/t/f; mv b/t a
    ./mv: cannot move `b/t' to `a/t': File exists

Here's where the strace output diverged:

    $ diff -u /t/strace-xfs /t/strace-tmpfs|grep rename
    -rename("b/t", "a/t")                    = -1 EEXIST (File exists)
    +rename("b/t", "a/t")                    = -1 ENOTEMPTY (Directory not empty)

This is due in part to the following change, since before then, the code
in question never had to deal with an existing destination directory.

    2006-05-11  Jim Meyering  <jim@meyering.net>

            mv -T DIR EMPTY_DIR no longer fails unconditionally
            * src/copy.c (copy_internal): Don't manually prohibit a move where
            the destination is an existing directory.  Sometimes doing that is
            valid.  Let the rename system call enforce the rules.  That is
            allowed only when the source is a directory and the destination
            directory (to be replaced) is empty.  Reported by Eric Blake.
            * tests/mv/no-target-dir: New file/test for this.
            * tests/mv/Makefile.am (TESTS): Add no-target-dir.
            * NEWS: Mention this.

Since today's problem is due to work-around code whose sole
purpose is to accommodate buggy rename support in old systems,
I'm fixing it by removing the questionable work-around code.
I've included the patch for the trunk below.
Will probably do the same on the branch.

Note that I'm also removing the EIO-handling code.
If anyone cares about SunOS-4.1.4 or Irix 5.3 and still has access
to such a system, please try the following commands in an NFS-mounted
directory, and let me know if you get different results:

    $ rm -rf a; mkdir a; perl -e 'rename "a","a/x" or die "$!\n"'
    Invalid argument

2006-07-05  Jim Meyering  <jim@meyering.net>

	* src/copy.c (copy_internal): Don't work around old NFS clients like
	SunOS-4.1.4 and Irix 5.3 that set errno to values like EIO and
	ENOTEMPTY upon failed rename.  Otherwise, we risk misinterpreting
	a banal failure as a recursive move-into-self failure.
	Reported by Florent Bayle in <http://bugs.debian.org/376749>.

Index: src/copy.c
===================================================================
RCS file: /fetish/cu/src/copy.c,v
retrieving revision 1.200
diff -u -p -r1.200 copy.c
--- src/copy.c	3 Jun 2006 09:04:22 -0000	1.200
+++ src/copy.c	5 Jul 2006 08:38:52 -0000
@@ -1385,18 +1385,7 @@ copy_internal (char const *src_name, cha
 
       /* This happens when attempting to rename a directory to a
 	 subdirectory of itself.  */
-      if (errno == EINVAL
-
-	  /* When src_name is on an NFS file system, some types of
-	     clients, e.g., SunOS4.1.4 and IRIX-5.3, set errno to EIO
-	     instead.  Testing for this here risks misinterpreting a real
-	     I/O error as an attempt to move a directory into itself, so
-	     FIXME: consider not doing this.  */
-	  || errno == EIO
-
-	  /* And with SunOS-4.1.4 client and OpenBSD-2.3 server,
-	     we get ENOTEMPTY.  */
-	  || errno == ENOTEMPTY)
+      if (errno == EINVAL)
 	{
 	  /* FIXME: this is a little fragile in that it relies on rename(2)
 	     failing with a specific errno value.  Expect problems on



Bug marked as found in version 5.97-5.4. Request was from dwitch@nan92-1-81-57-214-146.fbx.proxad.net (Yann Dirson) to control@bugs.debian.org. (Sat, 10 Nov 2007 15:03:25 GMT) Full text and rfc822 format available.

Reply sent to Michael Stone <mstone@debian.org>:
You have taken responsibility. Full text and rfc822 format available.

Notification sent to Florent Bayle <florent@sarcelle.net>:
Bug acknowledged by developer. Full text and rfc822 format available.

Message #17 received at 376749-done@bugs.debian.org (full text, mbox):

From: Michael Stone <mstone@debian.org>
To: 376749-done@bugs.debian.org
Subject: Re: coreutils: Incorrect error message in mv (due to incorrect behavior)
Date: Mon, 28 Jan 2008 20:38:52 -0500
Version: 6.10-1

Current version displays error message: "Directory not empty", which 
hopefully is more clear.




Bug archived. Request was from Debbugs Internal Request <owner@bugs.debian.org> to internal_control@bugs.debian.org. (Tue, 24 Feb 2009 07:34:30 GMT) Full text and rfc822 format available.

Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Thu Apr 17 22:01:09 2014; Machine Name: buxtehude.debian.org

Debian Bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.