X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=etc%2Fafpd%2Fextattrs.c;h=a26c801a230c2163f22118595fa8688a115b8894;hb=f758a8c097b044293fa2fe58f8a7fcc2d8909b55;hp=2e850e5015cc61576c00ea56dc29c42261d6a831;hpb=5a29c4a057d9ec4db9f0d1292006e7869c3103f4;p=netatalk.git diff --git a/etc/afpd/extattrs.c b/etc/afpd/extattrs.c index 2e850e50..a26c801a 100644 --- a/etc/afpd/extattrs.c +++ b/etc/afpd/extattrs.c @@ -1,5 +1,5 @@ /* - $Id: extattrs.c,v 1.7 2009-10-15 15:35:05 franklahm Exp $ + $Id: extattrs.c,v 1.9 2009-10-22 12:35:38 franklahm Exp $ Copyright (c) 2009 Frank Lahm This program is free software; you can redistribute it and/or modify @@ -74,8 +74,8 @@ static void hexdump(void *m, size_t l) { */ int afp_listextattr(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t *rbuflen) { - int count, ret, oflag = 0, adflags = 0; - uint16_t vid, bitmap; + int ret, oflag = 0, adflags = 0; + uint16_t vid, bitmap, uint16; uint32_t did, maxreply, tmpattr; struct vol *vol; struct dir *dir; @@ -84,7 +84,10 @@ int afp_listextattr(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, siz struct adouble ad, *adp = NULL; struct ofork *of; char *uname, *FinderInfo; - static int buf_valid = 0, attrbuflen = 0; + char emptyFinderInfo[32] = { 0 }; + + static int buf_valid = 0; + static size_t attrbuflen = 0; *rbuflen = 0; ibuf += 2; @@ -163,21 +166,24 @@ int afp_listextattr(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, siz } FinderInfo = ad_entry(adp, ADEID_FINDERI); + #ifdef DEBUG - LOG(log_debug9, logtype_afpd, "afp_listextattr(%s): FinderInfo:", uname); + LOG(log_maxdebug, logtype_afpd, "afp_listextattr(%s): FinderInfo:", uname); hexdump( FinderInfo, 32); #endif - /* Now scan FinderInfo if its all 0 */ - count = 32; - while (count--) { - if (*FinderInfo++) { - /* FinderInfo contains some non 0 bytes -> include "com.apple.FinderInfo" */ - strcpy(attrnamebuf, ea_finderinfo); - attrbuflen += strlen(ea_finderinfo) + 1; - LOG(log_debug7, logtype_afpd, "afp_listextattr(%s): sending com.apple.FinderInfo", uname); - break; - } + if ((adflags & ADFLAGS_DIR)) { + /* set default view */ + uint16 = htons(FINDERINFO_CLOSEDVIEW); + memcpy(emptyFinderInfo + FINDERINFO_FRVIEWOFF, &uint16, 2); + } + + /* Check if FinderInfo equals default and empty FinderInfo*/ + if ((memcmp(FinderInfo, emptyFinderInfo, 32)) != 0) { + /* FinderInfo contains some non 0 bytes -> include "com.apple.FinderInfo" */ + strcpy(attrnamebuf, ea_finderinfo); + attrbuflen += strlen(ea_finderinfo) + 1; + LOG(log_debug7, logtype_afpd, "afp_listextattr(%s): sending com.apple.FinderInfo", uname); } /* Now check for Ressource fork and add virtual EA "com.apple.ResourceFork" if size > 0 */