What does errno 21 (EISDIR) mean?

 
Could be also:
ConstantTypeOS
ERROR_NOT_READYWin32 errorWindows
KERN_RIGHT_EXISTSKern returnMac
ippStsCpuMismatchIntel Ipp StatusAny
LAST_CHANCE_CALLED_FROM_KMODEBugCheck CodeWindows
Previous Next
ENOTDIR EINVAL

EISDIR

What type mismatch occurred

EISDIR tells you that the target exists and is a directory, but the requested operation expects something else. A read call on a descriptor that refers to a directory can return this code. Opening a directory for modification as though it were a regular file can do the same. Rename and unlink-style operations also distinguish directory and non-directory targets because the correct API and safety rules differ.

The code is useful precisely because it is not ENOENT or ENOTDIR: the path resolved successfully, and the unexpected part is the final object type.

How to investigate

  • Confirm the final object type and whether the intended path accidentally points at a directory, mount root, or package folder.
  • Use directory-specific APIs for enumeration, creation, or removal rather than regular-file read/write assumptions.
  • Check path joins and filename variables; an empty filename component often collapses to the directory itself.
  • For destructive code, treat the mismatch as a guardrail instead of trying to coerce a directory into a file operation.

References


Looking for a different code? Search another status or error code.