[prev in list] [next in list] [prev in thread] [next in thread]
List: netatalk-devel
Subject: Re: [Netatalk-devel] FPSyncDir patch
From: Bolke de Bruin <bdbruin () gmail ! com>
Date: 2008-04-25 5:48:40
Message-ID: D88FD25B-D0D2-4E4D-B367-AE3375C5F7DA () gmail ! com
[Download RAW message or body]
Cheers! That solved my problem. Please find the corrected patch
attached. One thing left however, the function do no seem to be called
if I only specify them in switch.c. To be honest I have no clue why.
Maybe someone else could fix this?
regards,
Bolke.
["syncfork_syncdir-fixed.patch" (syncfork_syncdir-fixed.patch)]
--- netatalk/etc/afpd/switch.c 2005-04-28 22:49:44.000000000 +0200
+++ netatalk.cmd/etc/afpd/switch.c 2008-04-20 20:27:36.000000000 +0200
@@ -153,7 +153,7 @@
NULL, NULL, NULL, NULL, /* 64 - 71 */
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, /* 72 - 79 */
- NULL, NULL, NULL, NULL,
+ NULL, NULL, afp_syncdir, afp_syncfork,
NULL, NULL, NULL, NULL, /* 80 - 87 */
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, /* 88 - 95 */
--- netatalk/etc/afpd/directory.h 2005-04-30 23:33:41.000000000 +0200
+++ netatalk.cmd/etc/afpd/directory.h 2008-04-20 19:38:14.000000000 +0200
@@ -219,6 +219,7 @@
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 *));
--- netatalk/etc/afpd/directory.c 2006-09-29 11:39:16.000000000 +0200
+++ netatalk.cmd/etc/afpd/directory.c 2008-04-20 20:26:55.000000000 +0200
@@ -2271,6 +2271,47 @@
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( "." )) ) {
+ return afp_errno;
+ }
+
+ 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_errno;
+ }
+
+ return ( AFP_OK );
+}
+
int afp_createdir(obj, ibuf, ibuflen, rbuf, rbuflen )
AFPObj *obj;
char *ibuf, *rbuf;
--- netatalk/etc/afpd/fork.h 2005-09-28 11:46:37.000000000 +0200
+++ netatalk.cmd/etc/afpd/fork.h 2008-04-20 18:53:22.000000000 +0200
@@ -89,4 +89,6 @@
extern int afp_bytelock_ext __P((AFPObj *, char *, int, char *, int *));
extern int afp_read_ext __P((AFPObj *, char *, int, char *, int *));
extern int afp_write_ext __P((AFPObj *, char *, int, char *, int *));
+
+extern int afp_syncfork __P((AFPObj *, char *, int, char *, int *));
#endif
--- netatalk/etc/afpd/fork.c 2006-09-29 11:39:16.000000000 +0200
+++ netatalk.cmd/etc/afpd/fork.c 2008-04-20 19:24:35.000000000 +0200
@@ -1053,6 +1053,50 @@
return read_fork(obj, ibuf, ibuflen, rbuf, rbuflen, 1);
}
+
+/* ----------------------------- */
+/* There is a lot to tell about fsync, fdatasync, F_FULLFSYNC.
+ * fsync(2) on OSX is implemented differently than on other platforms.
+ * see: http://mirror.linux.org.au/pub/linux.conf.au/2007/video/talks/278.pdf.
+ */
+int afp_syncfork(obj, ibuf, ibuflen, rbuf, rbuflen )
+AFPObj *obj;
+char *ibuf, *rbuf _U_;
+int ibuflen _U_, *rbuflen;
+{
+ struct ofork *ofork;
+ u_int16_t ofrefnum;
+
+ *rbuflen = 0;
+ ibuf += 2;
+
+ memcpy(&ofrefnum, ibuf, sizeof(ofrefnum));
+ ibuf += sizeof( ofrefnum );
+
+ if (NULL == ( ofork == of_find( ofrefnum )) ) {
+ LOG(log_error, logtype_afpd, "afpd_syncfork: of_find(%d) could not locate fork", ofrefnum );
+ return( AFPERR_PARAM );
+ }
+
+#ifdef HAVE_DATASYNC
+ if ( ad_data_fileno( ofork->of_ad ) != -1 &&
+ fdatasync( ad_data_fileno( ofork->of_ad )) < 0 ) {
+ LOG(log_error, logtype_afpd, "syncfork(%s): dfile(%d) %s",
+ of_name(ofork), ad_data_fileno(ofork->of_ad), strerror(errno) );
+ return( AFPERR_PARAM );
+ }
+#else
+ if ( ad_data_fileno( ofork->of_ad ) != -1 &&
+ fsync( ad_data_fileno( ofork->of_ad )) < 0 ) {
+ LOG(log_error, logtype_afpd, "syncfork(%s): dfile(%d) %s",
+ of_name(ofork), ad_data_fileno(ofork->of_ad), strerror(errno) );
+ return( AFPERR_PARAM );
+ }
+#endif /* HAVE_DATASYNC */
+
+ return( AFP_OK );
+}
+
/* ---------------------- */
int afp_flush(obj, ibuf, ibuflen, rbuf, rbuflen )
AFPObj *obj _U_;
--- netatalk/include/atalk/afp.h 2003-03-15 02:34:37.000000000 +0100
+++ netatalk.cmd/include/atalk/afp.h 2008-04-20 18:31:21.000000000 +0200
@@ -199,6 +199,10 @@
/* version 3.1 */
#define AFP_ENUMERATE_EXT2 68
+#define AFP_ACCESS 75
+#define AFP_SPOTLIGHT 76
+#define AFP_SYNCDIR 78
+#define AFP_SYNCFORK 79
#define AFP_ZZZ 122
#endif
--- netatalk/etc/afpd/auth.c 2007-12-03 15:50:38.000000000 +0100
+++ netatalk.cmd/etc/afpd/auth.c 2008-04-20 20:43:28.000000000 +0200
@@ -76,7 +76,8 @@
{ "AFP2.2", 22 },
#ifdef AFP3x
{ "AFPX03", 30 },
- { "AFP3.1", 31 }
+ { "AFP3.1", 31 },
+ { "AFP3.2", 32 }
#endif
};
@@ -186,6 +187,7 @@
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:
Op 24 apr 2008, om 23:48 heeft didier het volgende geschreven:
>> On 24-Apr-08, at 2:32 PM, Bolke de Bruin wrote:
>>>
>>> My patch for FPSyncDir isn't entirely correct. I will fix it up
>>> when I
>>> find out how to get the directory path of a did (so opendir
>>> works). If
>>> someone is faster than me that would be very much appreciated :-).
> opendir(".")
>
> IIRC after a call to dirlookup you are in it.
>
> Didier
>
>
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Netatalk-devel mailing list
Netatalk-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/netatalk-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic