dirfd doesn't exist in some platforms.
authorJeremy Allison <jra@samba.org>
Sat, 26 Feb 2011 01:25:36 +0000 (17:25 -0800)
committerJeremy Allison <jra@samba.org>
Sat, 26 Feb 2011 03:19:55 +0000 (04:19 +0100)
Hack that should get the buildfarm back to green.
Ensure dirfd() needs to be defined before we properly return fdopendir.
This will do until we get a proper dirfd() defined in libreplace.

From http://www.gnu.org/software/hello/manual/gnulib/dirfd.html

This function is missing on some platforms: AIX 7.1, HP-UX 11, OSF/1 5.1, Solaris 10, mingw.

Jeremy.

Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Sat Feb 26 04:19:55 CET 2011 on sn-devel-104

source3/lib/system.c
source3/smbd/dir.c

index 24d3c09d58a4b5bd15e9f20989f879fcf173edb1..092287a6020a60957a4769ca4cf2932d37f23101 100644 (file)
@@ -868,13 +868,15 @@ SMB_STRUCT_DIR *sys_opendir(const char *name)
 
 /*******************************************************************
  An fdopendir wrapper that will deal with 64 bit filesizes.
+ Ugly hack - we need dirfd for this to work correctly in the
+ calling code.. JRA.
 ********************************************************************/
 
 SMB_STRUCT_DIR *sys_fdopendir(int fd)
 {
-#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_FDOPENDIR64)
+#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_FDOPENDIR64) && defined(HAVE_DIRFD)
        return fdopendir64(fd);
-#elif defined(HAVE_FDOPENDIR)
+#elif defined(HAVE_FDOPENDIR) && defined(HAVE_DIRFD)
        return fdopendir(fd);
 #else
        errno = ENOSYS;
index 5c502f77068bd65de0765875bc4340ba555bc362..b9791e9dab6d4a1ab45372b466d97f89f70c5de6 100644 (file)
@@ -570,10 +570,16 @@ NTSTATUS dptr_create(connection_struct *conn, files_struct *fsp,
 void dptr_CloseDir(files_struct *fsp)
 {
        if (fsp->dptr) {
+/*
+ * Ugly hack. We have defined fdopendir to return ENOSYS if dirfd also isn't
+ * present. I hate Solaris. JRA.
+ */
+#ifdef HAVE_DIRFD
                if (fsp->fh->fd == dirfd(fsp->dptr->dir_hnd->dir)) {
                        /* The call below closes the underlying fd. */
                        fsp->fh->fd = -1;
                }
+#endif
                dptr_close_internal(fsp->dptr);
                fsp->dptr = NULL;
        }