When we run configure on FreeBSD the test for dirfd fails: configure:25451: checking for dirfd configure:25507: gcc -o conftest -O0 -I/home/rsharpe/dev-src/buildroot/tools/x86_gcc4.2.4/usr/include -DPANZURA_DEV -I/home/rsharpe/dev-src/buildroot/../pixel8/replock -I/home/rsharpe/dev-src/buildroot/build/cloudcc/build_x86_64/samba-3.6.6/lib/tdb/include -I/home/rsharpe/dev-src/buildroot/build/cloudcc/build_x86_64/root/usr/include -Iinclude -I./include -I. -I. -I./../lib/replace -I./../lib/tevent -I./librpc -I./.. -I./../lib/popt --sysroot /home/rsharpe/dev-src/buildroot/tools/x86_gcc4.2.4 -L/home/rsharpe/dev-src/buildroot/tools/x86_gcc4.2.4/lib -L/home/rsharpe/dev-src/buildroot/tools/x86_gcc4.2.4/usr/lib -L/home/rsharpe/dev-src/buildroot/build/cloudcc/build_x86_64/samba-3.6.6/source3 -L/home/rsharpe/dev-src/buildroot/build/cloudcc/build_x86_64/samba-3.6.6/source3/bin -L/home/rsharpe/dev-src/buildroot/build/cloudcc/build_x86_64/licd/build/FreeBSD/export/dist/lib -rpath /home/rsharpe/dev-src/buildroot/tools/x86_gcc4.2.4/lib -rpath /home/rsharpe/dev-src/buildroot/tools/x86_gcc4.2.4/usr/lib conftest.c >&5 /var/tmp//ccQXACBM.o(.text+0xa): In function `main': : undefined reference to `dirfd' This is because it is a macro and the testing code is: | int | main () | { | return dirfd (); | ; | return 0; | } We need a more robust configure test.
I think we can do something like: AC_CHECK_DECLS(dirfd, [AC_DEFINE(HAVE_DIRFD,1,[Whether we have dirfd])], [AC_CHECK_FUNCS(dirfd)], #include <dirent.h>) if test x"$ac_cv_func_dirfd" = x"yes" -o x"ac_cv_have_decl_diffd" = x"yes"; then ... current actions. fi
Hmmm, my suggestion above is bogus. Here is something that promises to work (stolen from sudo): dnl dnl Check for the dirfd function/macro. If not found, look for dd_fd in DIR. dnl AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> #include <$ac_header_dirent>]], [[DIR *d; (void)dirfd(d);]])], [AC_DEFINE(HAVE_DIRFD)], [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> #include <$ac_header_dirent>]], [[DIR d; memset(&d, 0, sizeof(d)); return(d.dd_fd);]])], [AC_DEFINE(HAVE_DD_FD)], [])]) Clearly, it will need a little changing to do what we want but it is close.
This looks like it should do something close to what is needed: ########################################### # Check for the dirfd function/macro. AC_CACHE_CHECK([for dirfd as func or macro], [ AC_TRY_COMPILE([ #include <sys/types.h> #include <$ac_header_dirent>], [DIR *d; (void)dirfd(d);], [samba_ac_cv_func_dirfd=yes], [samba_ac_cv_func_dirfd=no])]) if test x"$samba_ac_cv_func_dirfd" = x"yes"; then AC_DEFINE(HAVE_DIRFD)] default_shared_modules="$default_shared_modules vfs_syncops vfs_dirsort" fi However, autogen.sh is generating some weird stuff so I don't know what is going wrong.
This is closer to correct, but it seems Linux has an automatic test for dirfd anyway: ########################################### # Check for the dirfd function/macro. AC_CACHE_CHECK([for dirfd as func or macro], samba_cv_have_dirfd, [ AC_TRY_COMPILE([ #include <sys/types.h> #include <$ac_header_dirent>], [DIR *d; (void)dirfd(d);], [samba_cv_have_dirfd=yes], [samba_cv_have_dirfd=no])]) if test x"$samba_cv_have_dirfd" = x"yes"; then AC_DEFINE(HAVE_DIRFD,1,[Whether we have dirfd as func or macro]) default_shared_modules="$default_shared_modules vfs_syncops vfs_dirsort" fi
The above entry seems to work for FreeBSD now. However, it might be that on the FreeBSD system I am using we have an old version of autoconf, because there are checks for dirfd, they just do not detect the presence of dirfd.
The above fix also works on Linux (CentOS 6.3).
Created attachment 8168 [details] Patch in git format-patch format
Comment on attachment 8168 [details] Patch in git format-patch format This looks good to me.
For reasons I can not understand, bugzilla does not present me with any review button or check box I can review. The change looks good to me ...
Do we also need this for 4.0.x (and in that case a waf fix also) ? Jeremy.
(In reply to comment #9) > For reasons I can not understand, bugzilla does not present me with any review > button or check box I can review. the question is why you created a second bugzilla account. Your previous and still existing account has the rights to do that.
Created attachment 8174 [details] Patch for 3.6
Created attachment 8175 [details] Patch for 4.0
(In reply to comment #11) > (In reply to comment #9) > > For reasons I can not understand, bugzilla does not present me with any review > > button or check box I can review. > > the question is why you created a second bugzilla account. Your previous and > still existing account has the rights to do that. Probably because I forgot about the previous account, or could not remember the password.