From: Frank Lahm Date: Mon, 13 Dec 2010 21:26:33 +0000 (+0100) Subject: Mis X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=commitdiff_plain;h=739921959ed258477df74c55d44c57ee913e0f02 Mis --- diff --git a/etc/afpd/volume.c b/etc/afpd/volume.c index 9e9b904b..3775a816 100644 --- a/etc/afpd/volume.c +++ b/etc/afpd/volume.c @@ -45,6 +45,7 @@ char *strchr (), *strrchr (); #include #include #include +#include #ifdef CNID_DB #include @@ -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 */ diff --git a/include/atalk/adouble.h b/include/atalk/adouble.h index 3ce3f9d7..fe763a8f 100644 --- a/include/atalk/adouble.h +++ b/include/atalk/adouble.h @@ -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 *); diff --git a/include/atalk/util.h b/include/atalk/util.h index 9d61aaff..ba55bc9b 100644 --- a/include/atalk/util.h +++ b/include/atalk/util.h @@ -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); diff --git a/libatalk/adouble/ad_flush.c b/libatalk/adouble/ad_flush.c index 09c663a3..18533960 100644 --- a/libatalk/adouble/ad_flush.c +++ b/libatalk/adouble/ad_flush.c @@ -37,6 +37,14 @@ #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 ); diff --git a/libatalk/adouble/ad_open.c b/libatalk/adouble/ad_open.c index 1119f1ff..283efc0a 100644 --- a/libatalk/adouble/ad_open.c +++ b/libatalk/adouble/ad_open.c @@ -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; diff --git a/libatalk/util/unix.c b/libatalk/util/unix.c index 9e71fcb4..ab0c25e5 100644 --- a/libatalk/util/unix.c +++ b/libatalk/util/unix.c @@ -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 *