Bug 658839

Summary: mv: confusing 'subdirectory of itself' error message
Product: Red Hat Enterprise Linux 5 Reporter: Boris Ranto <branto>
Component: coreutilsAssignee: Ondrej Vasik <ovasik>
Status: CLOSED ERRATA QA Contact: qe-baseos-daemons
Severity: medium Docs Contact:
Priority: low    
Version: 5.7CC: asersen, meyering, prc
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: coreutils-5.97-28.el5 Doc Type: Bug Fix
Doc Text:
When moving a directory into another non-empty directory, the mv utility returned a confusing "cannot move [directory] to a subdirectory of itself" error message. This bug has been fixed and the correct "Directory not empty" error message is now given instead.
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-07-21 10:36:59 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Patch for the issue none

Description Boris Ranto 2010-12-01 12:57:08 UTC
Created attachment 463974 [details]
Patch for the issue

Description of problem:
If directory is moved to another existing directory that is not empty, rename sets errno to ENOTEMPTY. Coreutils in rhel5 considers this to be a case when directory is moved to a subdirectory of itself although it clearly is not the case.
Therefore I propose attached patch that fixed this confussion for me.

Version-Release number of selected component (if applicable):
coreutils-5.97-23.el5_4.2

How reproducible:
Always

Steps to Reproduce:
1. mkdir a{a,b}
2. touch aa/1
3. mkdir ab/aa
4. touch ab/aa/2
5. mv ab/aa ./
  
Actual results:
mv: cannot move `ab/aa' to a subdirectory of itself, `./aa'

Expected results:
mv: cannot move `ab/aa' to `./aa': Directory not empty

Additional info:
RHEL6 already has this behaviour.
This bug was found thanks to xfstests test no. 245.

Example without patch(/bin/mv) and with patch(/usr/bin/mv):
[root@dell-pesc1420-01 test]# mkdir a{a,b}
[root@dell-pesc1420-01 test]# touch aa/1
[root@dell-pesc1420-01 test]# mkdir ab/aa
[root@dell-pesc1420-01 test]# touch ab/aa/2
[root@dell-pesc1420-01 test]# /bin/mv ab/aa ./
/bin/mv: cannot move `ab/aa' to a subdirectory of itself, `./aa'
[root@dell-pesc1420-01 test]# /usr/bin/mv ab/aa ./
/usr/bin/mv: cannot move `ab/aa' to `./aa': Directory not empty
[root@dell-pesc1420-01 test]# 

Patch does not brake the case when directory is moved to its subdirectory:
[root@dell-pesc1420-01 test]# mv ab ab/aa
mv: cannot move `ab' to a subdirectory of itself, `ab/aa/ab'
[root@dell-pesc1420-01 test]# /usr/bin/mv ab ab/aa
/usr/bin/mv: cannot move `ab' to a subdirectory of itself, `ab/aa/ab'
[root@dell-pesc1420-01 test]#

Comment 1 Ondrej Vasik 2010-12-01 13:21:25 UTC
Thanks for patch, even EIO check could be dropped... upstream commit is here: http://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=36a288e41a6534c816090dce1a6ed139a60e87b7

Comment 2 RHEL Program Management 2011-01-11 20:14:18 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated in the
current release, Red Hat is unfortunately unable to address this
request at this time. Red Hat invites you to ask your support
representative to propose this request, if appropriate and relevant,
in the next release of Red Hat Enterprise Linux.

Comment 3 RHEL Program Management 2011-01-11 22:23:50 UTC
This request was erroneously denied for the current release of
Red Hat Enterprise Linux.  The error has been fixed and this
request has been re-proposed for the current release.

Comment 7 Tomas Capek 2011-07-13 12:15:09 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
When moving a directory into another non-empty directory, the mv utility returned a confusing "cannot move [directory] to a subdirectory of itself" error message. This bug has been fixed and the correct "Directory not empty" error message is now given instead.

Comment 8 errata-xmlrpc 2011-07-21 10:36:59 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-1074.html

Comment 9 errata-xmlrpc 2011-07-21 12:18:39 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-1074.html