rem: remove_entry's DO_UNLINK) of a non-directory failed due to EPERM.  */
add: remove_entry's DO_UNLINK) of a non-directory failed.  */
context: remove_cwd_entries (Dirstack_state *ds, char **subdir, struct stat *subdir_sb,		    struct rm_options const *x){  DIR *dirp = opendir (".");  struct AD_ent *top = AD_stack_top (ds);  enum RM_status status = top->status;  assert (VALID_STATUS (status));  *subdir = NULL;  if (dirp == NULL)    {      if (errno != ENOENT || !x->ignore_missing_files)	{	  error (0, errno, _("cannot open directory %s"),		 quote (full_filename (".")));	  return RM_ERROR;	}    }  while (1)    {      struct dirent *dp;      enum RM_status tmp_status;      const char *f;      /* Set errno to zero so we can distinguish between a readdir failure	 and when readdir simply finds that there are no more entries.  */      errno = 0;      if ((dp = readdir (dirp)) == NULL)	{	  if (errno)	    {	      /* Save/restore errno across closedir call.  */	      int e = errno;	      closedir (dirp);	      errno = e;	      /* Arrange to give a diagnostic after exiting this loop.  */	      dirp = NULL;	    }	  break;	}      f = dp->d_name;      if (DOT_OR_DOTDOT (f))	continue;      /* Skip files we've already tried/failed to remove.  */      if ( ! AD_is_removable (ds, f))	continue;      /* Pass dp->d_type info to remove_entry so the non-glibc	 case can decide whether to use unlink or chdir.	 Systems without the d_type member will have to endure	 the performance hit of first calling lstat F. */      tmp_status = remove_entry (ds, f, x, dp);      switch (tmp_status)	{	case RM_OK:	  /* do nothing */	  break;	case RM_ERROR:	case RM_USER_DECLINED:	  AD_mark_as_unremovable (ds, f);	  UPDATE_STATUS (status, tmp_status);	  break;	case RM_NONEMPTY_DIR:	  {	    /* Save a copy of errno, in case the preceding unlink (from	       remove_entry's DO_UNLINK) of a non-directory failed due	       to EPERM.  */	    int saved_errno = errno;	    /* Record dev/ino of F so that we can compare	       that with dev/ino of `.' after the chdir.	       This dev/ino pair is also used in cycle detection.  */	    if (lstat (f, subdir_sb))	      error (EXIT_FAILURE, errno, _("cannot lstat %s"),		     quote (full_filename (f)));	    if (chdir (f))	      {		/* It is much more common that we reach this point for an		   inaccessible directory.  Hence the second diagnostic, below.		   However it is also possible that F is a non-directory.		   That can happen when we use the `! ROOT_CAN_UNLINK_DIRS'		   block of code and when DO_UNLINK fails due to EPERM.		   In that case, give a better diagnostic.  */		if (errno == ENOTDIR)		  error (0, saved_errno, _("cannot remove %s"),			 quote (full_filename (f)));		else		  error (0, errno, _("cannot chdir from %s to %s"),			 quote_n (0, full_filename (".")), quote_n (1, f));		AD_mark_as_unremovable (ds, f);		status = RM_ERROR;		break;	      }	    if (cycle_check (&ds->cycle_check_state, subdir_sb))	      {		error (0, 0, _("\WARNING: Circular directory structure.\n\This almost certainly means that you have a corrupted file system.\n\NOTIFY YOUR SYSTEM MANAGER.\n\The following directory is part of the cycle:\n  %s\n"),		       quote (full_filename (".")));		longjmp (ds->current_arg_jumpbuf, 1);	      }	    *subdir = xstrdup (f);	    break;	  }	}      /* Record status for this directory.  */      UPDATE_STATUS (top->status, status);      if (*subdir)	break;    }  if (dirp == NULL || CLOSEDIR (dirp) != 0)    {      /* Note that this diagnostic serves for both readdir	 and closedir failures.  */      error (0, errno, _("reading directory %s"), quote (full_filename (".")));      status = RM_ERROR;    }  return status;}