[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: rm: avoiding a race condition on non-glibc systems
From: |
Eric Blake |
Subject: |
Re: rm: avoiding a race condition on non-glibc systems |
Date: |
Mon, 16 May 2005 07:22:46 -0600 |
User-agent: |
Mozilla Thunderbird 1.0.2 (Windows/20050317) |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Paul Eggert on 5/13/2005 4:55 PM:
> 2005-05-13 Paul Eggert <address@hidden>
>
> * m4/prereqs.m4 (gl_PREREQ): Require gl_UNLINKDIR.
> * src/remove.c: Include unlinkdir.h.
> (UNLINK_CAN_UNLINK_DIRS): Remove.
> (remove_entry): Use cannot_unlink_dirs () rather than
> UNLINK_CAN_UNLINK_DIRS.
> * lib/unlinkdir.c, lib/unlinkdir.h: New files.
> * m4/unlinkdir.m4: New file.
> + /* If we happen to know that FILENAME is a directory, return now
> + and let the caller remove it -- this saves the overhead of a failed
> + unlink call. If FILENAME is a command-line argument, then dp is NULL,
> + so we'll first try to unlink it. Using unlink here is ok, because it
> + cannot remove a directory. */
> + if ((dp && DT_IS_DIR (dp)) || is_dir == T_YES)
> + return RM_NONEMPTY_DIR;
> +
This change broke cygwin. Cygwin does not have struct dirent.d_type, so
DT_IS_DIR is defined as do_not_use_this_macro. I think protecting this if
statement with HAVE_STRUCT_DIRENT_D_TYPE, and letting cygwin fall through
to the unlink, will fix the problem.
2005-05-16 Eric Blake <address@hidden>
* src/remove.c (remove_entry) [! HAVE_STRUCT_DIRENT_D_TYPE]: Fix
breakage on Cygwin when checking for directory.
Index: src/remove.c
===================================================================
RCS file: /cvsroot/coreutils/coreutils/src/remove.c,v
retrieving revision 1.125
diff -u -p -r1.125 remove.c
- --- src/remove.c 14 May 2005 08:05:35 -0000 1.125
+++ src/remove.c 16 May 2005 13:21:05 -0000
@@ -755,7 +755,11 @@ remove_entry (Dirstack_state const *ds,
unlink call. If FILENAME is a command-line argument, then dp is
NULL,
so we'll first try to unlink it. Using unlink here is ok, because it
cannot remove a directory. */
- - if ((dp && DT_IS_DIR (dp)) || is_dir == T_YES)
+ if (is_dir == T_YES
+#if HAVE_STRUCT_DIRENT_D_TYPE
+ || (dp && DT_IS_DIR (dp))
+#endif
+ )
return RM_NONEMPTY_DIR;
DO_UNLINK (filename, x);
- --
Life is short - so eat dessert first!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFCiJ6m84KuGfSFAYARAoaSAJ9PwT7Nqgda/rvCCdC2BXCPMqqldACfTtL6
pkcs5bvT1FNKdT34REcWmLg=
=EnkT
-----END PGP SIGNATURE-----