if (cdir)
LOG(log_debug, logtype_afpd, "dircache(did:%u): {cached: path:'%s'}",
- ntohl(did), cdir->d_u_name);
+ ntohl(did), cfrombstring(cdir->d_u_name));
else
LOG(log_debug, logtype_afpd, "dircache(did:%u): {not in cache}", ntohl(did));
break;
dir = (struct dir *)n->data;
fprintf(dump, "%05u: vid:%u, pdid:%6u, did:%6u, path:%s, locked:%3s, oforks:%s\n",
- i, ntohs(dir->d_vid), ntohl(dir->d_pdid), ntohl(dir->d_did), dir->d_u_name,
+ i, ntohs(dir->d_vid), ntohl(dir->d_pdid), ntohl(dir->d_did),
+ cfrombstring(dir->d_u_name),
(dir->d_flags & DIRF_CACHELOCK) ? "yes" : "no",
dir->d_ofork ? "yes" : "no");
n = n->next;
*
* Resolve a DID, allocate a struct dir for it
* 1. Check for special CNIDs 0 (invalid), 1 and 2.
- * 2. Check if the DID is in the cache.
+ * 2a. Check if the DID is in the cache.
+ * 2b. Check if it's really a dir (d_fullpath != NULL) because we cache files too.
* 3. If it's not in the cache resolve it via the database.
* 4. Build complete server-side path to the dir.
* 5. Check if it exists and is a directory.
}
/* Search the cache */
- if ((ret = dircache_search_by_did(vol, did)) != NULL) { /* 2 */
+ if ((ret = dircache_search_by_did(vol, did)) != NULL) { /* 2a */
+ if (ret->d_fullpath == NULL) { /* 2b */
+ afp_errno = AFPERR_BADTYPE;
+ return NULL;
+ }
if (lstat(cfrombstring(ret->d_fullpath), &st) != 0) {
LOG(log_debug, logtype_afpd, "dirlookup(did: %u) {lstat: %s}", ntohl(did), strerror(errno));
switch (errno) {
* @param vol (r) pointer to struct vol
* @param pdid (r) Parent CNID
* @param did (r) CNID
- * @param fullpath (r) Full unix path to dir
+ * @param fullpath (r) Full unix path to dir or NULL for files
*
* @returns pointer to new struct dir or NULL on error
*