Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
For bugs related to Red Hat Enterprise Linux 5 product line. The current stable release is 5.10. For Red Hat Enterprise Linux 6 and above, please visit Red Hat JIRA https://issues.redhat.com/secure/CreateIssue!default.jspa?pid=12332745 to report new issues.

Bug 664895

Summary: rmdir --ignore-fail-on-non-empty fails on vxfs filesytem
Product: Red Hat Enterprise Linux 5 Reporter: Lachlan McIlroy <lmcilroy>
Component: coreutilsAssignee: Ondrej Vasik <ovasik>
Status: CLOSED ERRATA QA Contact: qe-baseos-daemons
Severity: medium Docs Contact:
Priority: high    
Version: 5.5CC: asersen, azelinka, meyering, prc, vgaikwad
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: coreutils-5.97-28.el5 Doc Type: Bug Fix
Doc Text:
On certain filesystems such as VxFS, the Veritas File System, the rmdir() system call returned the wrong error code for non-empty directories. This caused the rmdir utility to fail to ignore the error when the "--ignore-fail-on-non-empty" command line option was specified. This bug has been fixed and the rmdir utility now handles errors on non-empty directories on VxFS partitions properly.
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-07-21 10:33:37 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
test coreutils RPM (not for production use)
none
test coreutils source RPM none

Description Lachlan McIlroy 2010-12-22 02:18:16 UTC
Description of problem:

rmdir accepts a command line argument (--ignore-fail-on-non-empty) to silently ignore directories that are not empty.  rmdir expects the rmdir() system call to return ENOTEMPTY in this case but vxfs returns EEXIST and rmdir fails to ignore the error.

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

How reproducible:
Always.

Steps to Reproduce:

On an ext3 filesystem:
# mkdir dir
# touch dir/file
# rmdir --ignore-fail-on-non-empty dir
# echo $?
0

On an vxfs filesystem:
# mkdir dir
# touch dir/file
# rmdir --ignore-fail-on-non-empty dir
rmdir: dir: File exists
# echo $?
1
  
strace shows that vxfs is returning EEXIST from rmdir() while the rmdir utility expects ENOTEMPTY.

On ext3:
rmdir("a")               = -1 ENOTEMPTY (Directory not empty)

On vxfs:
rmdir("test")            = -1 EEXIST (File exists)

The man page for rmdir() states that EEXIST is a posix compliant substitute:

       ENOTEMPTY
              pathname contains entries other than . and .. ; or, pathname has ..  as its final component.  POSIX.1-2001 also allows EEXIST for this condition.

This patch will fix it:

http://osdir.com/ml/bug-coreutils-gnu/2009-09/msg00265.html

This fix exists in coreutils-8.0.

Comment 2 John Brier 2010-12-23 23:14:23 UTC
Created attachment 470476 [details]
test coreutils RPM (not for production use)

Comment 3 John Brier 2010-12-23 23:17:42 UTC
Created attachment 470477 [details]
test coreutils source RPM

This source RPM includes a one line patch based on the patch Lachlan found.


[root@localhost coreutils-5.97]# cat coreutils-664895-rmdir-errno-cleanup.patch 
--- /dev/null			2010-12-23 16:17:50.000000000 -0500
+++ coreutils-5.97/src/rmdir.c	2010-12-23 16:19:01.000000000 -0500
@@ -78,7 +78,7 @@
 static bool
 errno_rmdir_non_empty (int error_number)
 {
-  return (error_number == RMDIR_ERRNO_NOT_EMPTY);
+  return error_number == ENOTEMPTY || error_number == EEXIST;
 }
 
 /* Remove any empty parent directories of DIR.




I had to hack the release section of the spec file

this diidn't work for me:

Release: 23%{?dist}.2.BZ664895

I had to manually change it to 

Release: 23.el5_4.2.BZ664895


not sure why

Comment 9 Tomas Capek 2011-07-13 12:10:14 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:
On certain filesystems such as VxFS, the Veritas File System, the rmdir() system call returned the wrong error code for non-empty directories. This caused the rmdir utility to fail to ignore the error when the "--ignore-fail-on-non-empty" command line option was specified. This bug has been fixed and the rmdir utility now handles errors on non-empty directories on VxFS  partitions properly.

Comment 10 errata-xmlrpc 2011-07-21 10:33:37 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 11 errata-xmlrpc 2011-07-21 12:18:43 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