From eeee5218d55c72b8b1ca2e8de935b510ec54aed1 Mon Sep 17 00:00:00 2001 From: franklahm Date: Fri, 10 Apr 2009 11:21:18 +0000 Subject: [PATCH 1/1] afp_syncdir: only fsync directories on hosts that have dirfd (e.g. Linux). fsyncin' dirs is non standard --- configure.in | 7 +++---- etc/afpd/directory.c | 13 +++++++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/configure.in b/configure.in index ec37454c..bdedc208 100644 --- a/configure.in +++ b/configure.in @@ -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 ]) AC_CACHE_SAVE diff --git a/etc/afpd/directory.c b/etc/afpd/directory.c index 07ebc30f..53a36b30 100644 --- a/etc/afpd/directory.c +++ b/etc/afpd/directory.c @@ -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 ); -- 2.39.2