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. shlibs/blkid/src/read.c: Do not define _XOPEN_SOURCE to 600, or DIR will lose it's dd_fd member again. Rearrange defines and includes to make sense per comments, and not conflict on Solaris. Signed-off-by: Fabian Groffen <grobian@xxxxxxxxxx> diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -242,6 +242,24 @@ AC_MSG_RESULT(yes), AC_MSG_RESULT(no)) +have_dirfd=no +AC_CHECK_FUNCS([dirfd], [have_dirfd=yes], [have_dirfd=no]) +if test x"$have_dirfd" = xno ; then + AC_CHECK_DECLS([dirfd], [have_dirfd=yes], [have_dirfd=no], + [#include <sys/types.h> + #include <dirent.h>]) +fi +have_ddfd=no +if test x"$have_dirfd" = xno ; then + AC_CHECK_MEMBERS([DIR.dd_fd], [have_ddfd=yes], [have_ddfd=no], + [#include <sys/types.h> + #include <dirent.h>]) +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 + + 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 @@ -109,5 +109,14 @@ # endif #endif +#if !defined(HAVE_DIRFD) && (!defined(HAVE_DECL_DIRFD) || HAVE_DECL_DIRFD == 0) && defined(HAVE_DIR_DD_FD) +#include <sys/types.h> +#include <dirent.h> +static inline int dirfd(DIR *d) +{ + return d->dd_fd; +} +#endif + #endif /* UTIL_LINUX_C_H */ diff --git a/shlibs/blkid/src/read.c b/shlibs/blkid/src/read.c --- a/shlibs/blkid/src/read.c +++ b/shlibs/blkid/src/read.c @@ -10,7 +10,6 @@ * %End-Header% */ -#define _XOPEN_SOURCE 600 /* for inclusion of strtoull */ #include <stdio.h> #include <ctype.h> @@ -26,6 +25,11 @@ #include "blkidP.h" +#if HAVE_STDLIB_H +#define _XOPEN_SOURCE 600 /* for inclusion of strtoull */ +#include <stdlib.h> +#endif + #ifdef HAVE_STRTOULL #define STRTOULL strtoull /* defined in stdlib.h if you try hard enough */ #else @@ -33,10 +37,6 @@ #define STRTOULL strtoul #endif -#if HAVE_STDLIB_H -#include <stdlib.h> -#endif - #ifdef TEST_PROGRAM #define blkid_debug_dump_dev(dev) (debug_dump_dev(dev)) static void debug_dump_dev(blkid_dev dev); -- 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