]> arthur.barton.de Git - netatalk.git/commitdiff
Fixes
authorFrank Lahm <franklahm@googlemail.com>
Tue, 29 Jun 2010 05:25:52 +0000 (07:25 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Tue, 29 Jun 2010 05:25:52 +0000 (07:25 +0200)
etc/afpd/dircache.c
etc/afpd/enumerate.c
etc/afpd/file.c

index 5906036e0a4b84d479d0046198a3d2917f641334..d6efdce2caf7f963ae99fc45685a9f56b57a0777 100644 (file)
@@ -271,11 +271,14 @@ struct dir *dircache_search_by_name(const struct vol *vol, const struct dir *dir
     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;
@@ -287,11 +290,11 @@ struct dir *dircache_search_by_name(const struct vol *vol, const struct dir *dir
     }
 
     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;
 }
@@ -310,7 +313,6 @@ int dircache_add(struct dir *dir)
    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);
@@ -339,7 +341,7 @@ int dircache_add(struct dir *dir)
         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);
index daa83a693a2557e82c106839f5d2dcc278046f2e..b8a403bd4fd958a9b5de04d9c6cca5ccb3ea5bc2 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id: enumerate.c,v 1.49 2010/02/10 14:05:37 franklahm Exp $
- *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
  */
index b277938c2fdd247e7da583c7f1ca4fa795ae3894..51a33e8c30ba0bd2e823b856e9f331bd484053d4 100644 (file)
@@ -298,21 +298,49 @@ int getmetadata(struct vol *vol,
     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());
         }