}
add->ad_rlen = ads->ad_rlen;
- if ((ads->ad_vers == AD_VERSION2) && (add->ad_vers = AD_VERSION_EA)
- || (ads->ad_vers == AD_VERSION_EA) && (add->ad_vers = AD_VERSION2)) {
+ if (((ads->ad_vers == AD_VERSION2) && (add->ad_vers == AD_VERSION_EA))
+ || ((ads->ad_vers == AD_VERSION_EA) && (add->ad_vers == AD_VERSION2))) {
cnid_t id;
memcpy(&id, ad_entry(add, ADEID_PRIVID), sizeof(cnid_t));
id = htonl(id);
break;
}
- if (ret != 0)
+ if (ret == 0)
+ ad->ad_meta_refcount++;
+ else
ret = ad_error(ad, adflags);
return ret;
static int ad_open_rf_v2(const char *path, int adflags, int mode, struct adouble *ad)
{
+ EC_INIT;
+
/*
* ad_open_hf_v2() does the work, but if it failed and adflags are ADFLAGS_NOHF | ADFLAGS_RF
* ad_open_hf_v2() didn't give an error, but we're supposed to return a reso fork fd
*/
- if (!AD_RSRC_OPEN(ad) && !(adflags & ADFLAGS_NORF))
- return -1;
- return 0;
+
+ LOG(log_debug, logtype_ad, "ad_open_rf_v2(\"%s\"): BEGIN", fullpathname(path));
+
+ if (!AD_META_OPEN(ad) && !(adflags & ADFLAGS_NORF))
+ EC_FAIL;
+ if (AD_META_OPEN(ad))
+ ad->ad_reso_refcount++;
+
+EC_CLEANUP:
+ LOG(log_debug, logtype_ad, "ad_open_rf_v2(\"%s\"): END: %d", fullpathname(path), ret);
+ EC_EXIT;
}
static int ad_open_rf_ea(const char *path, int adflags, int mode, struct adouble *ad)
opened = 1;
ad->ad_rfp->adf_refcount = 1;
ad->ad_rfp->adf_flags = oflags;
+ ad->ad_reso_refcount++;
#ifndef HAVE_EAFD
EC_ZERO_LOG( fstat(ad_reso_fileno(ad), &st) );
if (opened && (ad_reso_fileno(ad) != -1)) {
close(ad_reso_fileno(ad));
ad_reso_fileno(ad) = -1;
+ ad->ad_reso_refcount--;
ad->ad_rfp->adf_refcount = 0;
}
if (adflags & ADFLAGS_NORF) {
}
if (adflags & ADFLAGS_HF) {
- ad->ad_meta_refcount++;
if (ad_open_hf(path, adflags, mode, ad) != 0) {
- ad->ad_meta_refcount--;
EC_FAIL;
}
}
if (adflags & ADFLAGS_RF) {
- ad->ad_reso_refcount++;
if (ad_open_rf(path, adflags, mode, ad) != 0) {
- ad->ad_reso_refcount--;
EC_FAIL;
}
}