podman-container-tools/podman · error

readdir %s: %m

Error message

readdir %s: %m

What it means

do_preexec_hooks_dir() uses the glibc readdir convention: errno is cleared before the scan loop and inspected after (pkg/rootless/rootless_linux.c:434-490). A NULL dirent with errno != 0 means readdir itself failed rather than reaching end-of-directory - e.g. EBADF (dirfd closed underneath the scan, often by a signal handler), EOVERFLOW, or an underlying filesystem error. Podman exits with EXIT_FAILURE.

Source

Thrown at pkg/rootless/rootless_linux.c:489

          /* Ignore the failure if the file was deleted.  */
          if (errno == ENOENT)
            continue;

          fprintf (stderr, "stat %s: %m\n", path);
          exit (EXIT_FAILURE);
        }

      /* Not an executable.  */
      if ((st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) == 0)
        continue;

      exec_binary (path, argv, argc);
      errno = 0;
    }

  if (errno)
    {
      fprintf (stderr, "readdir %s: %m\n", dir);
      exit (EXIT_FAILURE);
    }
}

static void
do_preexec_hooks (char **argv, int argc)
{
  // Access the preexec_hooks_dir indicator file
  // return without processing if the file doesn't exist
  char preexec_hooks_path[] = "/etc/containers/podman_preexec_hooks.txt";
  if (access(preexec_hooks_path, F_OK) != 0) {
    return;
  }

  char *preexec_hooks = getenv ("PODMAN_PREEXEC_HOOKS_DIR");
  do_preexec_hooks_dir (LIBEXECPODMAN "/pre-exec-hooks", argv, argc);
  do_preexec_hooks_dir (ETC_PREEXEC_HOOKS, argv, argc);
  if (preexec_hooks && preexec_hooks[0])

View on GitHub (pinned to a2409076ef)

Solutions

  1. Simply re-run the command - a transient race or I/O hiccup usually does not repeat
  2. Ensure only one actor modifies the hooks directories while podman starts
  3. Check 'dmesg' for filesystem errors if the dir is on NFS/FUSE
  4. If persistent, capture 'strace -e trace=readdir,closefd podman <cmd>' and report upstream
Defensive patterns

Strategy: validation

Validate before calling

# Simple readability probe of the hooks dir before launching podman
for d in /etc/containers/pre-exec-hooks "${PODMAN_PREEXEC_HOOKS_DIR:-}"; do
  [ -n "$d" ] && [ -d "$d" ] && ls "$d" >/dev/null || { [ -n "$d" ] && [ -d "$d" ] && echo "hooks dir unreadable: $d" >&2 && exit 1; }
done

Prevention

When it happens

Trigger: The hooks directory is deleted or its dirfd closed while the scan is running; a FUSE/network filesystem returns an I/O error mid-readdir; exotic signal handlers closing arbitrary descriptors.

Common situations: Racing 'rm -rf' or package upgrades against a starting podman; hooks dir on a flaky network mount; extremely rare otherwise.

Related errors


AI-assisted analysis of podman-container-tools/podman@a2409076ef (2026-08-15). Data as JSON: /api/errors/42e6604822fc8694. Report an issue: GitHub.