+off_t ad_reso_size(const char *path, int adflags, struct adouble *ad)
+{
+ EC_INIT;
+ struct stat st;
+ off_t rlen;
+
+ if (adflags & ADFLAGS_DIR)
+ EC_FAIL;
+
+ LOG(log_debug, logtype_ad, "ad_reso_size(\"%s\"): BEGIN", path);
+
+#ifdef HAVE_EAFD
+ ssize_t easz;
+
+ if (ad && ad_reso_fileno(ad) != -1) {
+ EC_NEG1( fstat(ad_reso_fileno(ad), &st) );
+ rlen = st.st_size;
+ } else if (ad && ad_meta_fileno(ad) != -1) {
+ EC_NEG1( (rlen = sys_fgetxattr(ad_meta_fileno(ad), AD_EA_RESO, NULL, 0)) );
+ } else {
+ EC_NEG1( (rlen = sys_lgetxattr(path, AD_EA_RESO, NULL, 0)) );
+ }
+
+#else
+ const char *rfpath;
+ EC_NULL_LOG( rfpath = ad_path_osx(path, adflags));
+ EC_ZERO( lstat(rfpath, &st));
+ if (st.st_size > ADEDOFF_RFORK_OSX)
+ rlen = st.st_size - ADEDOFF_RFORK_OSX;
+ else
+ rlen = 0;
+#endif
+
+ LOG(log_debug, logtype_ad, "ad_reso_size(\"%s\"): size: %zd", path, rlen);
+
+EC_CLEANUP:
+ if (ret != 0)
+ rlen = 0;
+ return rlen;
+}
+
+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
+ */
+
+ LOG(log_debug, logtype_ad, "ad_open_rf_v2(\"%s\"): BEGIN", fullpathname(path));
+
+ if (!AD_META_OPEN(ad) && !(adflags & (ADFLAGS_NORF | ADFLAGS_RDONLY)))
+ 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)