d->d_type = DT_UNKNOWN; d->d_reclen = &d->d_name[d->d_namlen + 1] - (char *) d;
DEFUN(readdir, (dirp), DIR *dirp){  if (dirp == NULL || dirp->__data == NULL)    {      errno = EINVAL;      return NULL;    }  while (1)    {      struct direct *dp;      if (dirp->__offset >= dirp->__size)	{	  /* We've emptied out our buffer.  Refill it.  */	  off_t base;	  ssize_t bytes = __getdirentries (dirp->__fd, dirp->__data,					   dirp->__allocation, &base);	  if (bytes <= 0)	    return NULL;	  dirp->__size = (size_t) bytes;	  /* Reset the offset into the buffer.  */	  dirp->__offset = 0;	}      dp = (struct direct *) &dirp->__data[dirp->__offset];      dirp->__offset += D_RECLEN (dp);      if (dp->d_ino != 0)	{	  /* Not a deleted file.  */	  register struct dirent *d = &dirp->__entry;	  register const char *p;	  d->d_fileno = (ino_t) dp->d_ino;	  /* On some systems the name length does not actually mean much.	     But we always use it as a maximum.  */	  p = memchr ((PTR) dp->d_name, '\0', D_NAMLEN (dp) + 1);	  d->d_namlen = (p != NULL) ? p - dp->d_name : D_NAMLEN (dp);	  memcpy (d->d_name, dp->d_name, d->d_namlen + 1);	  return d;	}    }}