Fix readdir() setting errno on success.

This commit is contained in:
Jonas 'Sortie' Termansen 2014-08-26 23:12:18 +02:00
parent ecccf4e1f7
commit 783c1092ff
1 changed files with 2 additions and 0 deletions

View File

@ -54,10 +54,12 @@ static int fddir_sortix_readents(fddir_sortix_t* info)
return -1;
}
int saved_errno = errno;
if ( readdirents(info->fd, info->dirent, info->direntsize) < 0 )
{
if ( errno != ERANGE )
return -1;
errno = saved_errno;
size_t newdirentsize = sizeof(struct kernel_dirent) + info->dirent->d_namlen + 1;
if ( newdirentsize < info->direntsize )
newdirentsize *= 2;