]> arthur.barton.de Git - netatalk.git/commitdiff
this fixes a problem exposed by the os x appleshare client. flushfork
authorfucus <fucus>
Thu, 1 Feb 2001 06:25:56 +0000 (06:25 +0000)
committerfucus <fucus>
Thu, 1 Feb 2001 06:25:56 +0000 (06:25 +0000)
wasn't re-reading appledouble header information from the disk
when it needed to do so. as a result, you could get zero-length resource
forks.

-a

etc/afpd/fork.c

index f0fda992cc16651bbce9178b8c129b7ea4a68c1e..d245b1c3cbccf14a5205965f2773802d70cc051a 100644 (file)
@@ -944,15 +944,12 @@ int flushfork( ofork )
     }
 
     if ( ad_hfileno( ofork->of_ad ) != -1 ) {
-        if (ofork->of_flags & AFPFORK_RSRC) {
-         len = ad_getentrylen(ofork->of_ad, ADEID_RFORK);
-         ad_refresh(ofork->of_ad);
-         if (len != ad_getentrylen(ofork->of_ad, ADEID_RFORK)) {
-           ad_setentrylen(ofork->of_ad, ADEID_RFORK, len);
-           doflush++;
-         }
-       }
 
+        /* read in the rfork length */
+       len = ad_getentrylen(ofork->of_ad, ADEID_RFORK);
+       ad_refresh(ofork->of_ad);
+
+       /* set the date if we're dirty */
         if ((ofork->of_flags & AFPFORK_DIRTY) &&
            (gettimeofday(&tv, NULL) == 0)) {
          ad_setdate(ofork->of_ad, AD_DATE_MODIFY|AD_DATE_UNIX, tv.tv_sec);
@@ -960,6 +957,15 @@ int flushfork( ofork )
          doflush++;
        }
 
+       /* if we're actually flushing this fork, make sure to set the
+        * length. otherwise, just use the stored length */
+        if ((ofork->of_flags & AFPFORK_RSRC) && 
+           (len != ad_getentrylen(ofork->of_ad, ADEID_RFORK))) {
+           ad_setentrylen(ofork->of_ad, ADEID_RFORK, len);
+           doflush++;
+       }
+
+
        /* flush the header. */
        if (doflush && (ad_flush(ofork->of_ad, ADFLAGS_HF) < 0)) 
          err = -1;