]> arthur.barton.de Git - netatalk.git/commitdiff
afp_syncdir: only fsync directories on hosts that have dirfd (e.g. Linux). fsyncin...
authorfranklahm <franklahm>
Fri, 10 Apr 2009 11:21:18 +0000 (11:21 +0000)
committerfranklahm <franklahm>
Fri, 10 Apr 2009 11:21:18 +0000 (11:21 +0000)
configure.in
etc/afpd/directory.c

index ec37454ca42da8b79f3cded38d206a86e6ac4435..bdedc2084ca7179d5f4ce788813d6b9e9ea48eb0 100644 (file)
@@ -1,4 +1,4 @@
-dnl $Id: configure.in,v 1.214 2009-04-05 07:22:06 franklahm Exp $
+dnl $Id: configure.in,v 1.215 2009-04-10 11:21:18 franklahm Exp $
 dnl configure.in for netatalk
 
 AC_INIT(etc/afpd/main.c)
@@ -132,10 +132,9 @@ AC_TYPE_SIGNAL
 AC_FUNC_UTIME_NULL
 AC_FUNC_WAIT3
 AC_CHECK_FUNCS(getcwd gethostname gettimeofday getusershell mkdir rmdir select socket strdup strcasestr strstr strtoul strchr memcpy)
-AC_CHECK_FUNCS(backtrace_symbols)
-AC_CHECK_FUNCS(setlocale nl_langinfo)
+AC_CHECK_FUNCS(backtrace_symbols setlocale nl_langinfo)
 AC_CHECK_FUNCS(waitpid getcwd strdup strndup strnlen strtoul strerror chown fchown chmod fchmod chroot link mknod mknod64)
-AC_CHECK_FUNCS(strlcpy strlcat setlinebuf gethostid)
+AC_CHECK_FUNCS(strlcpy strlcat setlinebuf gethostid dirfd)
 AC_CHECK_MEMBERS(struct tm.tm_gmtoff,,, [#include <time.h>])
 AC_CACHE_SAVE
 
index 07ebc30f5677bb26f405da146d801a5e2f2e16e6..53a36b306ddd263877591158840477fb830ddf1c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: directory.c,v 1.95 2009-03-24 11:02:07 franklahm Exp $
+ * $Id: directory.c,v 1.96 2009-04-10 11:21:19 franklahm Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -2165,7 +2165,9 @@ AFPObj  *obj _U_;
 char    *ibuf, *rbuf _U_;
 int     ibuflen _U_, *rbuflen;
 {
+#ifdef HAVE_DIRFD
     DIR                  *dp;
+#endif
     int                  dfd;
     struct vol           *vol;
     struct dir           *dir;
@@ -2190,6 +2192,12 @@ int     ibuflen _U_, *rbuflen;
     if (movecwd( vol, dir ) < 0 )
         return ( AFPERR_NOOBJ ); 
 
+/*
+  Assuming only OSens that have dirfd also may require fsyncing directories
+  in order to flush metadata e.g. Linux.
+*/
+    
+#ifdef HAVE_DIRFD
     if (NULL == ( dp = opendir( "." )) ) {
         switch( errno ) {
         case ENOENT :
@@ -2208,8 +2216,9 @@ int     ibuflen _U_, *rbuflen;
         LOG(log_error, logtype_afpd, "afp_syncdir(%s):  %s",
             dir->d_u_name, strerror(errno) );
     closedir(dp); /* closes dfd too */
+#endif
 
-    if ( -1 == (dfd = open(vol->vfs->ad_path(".", ADFLAGS_DIR), O_RDONLY))) {
+    if ( -1 == (dfd = open(vol->vfs->ad_path(".", ADFLAGS_DIR), O_RDWR))) {
         switch( errno ) {
         case ENOENT:
             return( AFPERR_NOOBJ );