]> arthur.barton.de Git - netatalk.git/commitdiff
Fixes
authorFrank Lahm <franklahm@googlemail.com>
Sat, 21 Jan 2012 18:03:02 +0000 (19:03 +0100)
committerFrank Lahm <franklahm@googlemail.com>
Sat, 21 Jan 2012 18:03:02 +0000 (19:03 +0100)
etc/afpd/file.c
include/atalk/adouble.h
libatalk/adouble/ad_open.c

index 69c3388b5473c3b6a08d3a97ae9a49ee9df4ac61..51de7562330399b5545d6f6d20034d8ef9da4ceb 100644 (file)
@@ -1619,7 +1619,7 @@ int deletefile(const struct vol *vol, int dirfd, char *file, int checkAttrib)
  
     /* try to open both forks at once */
     adflags = ADFLAGS_DF;
-    if (ad_openat(&ad, dirfd, file, adflags | ADFLAGS_HF | ADFLAGS_NOHF | ADFLAGS_RDONLY) < 0 ) {
+    if (ad_openat(&ad, dirfd, file, adflags | ADFLAGS_RF | ADFLAGS_NORF | ADFLAGS_RDONLY) < 0 ) {
         switch (errno) {
         case ENOENT:
             err = AFPERR_NOOBJ;
@@ -1638,8 +1638,8 @@ int deletefile(const struct vol *vol, int dirfd, char *file, int checkAttrib)
         adp = &ad;
     }
 
-    if ( adp && ad_reso_fileno( adp ) != -1 ) { /* there's a resource fork */
-        adflags |= ADFLAGS_HF;
+    if ( adp && AD_RSRC_OPEN(adp) != -1 ) { /* there's a resource fork */
+        adflags |= ADFLAGS_RF;
         /* FIXME we have a pb here because we want to know if a file is open 
          * there's a 'priority inversion' if you can't open the ressource fork RW
          * you can delete it if it's open because you can't get a write lock.
index 118dd613a4ff18ceb1644be2c41acee3195e0b3b..50857df0d5112286294a40f8c4a57f48285f6f89 100644 (file)
@@ -227,7 +227,8 @@ struct adouble {
 #define ADFLAGS_RF        (1<<1)
 #define ADFLAGS_HF        (1<<2)
 #define ADFLAGS_DIR       (1<<3)
-#define ADFLAGS_NOHF      (1<<4)  /* not an error if no ressource fork */
+#define ADFLAGS_NOHF      (1<<4)  /* not an error if no metadata fork */
+#define ADFLAGS_NORF      (1<<4)  /* not an error if no ressource fork */
 #define ADFLAGS_CHECK_OF  (1<<6)  /* check for open forks from us and other afpd's */
 #define ADFLAGS_SETSHRMD  (1<<7)  /* setting share mode must be done with excl fcnt lock,
                                      which implies that the file must be openend rw.
index be149077f833713eef978f1d780657c4afbc0342..93372a8611ba2b9a2113590ecd4afc6c6555bfdf 100644 (file)
@@ -1152,9 +1152,13 @@ EC_CLEANUP:
             ad_reso_fileno(ad) = -1;
             ad->ad_rfp->adf_refcount = 0;
         }
-        int err = errno;
-        (void)ad_close(ad, closeflags);
-        errno = err;
+        if (adflags & ADFLAGS_NORF) {
+            ret = 0;
+        } else {
+            int err = errno;
+            (void)ad_close(ad, closeflags);
+            errno = err;
+        }
         ad->ad_rlen = 0;
     }
 
@@ -1408,7 +1412,8 @@ void ad_init(struct adouble *ad, const struct vol * restrict vol)
  *                         ADFLAGS_DF:        open data fork
  *                         ADFLAGS_RF:        open ressource fork
  *                         ADFLAGS_HF:        open header (metadata) file
- *                         ADFLAGS_NOHF:      it's not an error if header file couldn't be created
+ *                         ADFLAGS_NOHF:      it's not an error if header file couldn't be opened
+ *                         ADFLAGS_NORF:      it's not an error if reso fork couldn't be opened
  *                         ADFLAGS_DIR:       if path is a directory you MUST or ADFLAGS_DIR to adflags
  *
  *                       Access mode for the forks:
@@ -1444,6 +1449,12 @@ int ad_open(struct adouble *ad, const char *path, int adflags, ...)
         /* Checking for open forks requires sharemode lock support (ie RDWR instead of RDONLY) */
         adflags |= ADFLAGS_SETSHRMD;
 
+    if ((ad->ad_vers == AD_VERSION2) && (adflags & ADFLAGS_RF)) {
+        adflags |= ADFLAGS_HF;
+        if (adflags & ADFLAGS_NORF)
+            adflags |= ADFLAGS_NOHF;
+    }
+    
     if ((ad->ad_vers == AD_VERSION_EA) && (adflags & ADFLAGS_SETSHRMD))
         /* adouble:ea sets sharemode locks on the datafork */
         adflags |= ADFLAGS_DF;