]> arthur.barton.de Git - netatalk.git/commitdiff
keep in each volume structure the last struct dir used, they are often reused
authordidg <didg>
Fri, 13 Nov 2009 00:27:35 +0000 (00:27 +0000)
committerdidg <didg>
Fri, 13 Nov 2009 00:27:35 +0000 (00:27 +0000)
etc/afpd/directory.c
etc/afpd/directory.h
etc/afpd/fork.h
etc/afpd/ofork.c
etc/afpd/volume.c
include/atalk/volume.h

index cd64283f43aea797385df38722f6ee1a9d7e8be2..d2e6519e37dd0b696bc9b667c52a3a3b07289e07 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: directory.c,v 1.116 2009-10-29 11:35:58 didg Exp $
+ * $Id: directory.c,v 1.117 2009-11-13 00:27:35 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -90,12 +90,26 @@ static struct dir rootpar  = { SENTINEL, SENTINEL, NULL, 0,
  * frPutAway:   4    home directory ID
  */
 
+static struct dir *
+vol_tree_root(const struct vol *vol, u_int32_t did)
+{
+  struct dir *dir;
+    
+  if (vol->v_curdir && vol->v_curdir->d_did == did) {
+        dir = vol->v_curdir;
+  }
+  else {
+        dir = vol->v_root;
+  }
+  return dir;
+}
+
 /*
  * redid did assignment for directories. now we use red-black trees.
  * how exciting.
  */
 struct dir *
-            dirsearch(const struct vol *vol, u_int32_t did)
+dirsearch(const struct vol *vol, u_int32_t did)
 {
     struct dir *dir;
 
@@ -111,16 +125,8 @@ struct dir *
         rootpar.d_child = vol->v_dir;
         return( &rootpar );
     }
-#if 0
-    /* XXX would be nice to check against curdir but we need to keep its volume  */
-    if (vol->curdir && curdir->d_did == did) {
-        dir = curdir;
-    }
-    else {
-        dir = vol->v_root;
-    }
-#endif
-    dir = vol->v_root;
+    
+    dir = vol_tree_root(vol, did);
 
     afp_errno = AFPERR_NOOBJ;
     while ( dir != SENTINEL ) {
@@ -425,7 +431,7 @@ static void dir_hash_del(const struct vol *vol, struct dir *dir)
  * different. actually, it has to worry about a bunch of things that
  * insertion doesn't care about. */
 
-static void dir_remove( const struct vol *vol _U_, struct dir  *dir)
+static void dir_remove( struct vol *vol, struct dir *dir)
 {
 #ifdef REMOVE_NODES
     struct ofork *of, *last;
@@ -437,6 +443,7 @@ static void dir_remove( const struct vol *vol _U_, struct dir       *dir)
         
     /* i'm not sure if it really helps to delete stuff. */
     dir_hash_del(vol, dir);
+    vol->v_curdir = NULL;
 #ifndef REMOVE_NODES 
     dirfreename(dir);
     dir->d_m_name = NULL;
@@ -542,7 +549,7 @@ static void dir_remove( const struct vol *vol _U_, struct dir       *dir)
  * process. It's fixable within afpd if fnctl_lock, doable with smb and
  * next to impossible for nfs and local filesystem access.
  */
-static void dir_invalidate( const struct vol *vol, struct dir *dir)
+static void dir_invalidate( struct vol *vol, struct dir *dir)
 {
     if (curdir == dir) {
         /* v_root can't be deleted */
@@ -560,7 +567,7 @@ static struct dir *dir_insert(const struct vol *vol, struct dir *dir)
 {
     struct dir *pdir;
 
-    pdir = vol->v_root;
+    pdir = vol_tree_root(vol, dir->d_did);
     while (pdir->d_did != dir->d_did ) {
         if ( pdir->d_did > dir->d_did ) {
             if ( pdir->d_left == SENTINEL ) {
@@ -1104,7 +1111,7 @@ dirhash(void)
 }
 
 /* ------------------ */
-static struct path *invalidate (const struct vol *vol, struct dir *dir, struct path *ret)
+static struct path *invalidate (struct vol *vol, struct dir *dir, struct path *ret)
 {
     /* it's tricky:
        movecwd failed some of dir path are not there anymore.
@@ -1418,7 +1425,7 @@ noucsfallback:
 /*
  * Move curdir to dir, with a possible chdir()
  */
-int movecwd(const struct vol *vol, struct dir *dir)
+int movecwd(struct vol *vol, struct dir *dir)
 {
     char path[MAXPATHLEN + 1];
     struct dir *d;
@@ -1474,7 +1481,7 @@ int movecwd(const struct vol *vol, struct dir *dir)
         }
         return( -1 );
     }
-    curdir = dir;
+    vol->v_curdir = curdir = dir;
     return( 0 );
 }
 
@@ -1883,7 +1890,7 @@ static int set_dir_errors(struct path *path, const char *where, int err)
 }
  
 /* ------------------ */
-int setdirparams(const struct vol *vol, 
+int setdirparams(struct vol *vol, 
                  struct path *path, u_int16_t d_bitmap, char *buf )
 {
     struct maccess     ma;
@@ -2493,7 +2500,7 @@ int renamedir(const struct vol *vol, char *src, char *dst,
 }
 
 /* delete an empty directory */
-int deletecurdir(const struct vol *vol)
+int deletecurdir(struct vol *vol)
 {
     struct dirent *de;
     struct stat st;
index b330140501304b3a429db2c1c5ea7e17d1428e43..0a699a2a8e7d8accbe8c8f26b6a44fcf2ae4148c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: directory.h,v 1.32 2009-10-22 12:35:38 franklahm Exp $
+ * $Id: directory.h,v 1.33 2009-11-13 00:27:35 didg Exp $
  *
  * Copyright (c) 1990,1991 Regents of The University of Michigan.
  * All Rights Reserved.
@@ -123,15 +123,15 @@ extern struct dir       *dirsearch_byname (const struct vol *, struct dir *,char
 extern struct dir      *adddir (struct vol *, struct dir *, 
                                                struct path *);
 
-extern int              movecwd (const struct vol *, struct dir *);
-extern int              deletecurdir (const struct vol *);
+extern int              movecwd (struct vol *, struct dir *);
+extern int              deletecurdir (struct vol *);
 extern struct path      *cname (struct vol *, struct dir *,
                              char **);
 extern mode_t           mtoumode (struct maccess *);
 extern void             utommode (struct stat *, struct maccess *);
 extern int getdirparams (const struct vol *, u_int16_t, struct path *,
                                  struct dir *, char *, size_t *);
-extern int setdirparams (const struct vol *, struct path *, u_int16_t, char *);
+extern int setdirparams (struct vol *, struct path *, u_int16_t, char *);
 extern int renamedir (const struct vol *, char *, char *, struct dir *,
                               struct dir *, char *);
 extern int path_error (struct path *, int error);
index fdc4a1eeb817d77526fedc5f5a53d783a5aa725e..36576b39c8d9f60cac14c27c93a24c9953662e9b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: fork.h,v 1.16 2009-10-15 10:43:13 didg Exp $
+ * $Id: fork.h,v 1.17 2009-11-13 00:27:35 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -71,7 +71,7 @@ extern int          of_rename    (const struct vol *,
 extern int          of_flush     (const struct vol *);
 extern void         of_pforkdesc (FILE *);
 extern int          of_stat      (struct path *);
-extern int          of_statdir   (const struct vol *vol, struct path *);
+extern int          of_statdir   (struct vol *vol, struct path *);
 extern int          of_closefork (struct ofork *ofork);
 extern void         of_closevol  (const struct vol *vol);
 extern struct adouble *of_ad     (const struct vol *, struct path *, struct adouble *);
index 90bf4ff6306b6702c958803018946e6f3d43f6ca..9bb6966770effcd6f627ff91746e7990d3f96224 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ofork.c,v 1.29 2009-11-06 03:51:54 didg Exp $
+ * $Id: ofork.c,v 1.30 2009-11-13 00:27:36 didg Exp $
  *
  * Copyright (c) 1996 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -295,7 +295,7 @@ int ret;
    stat(".") works even if "." is deleted thus
    we have to stat ../name because we want to know if it's there
 */
-int of_statdir  (const struct vol *vol, struct path *path)
+int of_statdir  (struct vol *vol, struct path *path)
 {
 static char pathname[ MAXPATHLEN + 1] = "../";
 int ret;
index 90f8d633a5604badf92d5eb90878d60b39da339d..81981e01c6604a3d219459f88cad896491f94f62 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: volume.c,v 1.101 2009-11-09 01:36:18 didg Exp $
+ * $Id: volume.c,v 1.102 2009-11-13 00:27:36 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -1950,6 +1950,7 @@ int afp_openvol(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t
     dir->d_color = DIRTREE_COLOR_BLACK; /* root node is black */
     dir->d_m_name_ucs2 = strdup_w(volume->v_name);
     volume->v_dir = volume->v_root = dir;
+    volume->v_curdir = NULL;
     volume->v_hash = dirhash();
 
     curdir = volume->v_dir;
index ffcdb43ddad616c7c7dd46fc0f3a54dc9216f7a5..2184816ccfad910b1702c0555f87a4cfcab4a2e8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: volume.h,v 1.5 2009-11-09 01:36:18 didg Exp $
+ * $Id: volume.h,v 1.6 2009-11-13 00:27:38 didg Exp $
  *
  * Copyright (c) 1990,1994 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -28,6 +28,8 @@ struct vol {
     char               *v_path;
     
     struct dir         *v_dir, *v_root;
+    struct dir                 *v_curdir;      /* cache */
+
     hash_t             *v_hash;
     time_t             v_mtime;