]> arthur.barton.de Git - netatalk.git/commitdiff
Mis
authorFrank Lahm <franklahm@googlemail.com>
Mon, 13 Dec 2010 21:26:33 +0000 (22:26 +0100)
committerFrank Lahm <franklahm@googlemail.com>
Mon, 13 Dec 2010 21:26:33 +0000 (22:26 +0100)
etc/afpd/volume.c
include/atalk/adouble.h
include/atalk/util.h
libatalk/adouble/ad_flush.c
libatalk/adouble/ad_open.c
libatalk/util/unix.c

index 9e9b904b53abb47f673cb141a938611349b27019..3775a816cd8ab79906aee3898c5c382203179230 100644 (file)
@@ -45,6 +45,7 @@ char *strchr (), *strrchr ();
 #include <atalk/logger.h>
 #include <atalk/vfs.h>
 #include <atalk/uuid.h>
+#include <atalk/ea.h>
 
 #ifdef CNID_DB
 #include <atalk/cnid.h>
@@ -151,12 +152,7 @@ typedef struct _special_folder {
 
 static const _special_folder special_folders[] = {
     {"Network Trash Folder",     1,  0777,  1},
-    {"Temporary Items",          1,  0777,  1},
     {".AppleDesktop",            1,  0777,  0},
-#if 0
-    {"TheFindByContentFolder",   0,     0,  1},
-    {"TheVolumeSettingsFolder",  0,     0,  1},
-#endif
     {NULL, 0, 0, 0}};
 
 /* Forward declarations */
index 3ce3f9d73de1c10c9d0a8bdcf8c4522be982579c..fe763a8f3ec1ca9e138e00e70f3ef5054c292157 100644 (file)
@@ -218,9 +218,6 @@ struct adouble {
 #define ADVOL_INVDOTS    (1 << 3) /* dot files (.DS_Store) are invisible) */
 #define ADVOL_NOADOUBLE  (1 << 4)
 
-extern uint32_t adv2_disk_eid[];
-#define DISK_EID(a) (adv2_disk_eid[a])
-
 /* lock flags */
 #define ADLOCK_CLR      (0)
 #define ADLOCK_RD       (1<<0)
@@ -365,6 +362,7 @@ extern int ad_excl_lock     (struct adouble * /*adp*/, const u_int32_t /*eid*/);
 #define ad_unlock ad_fcntl_unlock
 
 /* ad_open.c */
+extern uint32_t get_eid   (uint32_t eid);
 extern int ad_setfuid     (const uid_t );
 extern uid_t ad_getfuid   (void );
 extern char *ad_dir       (const char *);
index 9d61aaff71161c4c0b801f1226645d9e31a9bc61..ba55bc9b0f381d66089e9d35e10046143e984951 100644 (file)
@@ -141,6 +141,7 @@ extern int compare_ip(const struct sockaddr *sa1, const struct sockaddr *sa2);
  * unix.c
  *****************************************************************/
 
+extern const char *abspath(const char *name);
 extern const char *getcwdpath(void);
 extern char *stripped_slashes_basename(char *p);
 extern int lchdir(const char *dir);
index 09c663a31adca09d88f01a8565f8c7947b21946c..185339601c4c4a4b2bc688e73d968d45811c3adc 100644 (file)
 
 #include "ad_private.h"
 
+static const u_int32_t set_eid[] = {
+    0,1,2,3,4,5,6,7,8,
+    9,10,11,12,13,14,15,
+    AD_DEV, AD_INO, AD_SYN, AD_ID
+};
+
+#define EID_DISK(a) (set_eid[a])
+
 /*
  * Rebuild any header information that might have changed.
  */
@@ -66,7 +74,7 @@ int  ad_rebuild_adouble_header(struct adouble *ad)
         if ( ad->ad_eid[ eid ].ade_off == 0 ) {
             continue;
         }
-        temp = htonl( DISK_EID(eid) );
+        temp = htonl( EID_DISK(eid) );
         memcpy(buf, &temp, sizeof( temp ));
         buf += sizeof( temp );
 
index 1119f1ff9002ad1888b0ad4b7cb399bf66d4958d..283efc0a3e6a33be6d523381174ee8fb6629f7cb 100644 (file)
@@ -184,10 +184,21 @@ static const struct entry entry_order_ea[ADEID_NUM_EA + 1] = {
     {0, 0, 0}
 };
 
-uint32_t adv2_disk_eid[] = {
-    0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
-    AD_DEV, AD_INO, AD_SYN, AD_ID
-};
+uint32_t get_eid(uint32_t eid)
+{
+    if (eid <= 15)
+        return eid;
+    if (eid == AD_DEV)
+        return ADEID_PRIVDEV;
+    if (eid == AD_INO)
+        return ADEID_PRIVINO;
+    if (eid == AD_SYN)
+        return ADEID_PRIVSYN;
+    if (eid == AD_ID)
+        return ADEID_PRIVID;
+
+    return 0;
+}
 
 /* ----------------------------------- */
 static int new_ad_header(const char *path, struct adouble *ad, int adflags)
@@ -260,7 +271,7 @@ static void parse_entries(struct adouble *ad, char *buf, uint16_t nentries)
     /* now, read in the entry bits */
     for (; nentries > 0; nentries-- ) {
         memcpy(&eid, buf, sizeof( eid ));
-        eid = DISK_EID(ntohl( eid ));
+        eid = get_eid(ntohl(eid));
         buf += sizeof( eid );
         memcpy(&off, buf, sizeof( off ));
         off = ntohl( off );
@@ -306,6 +317,8 @@ static int ad_header_read(struct adouble *ad, struct stat *hst)
 
     memcpy(&ad->ad_magic, buf, sizeof( ad->ad_magic ));
     memcpy(&ad->ad_version, buf + ADEDOFF_VERSION, sizeof( ad->ad_version ));
+    ad->ad_magic = ntohl( ad->ad_magic );
+    ad->ad_version = ntohl( ad->ad_version );
 
     if ((ad->ad_magic != AD_MAGIC) || (ad->ad_version != AD_VERSION2)) {
         LOG(log_error, logtype_default, "ad_open: can't parse AppleDouble header.");
@@ -333,6 +346,7 @@ static int ad_header_read(struct adouble *ad, struct stat *hst)
     /* figure out all of the entry offsets and lengths. if we aren't
      * able to read a resource fork entry, bail. */
     nentries = len / AD_ENTRY_LEN;
+    LOG(log_error, logtype_default, "nentries: %d", nentries);
     parse_entries(ad, buf, nentries);
     if (!ad_getentryoff(ad, ADEID_RFORK)
         || (ad_getentryoff(ad, ADEID_RFORK) > sizeof(ad->ad_data))
@@ -354,6 +368,7 @@ static int ad_header_read(struct adouble *ad, struct stat *hst)
             return 1; /* fail silently */
         }
     }
+
     ad->ad_rlen = hst->st_size - ad_getentryoff(ad, ADEID_RFORK);
 
     return 0;
@@ -962,6 +977,88 @@ void ad_init(struct adouble *ad, int flags, int options)
     ad->ad_rlen = 0;
 }
 
+static const char *adflags2logstr(int adflags)
+{
+    int first = 1;
+    static char buf[64];
+
+    buf[0] = 0;
+
+    if (adflags & ADFLAGS_DF) {
+        strlcat(buf, "DF", 64);
+        first = 0;
+    }
+    if (adflags & ADFLAGS_RF) {
+        if (!first)
+            strlcat(buf, "|", 64);
+        strlcat(buf, "RF", 64);
+        first = 0;
+    }
+    if (adflags & ADFLAGS_HF) {
+        if (!first)
+            strlcat(buf, "|", 64);
+        strlcat(buf, "HF", 64);
+        first = 0;
+    }
+    if (adflags & ADFLAGS_NOHF) {
+        if (!first)
+            strlcat(buf, "|", 64);
+        strlcat(buf, "NOHF", 64);
+        first = 0;
+    }
+    if (adflags & ADFLAGS_DIR) {
+        if (!first)
+            strlcat(buf, "|", 64);
+        strlcat(buf, "DIR", 64);
+        first = 0;
+    }
+    if (adflags & ADFLAGS_RDONLY) {
+        if (!first)
+            strlcat(buf, "|", 64);
+        strlcat(buf, "RDONLY", 64);
+        first = 0;
+    }
+    if (adflags & ADFLAGS_OPENFORKS) {
+        if (!first)
+            strlcat(buf, "|", 64);
+        strlcat(buf, "OF", 64);
+        first = 0;
+    }
+    return buf;
+}
+
+static const char *oflags2logstr(int oflags)
+{
+    int first = 1;
+    static char buf[64];
+
+    buf[0] = 0;
+
+    if (oflags & O_RDONLY) {
+        strlcat(buf, "O_RDONLY", 64);
+        first = 0;
+    }
+    if (oflags & O_RDWR) {
+        if (!first)
+            strlcat(buf, "|", 64);
+        strlcat(buf, "O_RDWR", 64);
+        first = 0;
+    }
+    if (oflags & O_CREAT) {
+        if (!first)
+            strlcat(buf, "|", 64);
+        strlcat(buf, "O_CREAT", 64);
+        first = 0;
+    }
+    if (oflags & O_EXCL) {
+        if (!first)
+            strlcat(buf, "|", 64);
+        strlcat(buf, "O_EXCL", 64);
+        first = 0;
+    }
+    return buf;
+}
+
 /*!
  * Open data-, metadata(header)- or ressource fork
  *
@@ -978,7 +1075,6 @@ void ad_init(struct adouble *ad, int flags, int options)
  *                ADFLAGS_HF:        open header (metadata) file \n
  *                ADFLAGS_NOHF:      it's not an error if header file couldn't be created \n
  *                ADFLAGS_DIR:       if path is a directory you MUST or ADFLAGS_DIR to adflags \n
- *                ADFLAGS_NOADOUBLE: dont create adouble files if not necessary \n
  *                ADFLAGS_RDONLY:    open read only \n
  *                ADFLAGS_OPENFORKS: check for open forks from other processes
  *
@@ -999,6 +1095,9 @@ void ad_init(struct adouble *ad, int flags, int options)
  */
 int ad_open(const char *path, int adflags, int oflags, int mode, struct adouble  *ad)
 {
+    LOG(log_debug, logtype_default, "ad_open(\"%s\", %s, %s, 0%04o)",
+        abspath(path), adflags2logstr(adflags), oflags2logstr(oflags), mode);
+
     if (ad->ad_inited != AD_INITED) {
         ad->ad_inited = AD_INITED;
         ad->ad_refcount = 1;
index 9e71fcb4b71a3b7fd53479c4cebc2cef7cb3bb30..ab0c25e53cf7669f90409a20b50ebf308c71b223 100644 (file)
@@ -57,6 +57,31 @@ const char *getcwdpath(void)
         return strerror(errno);
 }
 
+/*!
+ * Make argument path absoulte
+ *
+ * @returns pointer to path or pointer to error messages on error
+ */
+const char *abspath(const char *name)
+{
+    static char buf[MAXPATHLEN + 1];
+    char *p;
+    int n;
+
+    if (name[0] == '/')
+        return name;
+
+    if ((p = getcwd(buf, MAXPATHLEN)) == NULL)
+        return strerror(errno);
+
+    n = strlen(buf);
+    if (buf[n-1] != '/')
+        buf[n++] = '/';
+        
+    strlcpy(buf + n, name, MAXPATHLEN - n);
+    return buf;
+}
+
 /*!
  * Takes a buffer with a path, strips slashs, returns basename
  *