summaryrefslogtreecommitdiff
path: root/src/remove.c
diff options
context:
space:
mode:
authorIngo Weinhold <ingo_weinhold@gmx.de>2008-03-21 14:10:27 +0100
committerJim Meyering <meyering@redhat.com>2008-03-21 16:01:29 +0100
commite73dfc3899c2a622c91c0948610a1c5c1e1972d1 (patch)
treefdfe2938278649d2bd6f6afa1cca1c231d9f5c19 /src/remove.c
parent18ce670a33ae31348d26da0c3737853af085e3b5 (diff)
downloadcoreutils-e73dfc3899c2a622c91c0948610a1c5c1e1972d1.tar.xz
remove.c: Accommodate systems with negative errno values.
* 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.
Diffstat (limited to 'src/remove.c')
-rw-r--r--src/remove.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/remove.c b/src/remove.c
index 1658fb990..9c6dc9ee2 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;
}