ENODATA
Linux / POSIXERRORNotableIPCHIGH confidence
No Data Available
Production Risk
Common when reading optional extended attributes; always handle this case.
What this means
ENODATA (errno 61) is returned when no data is available for a non-blocking read, most commonly from STREAMS message queues or extended attributes.
Why it happens
- 1getmsg() with MSG_DONTWAIT when no message is queued
- 2getxattr() when the attribute does not exist on the file
- 3Reading from a STREAMS pipe with no data
How to reproduce
getxattr() for a non-existent attribute.
trigger — this will error
trigger — this will error
ssize_t n = getxattr("/tmp/file", "user.myattr", buf, sizeof(buf));
// Returns -1, errno = ENODATA if attribute not setexpected output
getxattr: No data available (ENODATA)
Fix
Check for attribute existence before reading
WHEN When reading extended attributes
Check for attribute existence before reading
ssize_t n = getxattr(path, "user.myattr", buf, sizeof(buf));
if (n == -1 && errno == ENODATA) {
// Attribute doesn't exist — use default value
}Why this works
ENODATA from getxattr means the attribute is simply not set; treat it as a missing key.
Sources
Official documentation ↗
Linux Programmer Manual getxattr(2)
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev