]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
remove.c: Accommodate systems with negative errno values.
authorIngo Weinhold <ingo_weinhold@gmx.de>
Fri, 21 Mar 2008 13:10:27 +0000 (14:10 +0100)
committerJim Meyering <meyering@redhat.com>
Fri, 21 Mar 2008 15:01:29 +0000 (16:01 +0100)
* src/remove.c (cache_fstatat): Store errno value directly in
the st_ino field, rather than trying to shoehorn it into st_size.
This is required at least on BeOS and Haiku.

src/remove.c

index 1658fb9900b6c95508d8ad28e10e19e4f73b1f43..9c6dc9ee2532e69c94a14a89d9c4524966f8a571 100644 (file)
@@ -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;
 }