{"record":{"id":"42e6604822fc8694","repo":"podman-container-tools/podman","slug":"readdir-s-m","errorCode":null,"errorMessage":"readdir %s: %m\n","messagePattern":"readdir (.+?): %m\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/rootless/rootless_linux.c","lineNumber":489,"sourceCode":"          /* Ignore the failure if the file was deleted.  */\n          if (errno == ENOENT)\n            continue;\n\n          fprintf (stderr, \"stat %s: %m\\n\", path);\n          exit (EXIT_FAILURE);\n        }\n\n      /* Not an executable.  */\n      if ((st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) == 0)\n        continue;\n\n      exec_binary (path, argv, argc);\n      errno = 0;\n    }\n\n  if (errno)\n    {\n      fprintf (stderr, \"readdir %s: %m\\n\", dir);\n      exit (EXIT_FAILURE);\n    }\n}\n\nstatic void\ndo_preexec_hooks (char **argv, int argc)\n{\n  // Access the preexec_hooks_dir indicator file\n  // return without processing if the file doesn't exist\n  char preexec_hooks_path[] = \"/etc/containers/podman_preexec_hooks.txt\";\n  if (access(preexec_hooks_path, F_OK) != 0) {\n    return;\n  }\n\n  char *preexec_hooks = getenv (\"PODMAN_PREEXEC_HOOKS_DIR\");\n  do_preexec_hooks_dir (LIBEXECPODMAN \"/pre-exec-hooks\", argv, argc);\n  do_preexec_hooks_dir (ETC_PREEXEC_HOOKS, argv, argc);\n  if (preexec_hooks && preexec_hooks[0])","sourceCodeStart":471,"sourceCodeEnd":507,"githubUrl":"https://github.com/podman-container-tools/podman/blob/a2409076ef2fef60ad9ac046375dedc7d9410ef4/pkg/rootless/rootless_linux.c#L471-L507","documentation":"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.","triggerScenarios":"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.","commonSituations":"Racing 'rm -rf' or package upgrades against a starting podman; hooks dir on a flaky network mount; extremely rare otherwise.","solutions":["Simply re-run the command - a transient race or I/O hiccup usually does not repeat","Ensure only one actor modifies the hooks directories while podman starts","Check 'dmesg' for filesystem errors if the dir is on NFS/FUSE","If persistent, capture 'strace -e trace=readdir,closefd podman <cmd>' and report upstream"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Simple readability probe of the hooks dir before launching podman\nfor d in /etc/containers/pre-exec-hooks \"${PODMAN_PREEXEC_HOOKS_DIR:-}\"; do\n  [ -n \"$d\" ] && [ -d \"$d\" ] && ls \"$d\" >/dev/null || { [ -n \"$d\" ] && [ -d \"$d\" ] && echo \"hooks dir unreadable: $d\" >&2 && exit 1; }\ndone\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Serialize modifications to hooks directories with podman invocations","Avoid network filesystems for hook storage","Treat a first failure as transient and re-run before debugging"],"tags":["preexec-hooks","filesystem","readdir","race-condition"],"backgroundTag":null,"analyzedSha":"a2409076ef2fef60ad9ac046375dedc7d9410ef4","analyzedAt":"2026-08-15T15:57:05.625Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}