char *path = NULL;
long len = fpathconf (dirfd (dir), _PC_NAME_MAX);
+#if !defined(__OS2__) || !defined(__INNOTEK_LIBC__)
#ifdef NAME_MAX
/* POSIX says there shall we room for NAME_MAX bytes at all times */
if (/*len == -1 ||*/ len < NAME_MAX)
return NULL;
#endif
len += offsetof (struct dirent, d_name) + 1;
+#else /* __OS2__ && __INNOTEK_LIBC__ */
+ /* In the implementation of Innotek LIBC, aka kLIBC on OS/2,
+ * fpathconf (_PC_NAME_MAX) is broken, and d_name is not the last member
+ * of struct dirent.
+ * So just allocate as many as the size of struct dirent. */
+ len = sizeof (struct dirent);
+#endif
struct dirent *buf = malloc (len);
if (unlikely(buf == NULL))