From b4c0ce288eab4961be77ad1654fe74e6429d3e9b Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Fri, 21 Mar 2008 12:16:22 +0000 Subject: [PATCH] Wrong assumption that errno values are positive. Could cause "rm -f" to fail for non-existent entries. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24499 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/bin/coreutils/src/remove.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/bin/coreutils/src/remove.c b/src/bin/coreutils/src/remove.c index b059d0eb62..1153d8cf85 100644 --- a/src/bin/coreutils/src/remove.c +++ b/src/bin/coreutils/src/remove.c @@ -150,16 +150,19 @@ typedef struct dirstack_state Dirstack_state; /* 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; }