dirfd is not available on Solaris 10, it is available on latest OpenSolaris releases though. Do some autoconf trickery to determine if providing an alternative dirfd function is necessary and possible. Signed-off-by: Fabian Groffen <grobian@xxxxxxxxxx> diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -226,6 +226,34 @@ AC_SEARCH_LIBS([socket], [socket], [if test x"$ac_cv_search_socket" != x"none required"; then SOCKET_LIBS="$SOCKET_LIBS -lsocket"; fi]) AC_SUBST(SOCKET_LIBS) +have_dirfd= +AC_MSG_CHECKING([for dirfd]) +AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#include <dirent.h> +]],[[ + DIR *dir = 0; + if (dirfd(dir)) ; +]])], [have_dirfd=yes], [have_dirfd=no]) +AC_MSG_RESULT([$have_dirfd]) +have_ddfd= +if test x"$have_dirfd" = xno ; then + AC_MSG_CHECKING([for dd_fd member in struct dirent]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include <dirent.h> +]],[[ + DIR *dir = 0; + if (dir->dd_fd) ; + ]])], [have_ddfd=yes], [have_ddfd=no]) + AC_MSG_RESULT([$have_ddfd]) +fi +if test x"$have_dirfd" = xno && test x"$have_ddfd" = xno ; then + AC_MSG_ERROR([cannot find a method to get filedescriptor of directory]) +fi +if test x"$have_ddfd" = xyes ; then + AC_DEFINE(HAVE_DDFD, 1, [Define if struct DIR has a member dd_fd]) +fi + + dnl Static compilation m4_define([UTIL_STATIC_PROGRAMS], [losetup, mount, umount, fdisk, sfdisk, blkid]) diff --git a/include/c.h b/include/c.h --- a/include/c.h +++ b/include/c.h @@ -97,5 +97,12 @@ typedef int64_t loff_t; #endif +#if !defined(HAVE_DIRFD) && defined(HAVE_DDFD) +static inline int dirfd(DIR *dir) +{ + return dir->dd_fd; +} +#endif + #endif /* UTIL_LINUX_C_H */ -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html