]> arthur.barton.de Git - netatalk.git/commitdiff
First implementation of AFP3.2 FPSyncDir for timeMachine support, from Bolke de Bruin
authordidg <didg>
Fri, 23 May 2008 06:35:49 +0000 (06:35 +0000)
committerdidg <didg>
Fri, 23 May 2008 06:35:49 +0000 (06:35 +0000)
etc/afpd/auth.c
etc/afpd/directory.c
etc/afpd/directory.h
etc/afpd/switch.c
include/atalk/afp.h

index 0ac50eced3e11354e760a1a722abeebd012490fb..a9755f11d70c6a0387b5a467c9e8771384697dfb 100644 (file)
@@ -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:
index b9c687746ab9616c5a85d376c2b1b0213e20241e..1f2eda1f9f0be9f73e5cb504e9f809d3962807c2 100644 (file)
@@ -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;
index 2acd4a317a29bcf936317b47e64832a48d36ae68..8e39051fabd3f24d5d1fbbf0c96cc7a2074ac4a2 100644 (file)
@@ -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 *));
index d762f1216330365875eca14a3c6865a48348055c..48febcf6a2fcc70b7375d23fb23660ee7e197884 100644 (file)
@@ -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,
index 85a79747b770197df3d2dc1b5448352a2079f185..581d759f61e1cf3cdf7fbe32b0c3636c309bdfcc 100644 (file)
@@ -201,4 +201,7 @@ typedef enum {
 #define AFP_ENUMERATE_EXT2      68
 #define AFP_ZZZ                 122
 
+/* version 3.2 */
+#define AFP_FPSYNCDIR          78
+
 #endif