]> arthur.barton.de Git - netatalk.git/commitdiff
Correct handling of adflags NOXX for adouble:v2
authorFrank Lahm <franklahm@googlemail.com>
Sun, 5 Feb 2012 11:42:26 +0000 (12:42 +0100)
committerFrank Lahm <franklahm@googlemail.com>
Sun, 5 Feb 2012 11:42:26 +0000 (12:42 +0100)
etc/afpd/fork.c
libatalk/adouble/ad_open.c

index 3bfbbf639ee8f3093178aaae048dcc05c5f0f297..9bef65b036f5dd0b5a453f40cffd4631ddc74819 100644 (file)
@@ -304,10 +304,10 @@ int afp_openfork(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf, si
 
     if ( fork == OPENFORK_DATA ) {
         eid = ADEID_DFORK;
-        adflags = ADFLAGS_DF | ADFLAGS_HF ;
+        adflags = ADFLAGS_DF | ADFLAGS_HF | ADFLAGS_NOHF;
     } else {
         eid = ADEID_RFORK;
-        adflags = ADFLAGS_RF | ADFLAGS_HF;
+        adflags = ADFLAGS_RF | ADFLAGS_HF | ADFLAGS_NOHF;
         if (!(access & OPENACC_WR))
             adflags |= ADFLAGS_NORF;
     }
@@ -320,7 +320,7 @@ int afp_openfork(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf, si
 
     LOG(log_debug, logtype_afpd, "afp_openfork(\"%s\", %s, %s)",
         fullpathname(s_path->u_name),
-        (fork & OPENFORK_RSCS) ? "data" : "reso",
+        (fork == OPENFORK_DATA) ? "data" : "reso",
         !(access & OPENACC_WR) ? "O_RDONLY" : "O_RDWR");
 
     ret = AFPERR_NOOBJ;
index 6b6aa6a4378c6de6e398c918195dfa74253dbcb4..f7048aa054c1979c13ae352b2157977d124699d6 100644 (file)
@@ -1147,13 +1147,18 @@ EC_CLEANUP:
     EC_EXIT;
 }
 
-/*!
- * Open ressource fork
- *
- * Only for adouble:ea, a nullop otherwise because adouble:v2 has the ressource fork as part
- * of the adouble file which is openend by ADFLAGS_HF.
- */
-static int ad_open_rf(const char *path, int adflags, int mode, struct adouble *ad)
+static int ad_open_rf_v2(const char *path, int adflags, int mode, struct adouble *ad)
+{
+    /*
+     * 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;
+}
+
+static int ad_open_rf_ea(const char *path, int adflags, int mode, struct adouble *ad)
 {
     EC_INIT;
     int oflags;
@@ -1165,9 +1170,6 @@ static int ad_open_rf(const char *path, int adflags, int mode, struct adouble *a
     struct stat st;
 #endif
 
-    if (ad->ad_vers != AD_VERSION_EA)
-        return 0;
-
     LOG(log_debug, logtype_default, "ad_open_rf(\"%s\"): BEGIN", fullpathname(path));
 
     oflags = O_NOFOLLOW | (ad2openflags(ad, ADFLAGS_RF, adflags) & ~O_CREAT);
@@ -1253,6 +1255,28 @@ EC_CLEANUP:
     EC_EXIT;
 }
 
+/*!
+ * Open ressource fork
+ */
+static int ad_open_rf(const char *path, int adflags, int mode, struct adouble *ad)
+{
+    int ret = 0;
+
+    switch (ad->ad_vers) {
+    case AD_VERSION2:
+        ret = ad_open_rf_v2(path, adflags, mode, ad);
+        break;
+    case AD_VERSION_EA:
+        ret = ad_open_rf_ea(path, adflags, mode, ad);
+        break;
+    default:
+        ret = -1;
+        break;
+    }
+
+    return ret;
+}
+
 /***********************************************************************************
  * API functions
  ********************************************************************************* */