X-Git-Url: https://arthur.barton.de/gitweb/?p=netatalk.git;a=blobdiff_plain;f=libatalk%2Fadouble%2Fad_flush.c;h=fc95412c0d5fd03511e83de0c1352f35f1e91551;hp=cb0be93c024203e613ddff5c52239ace5f19528c;hb=a5f965283b1646cdcc8a8006a3f3bef0c3e572f4;hpb=1a59f639265e6fc11385a40dcef2a70a53b54954 diff --git a/libatalk/adouble/ad_flush.c b/libatalk/adouble/ad_flush.c index cb0be93c..fc95412c 100644 --- a/libatalk/adouble/ad_flush.c +++ b/libatalk/adouble/ad_flush.c @@ -59,7 +59,6 @@ int ad_rebuild_adouble_header_v2(struct adouble *ad) uint32_t temp; uint16_t nent; char *buf, *nentp; - int len; LOG(log_debug, logtype_ad, "ad_rebuild_adouble_header_v2"); @@ -105,7 +104,6 @@ int ad_rebuild_adouble_header_ea(struct adouble *ad) uint32_t temp; uint16_t nent; char *buf, *nentp; - int len; LOG(log_debug, logtype_ad, "ad_rebuild_adouble_header_ea"); @@ -148,12 +146,11 @@ int ad_rebuild_adouble_header_ea(struct adouble *ad) /*! * Prepare adbuf buffer from struct adouble for writing on disk */ -static int ad_rebuild_adouble_header_osx(struct adouble *ad, char *adbuf) +int ad_rebuild_adouble_header_osx(struct adouble *ad, char *adbuf) { uint32_t temp; uint16_t nent; char *buf; - int len; LOG(log_debug, logtype_ad, "ad_rebuild_adouble_header_osx"); @@ -292,7 +289,8 @@ static int ad_flush_hf(struct adouble *ad) if (ad->ad_adflags & ADFLAGS_DIR) { EC_NEG1_LOG( cwd = open(".", O_RDONLY) ); EC_NEG1_LOG( fchdir(ad_data_fileno(ad)) ); - EC_ZERO_LOG( sys_lsetxattr(".", AD_EA_META, ad->ad_data, AD_DATASZ_EA, 0) ); + EC_ZERO_LOGSTR( sys_lsetxattr(".", AD_EA_META, ad->ad_data, AD_DATASZ_EA, 0), + "sys_lsetxattr(\"%s\"): %s", fullpathname(".") ,strerror(errno)); EC_NEG1_LOG( fchdir(cwd) ); EC_NEG1_LOG( close(cwd) ); cwd = -1; @@ -431,6 +429,17 @@ int ad_close(struct adouble *ad, int adflags) } if (adflags & ADFLAGS_RF) { + /* HF is automatically opened when opening an RF, close it. */ + if ((ad->ad_vers == AD_VERSION2) && (ad_meta_fileno(ad) != -1)) { + if (ad->ad_meta_refcount) + ad->ad_meta_refcount--; + if (!(--ad->ad_mdp->adf_refcount)) { + if (close( ad_meta_fileno(ad)) < 0) + err = -1; + ad_meta_fileno(ad) = -1; + } + } + if (ad->ad_reso_refcount) if (--ad->ad_reso_refcount == 0) adf_lock_free(ad->ad_rfp);