X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=etc%2Fafpd%2Fenumerate.c;h=1659fb77ff89cc5fbff15513fe5915600b718ae4;hb=4054f4b3c85ecab060dafd46c0d3632cadbb5803;hp=b8a403bd4fd958a9b5de04d9c6cca5ccb3ea5bc2;hpb=e2b3be108f5d8757324c98d63df42b0c11835f82;p=netatalk.git diff --git a/etc/afpd/enumerate.c b/etc/afpd/enumerate.c index b8a403bd..1659fb77 100644 --- a/etc/afpd/enumerate.c +++ b/etc/afpd/enumerate.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -154,7 +155,7 @@ for_each_dirent(const struct vol *vol, char *name, dir_loop fn, void *data) macnamelength(1) + macname(31) + utf8(4) + utf8namelen(2) + utf8name(255) + oddpadding(1) */ -#define REPLY_PARAM_MAXLEN (4 + 104 + 1 + MACFILELEN + 4 + 2 + 255 + 1) +#define REPLY_PARAM_MAXLEN (4 + 104 + 1 + MACFILELEN + 4 + 2 + UTF8FILELEN_EARLY + 1) /* ----------------------------- */ static int enumerate(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, @@ -268,10 +269,8 @@ static int enumerate(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, return path_error(o_path, AFPERR_NODIR ); } - LOG(log_debug, logtype_afpd, "enumerate(vid:%u, did:%u, cwddid:%u, cwd:'%s', name:'%s', f/d:%04x/%04x, rc:%u, i:%u, max:%u)", - ntohs(vid), ntohl(did), ntohl(curdir->d_did), - cfrombstring(curdir->d_fullpath), o_path->u_name, - fbitmap, dbitmap, reqcnt, sindex, maxsz); + LOG(log_debug, logtype_afpd, "enumerate(\"%s/%s\", f/d:%04x/%04x, rc:%u, i:%u, max:%u)", + getcwdpath(), o_path->u_name, fbitmap, dbitmap, reqcnt, sindex, maxsz); data = rbuf + 3 * sizeof( u_int16_t ); sz = 3 * sizeof( u_int16_t ); /* fbitmap, dbitmap, reqcount */ @@ -285,11 +284,12 @@ static int enumerate(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, sd.sd_last = sd.sd_buf; /* if dir was in the cache we don't have the inode */ if (( !o_path->st_valid && lstat( ".", &o_path->st ) < 0 ) || - (ret = for_each_dirent(vol, ".", enumerate_loop, (void *)&sd)) < 0) + (ret = for_each_dirent(vol, ".", enumerate_loop, (void *)&sd)) < 0) { + LOG(log_error, logtype_afpd, "enumerate: loop error: %s (%d)", strerror(errno), errno); switch (errno) { case EACCES: - return AFPERR_ACCESS; + return AFPERR_ACCESS; case ENOTDIR: return AFPERR_BADTYPE; case ENOMEM: @@ -375,7 +375,7 @@ static int enumerate(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, continue; } int len = strlen(s_path.u_name); - if ((dir = dircache_search_by_name(vol, curdir, s_path.u_name, len)) == NULL) { + if ((dir = dircache_search_by_name(vol, curdir, s_path.u_name, len, s_path.st.st_ctime)) == NULL) { if ((dir = dir_add(vol, curdir, &s_path, len)) == NULL) { LOG(log_error, logtype_afpd, "enumerate(vid:%u, did:%u, name:'%s'): error adding dir: '%s'", ntohs(vid), ntohl(did), o_path->u_name, s_path.u_name); @@ -389,6 +389,7 @@ static int enumerate(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, if ( fbitmap == 0 ) { continue; } + /* files are added to the dircache in getfilparams() -> getmetadata() */ if (AFP_OK != ( ret = getfilparams(vol, fbitmap, &s_path, curdir, data + header , &esz )) ) { return( ret );