{
  "status": "shipping",
  "advantages": [
    {
      "text": "dircount and maxcount let a client bound the XDR-encoded reply in bytes, and the server must return NFS4ERR_TOOSMALL when not even one entry fits.",
      "citationIds": [
        "nfs-readdir"
      ]
    },
    {
      "text": "A server whose cookies never become invalid may use zero as the verifier on every reply.",
      "citationIds": [
        "nfs3-readdir"
      ]
    }
  ],
  "limitations": [
    {
      "text": "Cookie stability across directory changes is only a SHOULD, so a long listing can still end with NFS4ERR_NOT_SAME.",
      "citationIds": [
        "nfs-readdir"
      ]
    },
    {
      "text": "Servers should not return the . and .. entries, so a client that needs them must fabricate them.",
      "citationIds": [
        "nfs-readdir"
      ]
    }
  ],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-08",
  "slug": "nfs-readdir-cookie",
  "term": "NFS READDIR cookie",
  "aliases": [
    "NFS directory cookie"
  ],
  "definition": "An NFS READDIR cookie is a server-supplied cursor used to continue retrieving entries from a directory.",
  "note": "In NFSv4.1, a listing starts with cookie zero and a zero cookieverf, then sends a server-issued cookie with the cookieverf from the reply in which it was acquired. The server must reject a verifier it determines is invalid with NFS4ERR_NOT_SAME. The cookie is a 64-bit value meaningful only to the server and is not a byte offset. Cookie values 1 and 2 should not be sent, and 0, 1 and 2 should not be returned. [nfs-readdir]\n\nThe verifier is 8 bytes in both NFSv3 and NFSv4.1. NFSv2 had no verifier, so a reorganized directory could make a second READDIR miss entries or return them twice. NFSv3 added the verifier and rejects a stale cookie with NFS3ERR_BAD_COOKIE. [nfs3-readdir]\n\nA cookie/verifier pair addresses continuation for that directory, not a coordinated snapshot of a directory tree. If requested, rdattr_error can carry an attribute-fetch failure for one entry inside an otherwise successful READDIR reply, so per-entry errors need inspection as well as the operation status. [nfs-readdir]",
  "related": [
    "nfs-storage",
    "directory-enumeration",
    "nfs-attribute-cache",
    "nfs-change-attribute"
  ],
  "citations": [
    {
      "id": "nfs-readdir",
      "title": "Noveck and Lever: RFC 8881, NFSv4.1 READDIR, sections 18.23.3-18.23.4",
      "url": "https://www.rfc-editor.org/rfc/rfc8881.html#section-18.23",
      "accessed": "2026-10-23"
    },
    {
      "id": "nfs3-readdir",
      "title": "Callaghan et al.: RFC 1813, NFS version 3 READDIR, section 3.3.16",
      "url": "https://www.rfc-editor.org/rfc/rfc1813.html#section-3.3.16",
      "accessed": "2026-10-23"
    }
  ],
  "provenance": [
    "nfs-readdir is RFC 8881, re-read for READDIR arguments, results, reserved cookie values, the 64-bit nfs_cookie4 type and the 8-byte NFS4_VERIFIER_SIZE.",
    "nfs3-readdir is RFC 1813 section 3.3.16, read for the NFSv2 problem the verifier solves, NFS3ERR_BAD_COOKIE and the 8-byte NFS3_COOKIEVERFSIZE.",
    "The nfs-lookup-cache entry links here because both depend on cached directory state that a server-side change can make stale."
  ]
}
