Subject: [netatalk-admins] os8, finder info yuckiness, and a fix

From: a sun <[email-masked]>
Date: Thu, 7 Aug 1997 23:48:42 -0700 (PDT)

well, i'm pretty sure i've fixed the problem w/ finder
updates. os8 uses bits that it didn't before. netatalk, of
course, does the wrong thing and touches those bits. here's what
happens:

	mac gets a directory list. 
	mac realizes that the finder info is wrong for files which
           weren't copied to the server (e.g., the .??? files).
        mac sends back a correction for that info.
	netatalk disregards that correction
	repeat until thoroughly confused.

anyways, i've made available a patch to a14 to fix this. it's at the
standard place of ftp.u.washington.edu:/public/asun as
asun2.0a13-a14.diff.gz. it also fixes a couple other small things. you
might need to delete the "diff -u3" references from the patch file if
your version of patch doesn't ignore those.

after applying the patch, your mac will happily correct your incorrect
resource forks so things should just start working.

here's the fix for 1.4b2:

--- file.c.save Thu Aug  7 23:22:55 1997
+++ file.c      Thu Aug  7 23:47:43 1997
@@ -124,8 +124,7 @@
            break;

        case FILPBIT_FINFO :
-           if ( !isad ||
-                   bcmp( ad_entry( &ad, ADEID_FINDERI ), ufinderi, 8 ) == 0 ) {
+           if ( !isad ) {
                bcopy( ufinderi, data, 32 );
                if (( em = getextmap( path )) != NULL ) {
                    bcopy( em->em_type, data, sizeof( em->em_type ));
@@ -333,7 +332,6 @@
     u_short    bitmap;
 {
     struct adouble     ad;
-    struct extmap      *em;
     int                        bit = 0;
     u_short            ashort, bshort;
     u_long             along;
@@ -397,16 +395,6 @@
            break;

        case FILPBIT_FINFO :
-           if (( ad_getoflags( &ad, ADFLAGS_HF ) & O_CREAT ) ||
-                   bcmp( ad_entry( &ad, ADEID_FINDERI ), ufinderi, 8 ) == 0 ) {
-               if (( em = getextmap( path )) != NULL ) {
-                   if ( bcmp( buf, em->em_type, sizeof( em->em_type )) == 0 &&
-                           bcmp( buf + 4, em->em_creator,
-                           sizeof( em->em_creator )) == 0 ) {
-                       bcopy( ufinderi, buf, 8 );
-                   }
-               }
-           }
            bcopy( buf, ad_entry( &ad, ADEID_FINDERI ), 32 );
            buf += 32;
            break;

---

From: [email-masked]
Date: Fri, 08 Aug 1997 04:49:28 -0400

> From:    a sun <[email-masked]>
> To:      [email-masked], [email-masked]

> resource forks so things should just start working.

Ah, I don't know that I'd apply this patch...

While it's certainly a good call what's happening, removing the checks
will break the dynamic nature of the extension maps, i.e. once you've
opened and closed a directory once, all files will have their types
set.  The "stock" file extension code doesn't do this, instead it
leaves all Unix files with a server-side type and creator of TEXT/UNIX,
changing the information on the fly as the client asks for it.  That
way, if you edit your extension map, all the files magically change
type.  It's even the case that changing the name of an extension mapped
file changes it's type...

In any case, I think there must be a better fix.

:wes

---

From: a sun <[email-masked]>
Date: Fri, 8 Aug 1997 02:24:53 -0700 (PDT)

erk. i didn't realize that people did that. i guess my patch was a
little too extreme. in any case, all that needs to be done is make
sure that the finder info sans type/creator gets saved and
returned. i'll submit something suitable in a little bit.

-a

---

From: a sun <[email-masked]>
Date: Fri, 8 Aug 1997 09:12:23 -0700 (PDT)

here's my new fix for 1.4b2. after i've tested to see if it works
properly, i'll make a new a13-14-2 which incorporates it. anyways, it
should preserve dynamic extension maps at the cost of an extra copy.

--- fork.c.save	Fri Aug  8 08:45:41 1997
+++ fork.c	Fri Aug  8 08:52:41 1997
@@ -709,15 +709,16 @@
 	    break;
 
 	case FILPBIT_FINFO :
-	    if ( !isad || bcmp( ad_entry( &ofork->of_ad, ADEID_FINDERI ),
+	    memcpy(data, isad ? ad_entry(&ofork->of_ad, ADEID_FINDERI) :
+		   ufinderi, 32);
+
+	    if (!isad || bcmp( ad_entry( &ofork->of_ad, ADEID_FINDERI ),
 		    ufinderi, 8 ) == 0 ) {
-		bcopy( ufinderi, data, 32 );
+		bcopy( ufinderi, data, 8 );
 		if (( em = getextmap( ofork->of_name )) != NULL ) {
 		    bcopy( em->em_type, data, sizeof( em->em_type ));
 		    bcopy( em->em_creator, data + 4, sizeof( em->em_creator ));
 		}
-	    } else {
-		bcopy( ad_entry( &ofork->of_ad, ADEID_FINDERI ), data, 32 );
 	    }
 	    data += 32;
 	    break;
--- file.c.save	Fri Aug  8 08:44:49 1997
+++ file.c	Fri Aug  8 09:06:34 1997
@@ -124,15 +124,16 @@
 	    break;
 
 	case FILPBIT_FINFO :
+	    memcpy(data, isad ? ad_entry(&ad, ADEID_FINDERI) :
+		   ufinderi, 32);
+
 	    if ( !isad ||
 		    bcmp( ad_entry( &ad, ADEID_FINDERI ), ufinderi, 8 ) == 0 ) {
-		bcopy( ufinderi, data, 32 );
+		bcopy( ufinderi, data, 8);
 		if (( em = getextmap( path )) != NULL ) {
 		    bcopy( em->em_type, data, sizeof( em->em_type ));
 		    bcopy( em->em_creator, data + 4, sizeof( em->em_creator ));
 		}
-	    } else {
-		bcopy( ad_entry( &ad, ADEID_FINDERI ), data, 32 );
 	    }
 	    data += 32;
 	    break;
@@ -407,7 +408,7 @@
 		    }
 		}
 	    }
-	    bcopy( buf, ad_entry( &ad, ADEID_FINDERI ), 32 );
+	    memcpy(ad_entry( &ad, ADEID_FINDERI ), buf, 32 );
 	    buf += 32;
 	    break;