From a3b4a854d1cc667392f8ee6ec197cd500d06aed0 Mon Sep 17 00:00:00 2001 From: fucus Date: Thu, 1 Feb 2001 06:25:56 +0000 Subject: [PATCH] this fixes a problem exposed by the os x appleshare client. flushfork 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 | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/etc/afpd/fork.c b/etc/afpd/fork.c index f0fda992..d245b1c3 100644 --- a/etc/afpd/fork.c +++ b/etc/afpd/fork.c @@ -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; -- 2.39.2