]> arthur.barton.de Git - netatalk.git/commitdiff
Check for cached files in dirlookup
authorFrank Lahm <franklahm@googlemail.com>
Tue, 6 Jul 2010 09:00:35 +0000 (11:00 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Tue, 6 Jul 2010 09:00:35 +0000 (11:00 +0200)
etc/afpd/dircache.c
etc/afpd/directory.c

index f816ea72271a12922f377d8ec76362f29eb60261..edec2237bc53159fa75aad6b62fb61e07b033bcc 100644 (file)
@@ -248,7 +248,7 @@ struct dir *dircache_search_by_did(const struct vol *vol, cnid_t did)
 
     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));
 
@@ -473,7 +473,8 @@ void dircache_dump(void)
             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;
index 90c014c82efb9afc3f8e06912bf0891b27aa41fc..b658ad1d56995528333101dbc032bb41c3f00fe5 100644 (file)
@@ -428,7 +428,8 @@ int get_afp_errno(const int param)
  *
  * 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.
@@ -470,7 +471,11 @@ struct dir *dirlookup(const struct vol *vol, cnid_t did)
     }
 
     /* 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) {
@@ -677,7 +682,7 @@ int caseenumerate(const struct vol *vol, struct path *path, struct dir *dir)
  * @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
  *