Subject: Re: Error -50 copying from OS X

From: Steve Freitas <[email-masked]>
Date: Thu, 20 Dec 2001 12:54:44 -0800

Rick,

Joe Clarke has heard your pain! See below:

----------
From: Joe Clarke <[email-masked]>
Date: Thu, 20 Dec 2001 12:33:00 -0500 (EST)
To: Steve Freitas <[email-masked]>
Subject: Re: FW: Error -50 copying from OS X

Give these patches a try.  This implements a hashdid/lastdid hybrid.
You're free to give these out to others, but know that it may cause data
loss.  Hopefully, it will fix the -50 errors while not causing data loss.
Please provide feedback as soon as you can.

Joe
----------

The patches should apply against RC2. Grab it, untar it, then put the
patches into <netatalk RC2 source dir>/etc/afpd. Then cd to etc/afpd and
apply them:

patch -p0 < directory.h.patch
patch -p0 < file.c.patch
patch -p0 < enumerate.c.patch

Then configure, use --with-did=last, make, make install and give it a try.

Steve

Index: directory.h
===================================================================
RCS file: /cvsroot/netatalk/netatalk/etc/afpd/directory.h,v
retrieving revision 1.3
diff -u -r1.3 directory.h
--- directory.h	2001/12/03 05:03:38	1.3
+++ directory.h	2001/12/20 17:30:00
@@ -130,6 +130,10 @@
 #define CNID(a,b)     (((a)->st_ino & 0x7fffffff) | CNID_FILE(b))
 #endif /* AFS */
 
+#define LAST_DEV(a)   (((major((a)->st_dev) & 0xf) << 3) | \
+                      (minor((a)->st_dev) & 0x7) << 24)
+#define LAST_INODE(a) ((a)->st_ino & 0x00ffffff)
+#define LAST(a,b)     (LAST_DEV(a) | LAST_INODE(a) | CNID_FILE(b))
 
 struct maccess {
     u_char	ma_user;
Index: file.c
===================================================================
RCS file: /cvsroot/netatalk/netatalk/etc/afpd/file.c,v
retrieving revision 1.30
diff -u -r1.30 file.c
--- file.c	2001/12/03 05:03:38	1.30
+++ file.c	2001/12/20 17:30:23
@@ -100,11 +100,7 @@
                  char *path, struct dir *dir, struct stat *st,
                  char *buf, int *buflen )
 {
-#ifndef USE_LASTDID
     struct stat		hst, lst, *lstp;
-#else /* USE_LASTDID */
-    struct stat		hst;
-#endif /* USE_LASTDID */
     struct adouble	ad, *adp;
     struct ofork        *of;
     struct extmap	*em;
@@ -253,16 +249,16 @@
                  *
                  * it should be okay to use lstat to deal with symlinks.
                  */
-#ifdef USE_LASTDID
-                aint = htonl(( st->st_dev << 16 ) | (st->st_ino & 0x0000ffff));
-#else /* USE_LASTDID */
                 lstp = lstat(upath, &lst) < 0 ? st : &lst;
 #ifdef DID_MTAB
                 aint = htonl( afpd_st_cnid ( lstp ) );
 #else /* DID_MTAB */
+#ifdef USE_LASTDID
+				aint = htonl(LAST(lstp, 1));
+#else /* LAST_DID */
                 aint = htonl(CNID(lstp, 1));
-#endif /* DID_MTAB */
 #endif /* USE_LASTDID */
+#endif /* DID_MTAB */
             }
 
             memcpy(data, &aint, sizeof( aint ));
Index: enumerate.c
===================================================================
RCS file: /cvsroot/netatalk/netatalk/etc/afpd/enumerate.c,v
retrieving revision 1.11
diff -u -r1.11 enumerate.c
--- enumerate.c	2001/12/10 20:16:54	1.11
+++ enumerate.c	2001/12/20 17:30:33
@@ -52,9 +52,7 @@
     struct adouble ad;
 #endif /* AD_VERSION > AD_VERSION1 */
 
-#ifndef USE_LASTDID
     struct stat lst, *lstp;
-#endif /* USE_LASTDID */
 
     if ((cdir = dirnew(namlen + 1)) == NULL) {
         syslog( LOG_ERR, "adddir: malloc: %s", strerror(errno) );
@@ -82,19 +80,17 @@
 #endif /* CNID_DB */
 
     if (cdir->d_did == 0) {
-#ifdef USE_LASTDID
-        /* last way of doing DIDs */
-        cdir->d_did = htonl( vol->v_lastdid++ );
-#else /* USE_LASTDID */
         lstp = lstat(upath, &lst) < 0 ? st : &lst;
 #ifdef DID_MTAB
         /* mtab way of doing DIDs */
         cdir->d_did = htonl( afpd_st_cnid ( lstp ) );
 #else /* DID_MTAB */
-        /* the old way of doing DIDs (default) */
+#ifdef USE_LASTDID
+		cdir->d_did = htonl(LAST(lstp, 0));
+#else
         cdir->d_did = htonl( CNID(lstp, 0) );
-#endif /* DID_MTAB */
 #endif /* USE_LASTDID */
+#endif /* DID_MTAB */
     }
 
     if ((edir = dirinsert( vol, cdir ))) {

---

From: Rick Zeman <[email-masked]>
Date: Fri, 21 Dec 2001 11:09:27 -0500

> Joe Clarke has heard your pain! See below:

Works thus far with light banging on it.

-- 
"So Long, and Thanks For All the Fish."
       --Douglas Adams
          1952-2001