bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

rm -r fails on some systems


From: Michael van Elst
Subject: rm -r fails on some systems
Date: Tue, 21 Jan 2003 17:34:24 +0100
User-agent: Mutt/1.4i

Dear Bug-Searches,

the rm tool in GNU core utils 4.5.4 may fail to recursively remove directories
on systems that support DIRENT_D_TYPE.

On such systems the d_type may be set to DT_UNKNOWN for filesystems that
do not support directory entry types and which require an explicit call
to lstat(). In particular this happens on FreeBSD for NFS mounted volumes.

In this case rm fails to see subdirectories it should traverse and tries
to unlink() them.

The following patch fixes the problem:

--- src/remove.c.dist   2003-01-17 15:33:54.000000000 +0100
+++ src/remove.c        2003-01-17 15:37:08.000000000 +0100
@@ -632,9 +632,11 @@
 
 #if HAVE_STRUCT_DIRENT_D_TYPE
 # define DT_IS_DIR(D) ((D)->d_type == DT_DIR)
+# define DT_IS_DEF(D) ((D)->d_type != DT_UNKNOWN)
 #else
 /* Use this only if the member exists -- i.e., don't return 0.  */
 # define DT_IS_DIR(D) do_not_use_this_macro
+# define DT_IS_DEF(D) do_not_use_this_macro
 #endif
 
 #define DO_UNLINK(Filename, X)                                         \
@@ -704,7 +706,7 @@
   if (is_dir == T_UNKNOWN)
     {
 # if HAVE_STRUCT_DIRENT_D_TYPE
-      if (dp)
+      if (dp && DT_IS_DEF (dp))
        is_dir = DT_IS_DIR (dp) ? T_YES : T_NO;
       else
 # endif

Greetings,
-- 
                                       Michael van Elst
                                       address@hidden






reply via email to

[Prev in Thread] Current Thread [Next in Thread]