]> arthur.barton.de Git - netatalk.git/blobdiff - libatalk/adouble/ad_open.c
Solaris fixes
[netatalk.git] / libatalk / adouble / ad_open.c
index d8e2f0445a9a6be1300b8db8e07160bd550a2905..4b78d467359d522d16550f264e2fe179cf31b51e 100644 (file)
 #define ADEDOFF_RFORK_V2     (ADEDOFF_PRIVID + ADEDLEN_PRIVID)
 
 /* ad:ea */
-#define ADEDOFF_FINDERI_EA   (AD_HEADER_LEN + ADEID_NUM_EA * AD_ENTRY_LEN)
-#define ADEDOFF_COMMENT_EA   (ADEDOFF_FINDERI_EA + ADEDLEN_FINDERI)
+#define ADEDOFF_FINDERI_EA    (AD_HEADER_LEN + ADEID_NUM_EA * AD_ENTRY_LEN)
+#define ADEDOFF_COMMENT_EA    (ADEDOFF_FINDERI_EA + ADEDLEN_FINDERI)
 #define ADEDOFF_FILEDATESI_EA (ADEDOFF_COMMENT_EA + ADEDLEN_COMMENT)
-#define ADEDOFF_AFPFILEI_EA  (ADEDOFF_FILEDATESI_EA + ADEDLEN_FILEDATESI)
+#define ADEDOFF_AFPFILEI_EA   (ADEDOFF_FILEDATESI_EA + ADEDLEN_FILEDATESI)
+#define ADEDOFF_PRIVID_EA     (ADEDOFF_AFPFILEI_EA + ADEDLEN_AFPFILEI)
 
 /* this is to prevent changing timezones from causing problems with
    localtime volumes. the screw-up is 30 years. we use a delta of 5 years */
@@ -162,7 +163,7 @@ static const struct entry entry_order_ea[ADEID_NUM_EA + 1] = {
     {ADEID_COMMENT,    ADEDOFF_COMMENT_EA,    ADEDLEN_INIT},
     {ADEID_FILEDATESI, ADEDOFF_FILEDATESI_EA, ADEDLEN_FILEDATESI},
     {ADEID_AFPFILEI,   ADEDOFF_AFPFILEI_EA,   ADEDLEN_AFPFILEI},
-    {ADEID_PRIVID,     ADEDOFF_PRIVID,        ADEDLEN_INIT},
+    {ADEID_PRIVID,     ADEDOFF_PRIVID_EA,     ADEDLEN_INIT},
     {0, 0, 0}
 };
 
@@ -937,6 +938,10 @@ static int ad_open_hf_ea(const char *path, int adflags, int mode, struct adouble
 
     oflags = O_NOFOLLOW | (ad2openflags(adflags) & ~(O_CREAT | O_TRUNC));
 
+    if (ad_meta_fileno(ad) == -2)
+        /* symlink */
+        EC_EXIT;
+
     if (ad_meta_fileno(ad) != -1) {
         /* the file is already open, but we want write access: */
         if ((oflags & O_RDWR) &&
@@ -956,7 +961,7 @@ static int ad_open_hf_ea(const char *path, int adflags, int mode, struct adouble
                 /* For directories we open the directory RDONYL so we can later fchdir()  */
                 oflags = (oflags & ~O_RDWR) | O_RDONLY;
             LOG(log_debug, logtype_default, "ad_open_hf_ea(\"%s\"): opening base file for meta adouble EA", path);
-            EC_NEG1(ad_meta_fileno(ad) = open(path, oflags));
+            EC_NEG1_LOG(ad_meta_fileno(ad) = open(path, oflags));
             opened = 1;
             ad->ad_mdp->adf_flags = oflags;
         }
@@ -965,6 +970,7 @@ static int ad_open_hf_ea(const char *path, int adflags, int mode, struct adouble
     /* Read the adouble header in and parse it.*/
     if (ad->ad_ops->ad_header_read(path, ad, NULL) != 0) {
         if (!(adflags & ADFLAGS_CREATE)) {
+            LOG(log_error, logtype_default, "ad_open_hf_ea(\"%s\"): can't read metadata EA", path);
             errno = ENOENT;
             EC_FAIL;
         }
@@ -1045,7 +1051,7 @@ static int ad_reso_size(const char *path, int adflags, struct adouble *ad)
         EC_NEG1( eafd = sys_getxattrfd(path, AD_EA_RESO, O_RDONLY) );
         opened = 1;
     }
-    EC_NEG1( rlen = fstat(eafd, &st) );
+    EC_NEG1( fstat(eafd, &st) );
     ad->ad_rlen = st.st_size;
 #else
     const char *rfpath;
@@ -1108,11 +1114,11 @@ static int ad_open_rf(const char *path, int adflags, int mode, struct adouble *a
         goto EC_CLEANUP;
     }
 #ifdef HAVE_EAFD
-    if ((ad_reso_fileno(ad) = sys_getxattrfd(path, oflags)) == -1) {
+    if ((ad_reso_fileno(ad) = sys_getxattrfd(path, AD_EA_RESO, oflags)) == -1) {
         if (!(adflags & ADFLAGS_CREATE))
             EC_FAIL;
         oflags |= O_CREAT;
-        EC_NEG1_LOG( ad_reso_fileno(ad) = sys_getxattrfd(path, oflags, 0666) ); 
+        EC_NEG1_LOG( ad_reso_fileno(ad) = sys_getxattrfd(path, AD_EA_RESO, oflags, 0666) ); 
     }
 #else
     EC_NULL_LOG( rfpath = ad->ad_ops->ad_path(path, adflags) );
@@ -1594,6 +1600,7 @@ int ad_refresh(const char *path, struct adouble *ad)
             // TODO: read meta EA
         }
 
+#if 0
         if (AD_RSRC_OPEN(ad)) {
             if (ad_reso_fileno(ad) == -1)
                 return -1;
@@ -1602,6 +1609,7 @@ int ad_refresh(const char *path, struct adouble *ad)
                 return -1;
             ad->ad_rlen = len;
         }
+#endif
 #else
         if (AD_META_OPEN(ad)) {
             if (ad_data_fileno(ad) == -1)