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
This commit is contained in:
@@ -150,16 +150,19 @@ typedef struct dirstack_state Dirstack_state;
|
|||||||
|
|
||||||
/* Like fstatat, but cache the result. If ST->st_size is -1, the
|
/* 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
|
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. */
|
been gotten, so return 0. */
|
||||||
static int
|
static int
|
||||||
cache_fstatat (int fd, char const *file, struct stat *st, int flag)
|
cache_fstatat (int fd, char const *file, struct stat *st, int flag)
|
||||||
{
|
{
|
||||||
if (st->st_size == -1 && fstatat (fd, file, st, flag) != 0)
|
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)
|
if (0 <= st->st_size)
|
||||||
return 0;
|
return 0;
|
||||||
errno = -1 - st->st_size;
|
errno = (int) st->st_ino;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user