int save_err = errno; __closedir (dir.stream); __set_errno (save_err);  if (data->actdir-- == 0) data->actdir = data->maxdir - 1; data->dirstreams[data->actdir] = NULL;  return -1;
result = -1; goto fail;
ftw_dir (struct ftw_data *data, struct STAT *st){  struct dir_data dir;  struct dirent64 *d;  int previous_base = data->ftw.base;  int result;  char *startp;  /* Open the stream for this directory.  This might require that     another stream has to be closed.  */  result = open_dir_stream (data, &dir);  if (result != 0)    {      if (errno == EACCES)	/* We cannot read the directory.  Signal this with a special flag.  */	result = (*data->func) (data->dirbuf, st, FTW_DNR, &data->ftw);      return result;    }  /* First, report the directory (if not depth-first).  */  if (!(data->flags & FTW_DEPTH))    {      result = (*data->func) (data->dirbuf, st, FTW_D, &data->ftw);      if (result != 0)	return result;    }  /* If necessary, change to this directory.  */  if (data->flags & FTW_CHDIR)    {      if (__fchdir (dirfd (dir.stream)) < 0)	{	  int save_err = errno;	  __closedir (dir.stream);	  __set_errno (save_err);	  if (data->actdir-- == 0)	    data->actdir = data->maxdir - 1;	  data->dirstreams[data->actdir] = NULL;	  return -1;	}    }  /* Next, update the `struct FTW' information.  */  ++data->ftw.level;  startp = strchr (data->dirbuf, '\0');  /* There always must be a directory name.  */  assert (startp != data->dirbuf);  if (startp[-1] != '/')    *startp++ = '/';  data->ftw.base = startp - data->dirbuf;  while (dir.stream != NULL && (d = __readdir64 (dir.stream)) != NULL)    {      result = process_entry (data, &dir, d->d_name, NAMLEN (d));      if (result != 0)	break;    }  if (dir.stream != NULL)    {      /* The stream is still open.  I.e., we did not need more	 descriptors.  Simply close the stream now.  */      int save_err = errno;      assert (dir.content == NULL);      __closedir (dir.stream);      __set_errno (save_err);      if (data->actdir-- == 0)	data->actdir = data->maxdir - 1;      data->dirstreams[data->actdir] = NULL;    }  else    {      int save_err;      char *runp = dir.content;      while (result == 0 && *runp != '\0')	{	  char *endp = strchr (runp, '\0');	  result = process_entry (data, &dir, runp, endp - runp);	  runp = endp + 1;	}      save_err = errno;      free (dir.content);      __set_errno (save_err);    }  /* Prepare the return, revert the `struct FTW' information.  */  data->dirbuf[data->ftw.base - 1] = '\0';  --data->ftw.level;  data->ftw.base = previous_base;  /* Finally, if we process depth-first report the directory.  */  if (result == 0 && (data->flags & FTW_DEPTH))    result = (*data->func) (data->dirbuf, st, FTW_DP, &data->ftw);  return result;}