hnode_t *hn;
static_bstring uname = {-1, len, (unsigned char *)name};
- AFP_ASSERT(vol);
- AFP_ASSERT(dir);
- AFP_ASSERT(name);
- AFP_ASSERT(len == strlen(name));
- AFP_ASSERT(len < 256);
+ AFP_ASSERT(vol);
+ AFP_ASSERT(dir);
+ AFP_ASSERT(name);
+ AFP_ASSERT(len == strlen(name));
+ AFP_ASSERT(len < 256);
+
+ LOG(log_debug, logtype_afpd, "dircache_search_by_name(did:%u, \"%s\")",
+ ntohl(dir->d_did), name);
if (dir->d_did != DIRDID_ROOT_PARENT) {
key.d_vid = vol->v_vid;
}
if (cdir)
- LOG(log_debug, logtype_afpd, "dircache(pdid:%u, did:%u, '%s'): {found in cache}",
- ntohl(dir->d_did), ntohl(cdir->d_did), cfrombstring(cdir->d_fullpath));
+ LOG(log_debug, logtype_afpd, "dircache(did:%u, '%s'): {found in cache}",
+ ntohl(dir->d_did), name);
else
- LOG(log_debug, logtype_afpd, "dircache(pdid:%u,'%s/%s'): {not in cache}",
- ntohl(dir->d_did), cfrombstring(dir->d_fullpath), name);
+ LOG(log_debug, logtype_afpd, "dircache(did:%u,'%s'): {not in cache}",
+ ntohl(dir->d_did), name);
return cdir;
}
AFP_ASSERT(dir);
AFP_ASSERT(ntohl(dir->d_pdid) >= 2);
AFP_ASSERT(ntohl(dir->d_did) >= CNID_START);
- AFP_ASSERT(dir->d_fullpath);
AFP_ASSERT(dir->d_u_name);
AFP_ASSERT(dir->d_vid);
AFP_ASSERT(dircache->hash_nodecount <= dircache_maxsize);
queue_count++;
}
- LOG(log_debug, logtype_afpd, "dircache(did:%u,'%s'): {added}", ntohl(dir->d_did), cfrombstring(dir->d_fullpath));
+ LOG(log_debug, logtype_afpd, "dircache(did:%u,'%s'): {added}", ntohl(dir->d_did), cfrombstring(dir->d_u_name));
AFP_ASSERT(queue_count == index_didname->hash_nodecount
&& queue_count == dircache->hash_nodecount);
struct stat *st;
struct maccess ma;
-
upath = path->u_name;
st = &path->st;
-
data = buf;
if ( ((bitmap & ( (1 << FILPBIT_FINFO)|(1 << FILPBIT_LNAME)|(1 <<FILPBIT_PDINFO) ) ) && !path->m_name)
|| (bitmap & ( (1 << FILPBIT_LNAME) ) && utf8_encoding()) /* FIXME should be m_name utf8 filename */
|| (bitmap & (1 << FILPBIT_FNUM))) {
- if (!path->id)
- id = get_id(vol, adp, st, dir->d_did, upath, strlen(upath));
- else
+ if (!path->id) {
+ struct dir *cachedfile;
+ int len = strlen(upath);
+ if (cachedfile = dircache_search_by_name(vol, dir, upath, len))
+ id = cachedfile->d_did;
+ else {
+ id = get_id(vol, adp, st, dir->d_did, upath, len);
+
+ /* Add it to the cache */
+ LOG(log_debug, logtype_afpd, "getmetadata: caching: did:%u, \"%s\", cnid:%u",
+ ntohl(dir->d_did), upath, ntohl(id));
+
+ /* Get macname from unixname first */
+ if (path->m_name == NULL) {
+ if ((path->m_name = utompath(vol, upath, id, utf8_encoding())) == NULL) {
+ LOG(log_error, logtype_afpd, "getmetadata: utompath error");
+ exit(EXITERR_SYS);
+ }
+ }
+
+ if ((cachedfile = dir_new(path->m_name, upath, vol, dir->d_did, id, NULL)) == NULL) {
+ LOG(log_error, logtype_afpd, "getmetadata: error from dir_new");
+ exit(EXITERR_SYS);
+ }
+ if ((dircache_add(cachedfile)) != 0) {
+ LOG(log_error, logtype_afpd, "getmetadata: fatal dircache error");
+ exit(EXITERR_SYS);
+ }
+ }
+ } else {
id = path->id;
+ }
+
if (id == CNID_INVALID)
return afp_errno;
+
if (!path->m_name) {
path->m_name = utompath(vol, upath, id, utf8_encoding());
}