I was puzzled why some old 32-bit C code, which has been working reliably for many years, was suddenly unable to enumareate the contents of a directory. The code is straightforward and simple. Here's a stripped-down version:

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <dirent.h>
#include <errno.h>

void main(void)
{
  DIR *o;
  struct dirent *d;

  o = opendir("/some/folder/somewhere");
  if (o == NULL)
  {
    fprintf(stderr, "Failed to open directory.\n");
    exit(1);
  }

  errno = 0;
  while ((d=readdir(o)) != NULL)
  {
    printf("Just read %s\n", d->d_name);
  }
  printf("Everything read; errno = %d.\n", errno);
  closedir(o);
}

Yet when I ran this code, it failed with an error code 75 (EOVERFLOW). Or rather, it worked with some folders but not with others.

As it turns out, the code, compiled as 32-bit for backward compatibility, failed because the XFS file system on the target system's 2 TB drive has 64-bit inodes. The test program above fails if compiled with

  cc -m32 dt.c -o dt

but there is an easy fix:

  cc -m32 -D_FILE_OFFSET_BITS=64 dt.c -o dt

That flag changes some structures to use 64-bit inodes, without requiring any rewrite of the offending code.