]> arthur.barton.de Git - netatalk.git/blobdiff - libatalk/adouble/ad_write.c
Fix adouble refcounting
[netatalk.git] / libatalk / adouble / ad_write.c
index 97667d476afdf2b27bbbf21fcb878d8d53a78c51..6e8a0190ca0d4dca75f4453d8acb738d37154d4f 100644 (file)
@@ -55,13 +55,12 @@ ssize_t ad_write(struct adouble *ad, uint32_t eid, off_t off, int end, const cha
     size_t roundup;
     off_t    r_off;
 
-    if (ad_data_fileno(ad) == -2) {
-        /* It's a symlink */
+    if (ad_data_fileno(ad) == AD_SYMLINK) {
         errno = EACCES;
         return -1;
     }
 
-    LOG(log_debug, logtype_default, "ad_write: off: %ju, size: %zu, eabuflen: %zu",
+    LOG(log_debug, logtype_ad, "ad_write: off: %ju, size: %zu, eabuflen: %zu",
         (uintmax_t)off, buflen, ad->ad_rlen);
     
     if ( eid == ADEID_DFORK ) {
@@ -164,21 +163,18 @@ int ad_rtruncate( struct adouble *ad, const off_t size)
 {
     EC_INIT;
 
-    if (ad->ad_vers == AD_VERSION_EA && size == 0) {
-#if HAVE_EAFD
-        EC_NEG1( sys_lremovexattr(of_name(ofork), AD_EA_RESO) );
-#else
+#ifndef HAVE_EAFD
+    if (ad->ad_vers == AD_VERSION_EA && size == 0)
         EC_NEG1( unlink(ad->ad_ops->ad_path(ad->ad_name, 0)) );
+    else
 #endif
-    }
-
-    EC_NEG1( sys_ftruncate(ad_reso_fileno(ad), size + ad->ad_eid[ ADEID_RFORK ].ade_off) );
+        EC_NEG1( sys_ftruncate(ad_reso_fileno(ad), size + ad->ad_eid[ ADEID_RFORK ].ade_off) );
 
 EC_CLEANUP:
     if (ret == 0)
         ad->ad_rlen = size;    
     else
-        LOG(log_error, logtype_default, "ad_rtruncate(\"%s\"): %s",
+        LOG(log_error, logtype_ad, "ad_rtruncate(\"%s\"): %s",
             fullpathname(ad->ad_name), strerror(errno));
     EC_EXIT;
 }
@@ -186,7 +182,7 @@ EC_CLEANUP:
 int ad_dtruncate(struct adouble *ad, const off_t size)
 {
     if (sys_ftruncate(ad_data_fileno(ad), size) < 0) {
-        LOG(log_error, logtype_default, "sys_ftruncate(fd: %d): %s",
+        LOG(log_error, logtype_ad, "sys_ftruncate(fd: %d): %s",
             ad_data_fileno(ad), strerror(errno));
         return -1;
     }