]> arthur.barton.de Git - netatalk.git/commitdiff
Remove v_realpath from struct dir, normalize v_path instead
authorfranklahm <franklahm>
Fri, 19 Feb 2010 10:51:59 +0000 (10:51 +0000)
committerfranklahm <franklahm>
Fri, 19 Feb 2010 10:51:59 +0000 (10:51 +0000)
etc/afpd/catsearch.c
etc/afpd/directory.c
etc/afpd/filedir.c
etc/afpd/volume.c
include/atalk/volume.h

index 662a876613a87db5419c50473e082fb1123040de..58aab8e18360bf74e40f0bb7969b2c44cc9d0b51 100644 (file)
@@ -497,7 +497,7 @@ static int catsearch(struct vol *vol, struct dir *dir,
        int result = AFP_OK;
        int ccr;
     struct path path;
-       char *vpath = vol->v_realpath;
+       char *vpath = vol->v_path;
        char *rrbuf = rbuf;
     time_t start_time;
     int num_rounds = NUM_ROUNDS;
index 7c7eae72cd9920a3d1876c016500f25fcf8a2bfb..438cc43f63ed707866a0dbb92a5228db42508765 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: directory.c,v 1.133 2010-02-19 01:26:03 didg Exp $
+ * $Id: directory.c,v 1.134 2010-02-19 10:51:59 franklahm Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -1642,14 +1642,14 @@ int movecwd(struct vol *vol, struct dir *dir)
         memcpy( p, u, n );
     }
     if ( d != curdir ) {
-        n = strlen( vol->v_realpath );
+        n = strlen( vol->v_path );
         if (p -n -1 < path) {
             afp_errno = AFPERR_PARAM;
             return -1;
         }
         *--p = '/';
         p -= n;
-        memcpy( p, vol->v_realpath, n );
+        memcpy( p, vol->v_path, n );
     }
     if ( (ret = lchdir( p )) != 0 ) {
         LOG(log_debug, logtype_afpd, "movecwd('%s'): ret:%d, %u/%s", p, ret, errno, strerror(errno));
index 407e48a102f95b2a91024b31ca1bec8d3cb940a3..203622f45c7dac1005fc29612af88a3b145df6fb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: filedir.c,v 1.71 2010-02-19 01:26:03 didg Exp $
+ * $Id: filedir.c,v 1.72 2010-02-19 10:51:59 franklahm Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -588,13 +588,13 @@ char *absupath(const struct vol *vol, struct dir *dir, char *u)
         p -= len;
         memcpy( p, u, len );
     }
-    len = strlen( vol->v_realpath );
+    len = strlen( vol->v_path );
     if (p -len -1 < path) {
         return NULL;
     }
     *--p = '/';
     p -= len;
-    memcpy( p, vol->v_realpath, len );
+    memcpy( p, vol->v_path, len );
 
     return( p );
 }
index 5dfb3b6640de5c1e6ed88434573917e643c28639..9d2e64f3d0b39651e12dcdade6de644d2313b5fa 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: volume.c,v 1.118 2010-02-19 01:26:03 didg Exp $
+ * $Id: volume.c,v 1.119 2010-02-19 10:51:59 franklahm Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -1252,7 +1252,6 @@ static void volume_free(struct vol *vol)
     free(vol->v_macname);
     vol->v_macname = NULL;
     free(vol->v_path);
-    free(vol->v_realpath);
     free(vol->v_password);
     free(vol->v_veto);
     free(vol->v_volcodepage);
@@ -1993,7 +1992,27 @@ int afp_openvol(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t
         LOG(log_error, logtype_afpd, "afp_openvol(%s): volume pathlen too long", volume->v_path);
         return AFPERR_MISC;
     }
-    volume->v_realpath = strdup(path);
+
+    /* Normalize volume path */
+#ifdef REALPATH_TAKES_NULL
+    if ((volume->v_path = realpath(path, NULL)) == NULL)
+        return AFPERR_MISC;
+#else
+    if ((volume->v_path = malloc(MAXPATHLEN+1)) == NULL)
+        return AFPERR_MISC;
+    if (realpath(path, volume->v_path) == NULL) {
+        free(volume->v_path);
+        return AFPERR_MISC;
+    }
+    /* Safe some memory */
+    char *tmp;
+    if ((tmp = strdup(volume->v_path)) == NULL) {
+        free(volume->v_path);
+        return AFPERR_MISC;
+    } 
+    free(volume->v_path);
+    volume->v_path = tmp;
+#endif
 
     if (volume_codepage(obj, volume) < 0) {
         ret = AFPERR_MISC;
index 3c47bf06b52e89276574517b7cd41e3e9d7b30da..e2458ec4c9a077eb02ab9f5cc52609f082d06f89 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: volume.h,v 1.14 2010-02-19 01:26:03 didg Exp $
+ * $Id: volume.h,v 1.15 2010-02-19 10:51:59 franklahm Exp $
  *
  * Copyright (c) 1990,1994 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -25,7 +25,6 @@ struct vol {
     u_int16_t       v_vid;
     int             v_flags;
     char            *v_path;
-    char            *v_realpath; /* canonical path */
     struct dir      *v_dir, *v_root;
     struct dir      *v_curdir;  /* cache */
     hash_t          *v_hash;