Howdy,

on systems with negative errno values (BeOS, Haiku) the method used in the 
cache_fstatat() function in src/remove.c is broken (st_size will become 
positive on error). The attached patch changes the function to use the 
st_ino field to store the errno value instead, which should work on all 
platforms.

CU, Ingo
diff --git a/src/remove.c b/src/remove.c
index 1658fb9..dc84508 100644
--- a/src/remove.c
+++ b/src/remove.c
@@ -171,16 +171,19 @@ static size_t g_n_allocated;
 
 /* Like fstatat, but cache the result.  If ST->st_size is -1, the
    status has not been gotten yet.  If less than -1, fstatat failed
-   with errno == -1 - ST->st_size.  Otherwise, the status has already
+   with errno == ST->st_ino.  Otherwise, the status has already
    been gotten, so return 0.  */
 static int
 cache_fstatat (int fd, char const *file, struct stat *st, int flag)
 {
   if (st->st_size == -1 && fstatat (fd, file, st, flag) != 0)
-    st->st_size = -1 - errno;
+    {
+      st->st_size = -2;
+      st->st_ino = errno;
+       }
   if (0 <= st->st_size)
     return 0;
-  errno = -1 - st->st_size;
+  errno = (int) st->st_ino;
   return -1;
 }
 
_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to