From: didg Date: Fri, 23 May 2008 06:35:49 +0000 (+0000) Subject: First implementation of AFP3.2 FPSyncDir for timeMachine support, from Bolke de Bruin X-Git-Tag: before_acls~61 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=commitdiff_plain;h=fea987bdee62c3429485e556c09e5ade8551d0e3 First implementation of AFP3.2 FPSyncDir for timeMachine support, from Bolke de Bruin --- diff --git a/etc/afpd/auth.c b/etc/afpd/auth.c index 0ac50ece..a9755f11 100644 --- a/etc/afpd/auth.c +++ b/etc/afpd/auth.c @@ -1,5 +1,5 @@ /* - * $Id: auth.c,v 1.52 2008-05-16 04:19:41 didg Exp $ + * $Id: auth.c,v 1.53 2008-05-23 06:35:49 didg Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -76,7 +76,8 @@ static struct afp_versions afp_versions[] = { { "AFP2.2", 22 }, #ifdef AFP3x { "AFPX03", 30 }, - { "AFP3.1", 31 } + { "AFP3.1", 31 }, + { "AFP3.2", 32 } #endif }; @@ -186,6 +187,7 @@ static int set_auth_switch(int expired) else { afp_switch = postauth_switch; switch (afp_version) { + case 32: case 31: uam_afpserver_action(AFP_ENUMERATE_EXT2, UAM_AFPSERVER_POSTAUTH, afp_enumerate_ext2, NULL); case 30: diff --git a/etc/afpd/directory.c b/etc/afpd/directory.c index b9c68774..1f2eda1f 100644 --- a/etc/afpd/directory.c +++ b/etc/afpd/directory.c @@ -1,5 +1,5 @@ /* - * $Id: directory.c,v 1.84 2006-09-29 09:39:16 didg Exp $ + * $Id: directory.c,v 1.85 2008-05-23 06:35:49 didg Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -2271,6 +2271,53 @@ setdirparam_done: return err; } + +int afp_syncdir(obj, ibuf, ibuflen, rbuf, rbuflen ) +AFPObj *obj; +char *ibuf, *rbuf; +int ibuflen _U_, *rbuflen; +{ + DIR *dp; + int dfd; + struct vol *vol; + struct dir *dir; + u_int32_t did; + u_int16_t vid; + + *rbuflen = 0; + ibuf += 2; + + memcpy( &vid, ibuf, sizeof( vid )); + ibuf += sizeof( vid ); + if (NULL == (vol = getvolbyvid( vid )) ) { + return( AFPERR_PARAM ); + } + + memcpy( &did, ibuf, sizeof( did )); + ibuf += sizeof( did ); + if (NULL == ( dir = dirlookup( vol, did )) ) { + return afp_errno; /* was AFPERR_NOOBJ */ + } + + if (NULL == ( dp = opendir( "." )) ) { + switch( errno ) { + case ENOENT : + return( AFPERR_NOOBJ ); + case EACCES : + return( AFPERR_ACCESS ); + default : + return( AFPERR_PARAM ); + } + } + + dfd = dirfd( dp ); + if ( fsync ( dfd ) < 0 ) { + LOG(log_error, logtype_afpd, "syncdir(%s): ddir(%d) %s", dir->d_u_name, dfd, strerror(errno) ); + } + + return ( AFP_OK ); +} + int afp_createdir(obj, ibuf, ibuflen, rbuf, rbuflen ) AFPObj *obj; char *ibuf, *rbuf; diff --git a/etc/afpd/directory.h b/etc/afpd/directory.h index 2acd4a31..8e39051f 100644 --- a/etc/afpd/directory.h +++ b/etc/afpd/directory.h @@ -1,5 +1,5 @@ /* - * $Id: directory.h,v 1.19 2005-04-30 21:33:41 didg Exp $ + * $Id: directory.h,v 1.20 2008-05-23 06:35:49 didg Exp $ * * Copyright (c) 1990,1991 Regents of The University of Michigan. * All Rights Reserved. @@ -219,6 +219,7 @@ extern int afp_setdirparams __P((AFPObj *, char *, int, char *, int *)); extern int afp_closedir __P((AFPObj *, char *, int, char *, int *)); extern int afp_mapid __P((AFPObj *, char *, int, char *, int *)); extern int afp_mapname __P((AFPObj *, char *, int, char *, int *)); +extern int afp_syncdir __P((AFPObj *, char *, int, char *, int *)); /* from enumerate.c */ extern int afp_enumerate __P((AFPObj *, char *, unsigned int, char *, unsigned int *)); diff --git a/etc/afpd/switch.c b/etc/afpd/switch.c index d762f121..48febcf6 100644 --- a/etc/afpd/switch.c +++ b/etc/afpd/switch.c @@ -1,5 +1,5 @@ /* - * $Id: switch.c,v 1.13 2005-04-28 20:49:44 bfernhomberg Exp $ + * $Id: switch.c,v 1.14 2008-05-23 06:35:49 didg Exp $ * * Copyright (c) 1990,1991 Regents of The University of Michigan. * All Rights Reserved. @@ -152,7 +152,7 @@ int (*postauth_switch[])() = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 64 - 71 */ NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, /* 72 - 79 */ + NULL, NULL, afp_syncdir, NULL, /* 72 - 79 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 80 - 87 */ NULL, NULL, NULL, NULL, diff --git a/include/atalk/afp.h b/include/atalk/afp.h index 85a79747..581d759f 100644 --- a/include/atalk/afp.h +++ b/include/atalk/afp.h @@ -201,4 +201,7 @@ typedef enum { #define AFP_ENUMERATE_EXT2 68 #define AFP_ZZZ 122 +/* version 3.2 */ +#define AFP_FPSYNCDIR 78 + #endif