]> arthur.barton.de Git - netatalk.git/commitdiff
remove a linear dir search, we already have the info.
authordidg <didg>
Mon, 14 Apr 2003 18:03:48 +0000 (18:03 +0000)
committerdidg <didg>
Mon, 14 Apr 2003 18:03:48 +0000 (18:03 +0000)
etc/afpd/directory.c
etc/afpd/directory.h
etc/afpd/filedir.c

index 8c45316dd061607431f0e295cda6cb005a4715b6..6d8b21d7449c85a5bac33fdc9c1c1f32136be924 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: directory.c,v 1.65 2003-03-18 00:20:27 didg Exp $
+ * $Id: directory.c,v 1.66 2003-04-14 18:03:48 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -125,9 +125,12 @@ u_int32_t  did;
 #ifdef ATACC
 int path_isadir(struct path *o_path)
 {
+    return o_path->dir != NULL;
+#if 0
     return o_path->m_name == '\0' || /* we are in a it */
            !o_path->st_valid ||      /* in cache but we can't chdir in it */ 
            (!o_path->st_errno && S_ISDIR(o_path->st.st_mode)); /* not in cache an can't chdir */
+#endif
 }
 #endif
 
@@ -562,6 +565,7 @@ struct dir  *dir;
 struct path *path;
 {
     path->u_name = mtoupath(vol, path->m_name, utf8_encoding() );
+    path->dir = NULL;
 
     if ( path->u_name == NULL) {
         afp_errno = AFPERR_PARAM;
@@ -579,6 +583,7 @@ struct path *path;
         return( NULL );
     }
 
+    path->dir = dir;
     if ( movecwd( vol, dir ) < 0 ) {
         return( NULL );
     }
@@ -995,6 +1000,7 @@ char       **cpath;
     ret.m_name = path;
     ret.st_errno = 0;
     ret.st_valid = 0;
+    ret.dir = NULL;
     for ( ;; ) {
         if ( len == 0 ) {
             if (movecwd( vol, dir ) < 0 ) {
@@ -1011,6 +1017,7 @@ char      **cpath;
                    }
                    ret.m_name = dir->d_m_name;
                    ret.u_name = dir->d_u_name;
+                   ret.dir = dir;
                    return &ret;
                } else if (afp_errno == AFPERR_NOOBJ) {
                     if ( movecwd( vol, dir->d_parent ) < 0 ) {
@@ -1035,6 +1042,7 @@ char      **cpath;
             }
             if (*path == '\0') {
                ret.u_name = ".";
+               ret.dir = dir;
             }               
             return &ret;
         }
index c7cfc6ac11b84843545eb67bd06ead75be7f252f..429ae5c3c957d3ef1f0b4fee360d0a74e12f0345 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: directory.h,v 1.11 2003-03-09 19:55:34 didg Exp $
+ * $Id: directory.h,v 1.12 2003-04-14 18:03:49 didg Exp $
  *
  * Copyright (c) 1990,1991 Regents of The University of Michigan.
  * All Rights Reserved.
@@ -60,11 +60,11 @@ struct dir {
 };
 
 struct path {
-    int         m_type;
-    char       *m_name;             /* mac name */
+    int         m_type;             /* mac name type (long name, unicode */
+    char       *m_name;            /* mac name */
     char        *u_name;            /* unix name */
-
-    int         st_valid;
+    struct dir  *dir;               /* */
+    int         st_valid;           /* does st_errno and st set */
     int         st_errno;
     struct stat st;
 };
@@ -72,9 +72,12 @@ struct path {
 #ifndef ATACC
 static __inline__ int path_isadir(struct path *o_path)
 {
+    return o_path->dir != NULL;
+#if 0
     return o_path->m_name == '\0' || /* we are in a it */
            !o_path->st_valid ||      /* in cache but we can't chdir in it */ 
            (!o_path->st_errno && S_ISDIR(o_path->st.st_mode)); /* not in cache an can't chdir */
+#endif
 }
 #else
 extern int path_isadir(struct path *o_path);
index 65044f0fd678c088887f5c14d84291c30173e080..db8821e2545e92632796ffe8eb95ce69698df29f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: filedir.c,v 1.43 2003-03-15 01:34:35 didg Exp $
+ * $Id: filedir.c,v 1.44 2003-04-14 18:03:49 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -197,7 +197,7 @@ int         ibuflen, *rbuflen;
     buflen = 0;
     if (S_ISDIR(st->st_mode)) {
         if (dbitmap) {
-            dir = dirsearch_byname(curdir, s_path->u_name);
+            dir = s_path->dir;
             if (!dir) 
                 return AFPERR_NOOBJ;
 
@@ -500,12 +500,8 @@ int                ibuflen, *rbuflen;
     if ( *path->m_name != '\0' ) {
         strcpy(oldname, path->m_name); /* an extra copy for of_rename */
         if (isdir) {
-            /* curdir parent dir, need to move sdir back 
-             * FIXME search by unix name or mac name?
-            */
-            sdir = dirsearch_byname(curdir, path->u_name);
-            if (!sdir)
-                return AFPERR_NOOBJ;           
+            /* curdir parent dir, need to move sdir back */
+            sdir = path->dir;
         }
     }
     else {
@@ -711,9 +707,7 @@ int         ibuflen, *rbuflen;
     isdir = path_isadir(path);
     if ( *path->m_name != '\0' ) {
         if (isdir) {
-            sdir = dirsearch_byname(curdir, path->u_name);
-            if (!sdir)
-                return AFPERR_NOOBJ;           
+            sdir = path->dir;
        }
         strcpy(oldname, path->m_name); /* an extra copy for of_rename */
     } else {