+2008-03-30 Ulrich Drepper <drepper@redhat.com>
+
+ * sysdeps/unix/opendir.c (__alloc_dir): If allocation fails for size
+ provided through st_blksize, try the default size before giving up.
+
2008-03-29 Ulrich Drepper <drepper@redhat.com>
* stdio-common/vfprintf.c (vfprintf): Correct overflow test.
goto lose;
}
+ const size_t default_allocation = (BUFSIZ < sizeof (struct dirent64)
+ ? sizeof (struct dirent64) : BUFSIZ);
size_t allocation;
#ifdef _STATBUF_ST_BLKSIZE
if (__builtin_expect ((size_t) statp->st_blksize >= sizeof (struct dirent64),
allocation = statp->st_blksize;
else
#endif
- allocation = (BUFSIZ < sizeof (struct dirent64)
- ? sizeof (struct dirent64) : BUFSIZ);
+ allocation = default_allocation;
DIR *dirp = (DIR *) malloc (sizeof (DIR) + allocation);
if (dirp == NULL)
- lose:
{
- if (close_fd)
+#ifdef _STATBUF_ST_BLKSIZE
+ if (allocation == statp->st_blksize
+ && allocation != default_allocation)
{
- int save_errno = errno;
- close_not_cancel_no_status (fd);
- __set_errno (save_errno);
+ allocation = default_allocation;
+ dirp = (DIR *) malloc (sizeof (DIR) + allocation);
+ }
+ if (dirp == NULL)
+#endif
+ lose:
+ {
+ if (close_fd)
+ {
+ int save_errno = errno;
+ close_not_cancel_no_status (fd);
+ __set_errno (save_errno);
+ }
+ return NULL;
}
- return NULL;
}
dirp->fd = fd;