]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/fork.c
Fixes
[netatalk.git] / etc / afpd / fork.c
index 6eff75a8f163960cf7cfdcdb975c2acbd251657d..ea92e06b36975f4eacd6c0cb468b47d58c2f68b1 100644 (file)
@@ -266,9 +266,6 @@ int afp_openfork(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf, si
         return  AFPERR_BADTYPE;
     }
 
-    LOG(log_debug, logtype_afpd, "afp_openfork(\"%s\", %s)",
-        fullpathname(s_path->u_name), (fork & OPENFORK_RSCS) ? "RSRC" : "DATA");
-
     /* stat() data fork st is set because it's not a dir */
     switch ( s_path->st_errno ) {
     case 0:
@@ -311,6 +308,8 @@ int afp_openfork(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf, si
     } else {
         eid = ADEID_RFORK;
         adflags = ADFLAGS_RF | ADFLAGS_HF;
+        if (!(access & OPENACC_WR))
+            adflags |= ADFLAGS_NORF;
     }
 
     path = s_path->m_name;
@@ -319,6 +318,11 @@ int afp_openfork(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf, si
         return( AFPERR_NFILE );
     }
 
+    LOG(log_debug, logtype_afpd, "afp_openfork(\"%s\", %s, %s)",
+        fullpathname(s_path->u_name),
+        (fork & OPENFORK_RSCS) ? "data" : "reso",
+        !(access & OPENACC_WR) ? "O_RDONLY" : "O_RDWR");
+
     ret = AFPERR_NOOBJ;
     if (access & OPENACC_WR) {
         /* try opening in read-write mode */
@@ -366,7 +370,6 @@ int afp_openfork(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf, si
     } else {
         /* try opening in read-only mode */
         ret = AFPERR_NOOBJ;
-        /* we need w access for setting deny mode fcntl excl lock */
         if (ad_open(ofork->of_ad, upath, adflags | ADFLAGS_RDONLY | ADFLAGS_SETSHRMD) < 0) {
             switch ( errno ) {
             case EROFS:
@@ -444,9 +447,8 @@ int afp_openfork(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf, si
 
     /* don't try to lock non-existent rforks. */
     if ((eid == ADEID_DFORK)
-        || (ad_meta_fileno(ofork->of_ad) != -1)
-        || (vol->v_adouble & AD_VERSION_EA)) { /* META */
-
+        || (ad_reso_fileno(ofork->of_ad) != -1)
+        || (ofork->of_ad->ad_vers == AD_VERSION_EA)) {
         ret = fork_setmode(ofork->of_ad, eid, access, ofrefnum);
         /* can we access the fork? */
         if (ret < 0) {
@@ -561,7 +563,7 @@ int afp_setforkparams(AFPObj *obj _U_, char *ibuf, size_t ibuflen, char *rbuf _U
         if (err < 0)
             goto afp_setfork_err;
     } else if (bitmap == (1<<FILPBIT_RFLEN) || bitmap == (1<<FILPBIT_EXTRFLEN)) {
-        ad_refresh( ofork->of_ad );
+        ad_refresh(NULL, ofork->of_ad );
 
         st_size = ad_size(ofork->of_ad, eid);
         err = -2;
@@ -1067,7 +1069,7 @@ int flushfork(struct ofork *ofork)
          (ofork->of_flags & AFPFORK_RSRC)) {
 
         /* read in the rfork length */
-        ad_refresh(ofork->of_ad);
+        ad_refresh(NULL, ofork->of_ad);
 
         /* set the date if we're dirty */
         if ((ofork->of_flags & AFPFORK_DIRTY) && !gettimeofday(&tv, NULL)) {
@@ -1358,7 +1360,7 @@ int afp_getforkparams(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbu
     }
 
     if (AD_META_OPEN(ofork->of_ad)) {
-        if ( ad_refresh( ofork->of_ad ) < 0 ) {
+        if ( ad_refresh(NULL, ofork->of_ad ) < 0 ) {
             LOG(log_error, logtype_afpd, "getforkparams(%s): ad_refresh: %s", of_name(ofork), strerror(errno) );
             return( AFPERR_PARAM );
         }