]> arthur.barton.de Git - netatalk.git/commitdiff
Fix for not working dirname demangling
authorfranklahm <franklahm>
Mon, 1 Feb 2010 14:25:45 +0000 (14:25 +0000)
committerfranklahm <franklahm>
Mon, 1 Feb 2010 14:25:45 +0000 (14:25 +0000)
etc/afpd/directory.c
etc/afpd/mangle.c

index ef736f1c45d14857d522ce0431e8a3ac81991356..ad62f77b4b83d5df9d884ea27296f1c448a5d4f8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: directory.c,v 1.131.2.2 2010-02-01 12:59:09 franklahm Exp $
+ * $Id: directory.c,v 1.131.2.3 2010-02-01 14:25:45 franklahm Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -53,6 +53,7 @@ extern void addir_inherit_acl(const struct vol *vol);
  * o setdirparams doesn't change parent mdate anymore
  * o catsearch doesn't work, see FIXMEs in catsearch.c
  * o curdir per volume caching is gone
+ * o directory offspring count calculation probably broken
  */
 
 
@@ -282,8 +283,6 @@ static int cname_mtouname(const struct vol *vol, const struct dir *dir, struct p
     char *t;
     cnid_t fileid;
 
-    LOG(log_maxdebug, logtype_afpd, "cname_mtouname('%s', toUTF8:%u)", ret->m_name, toUTF8);
-
     if (afp_version >= 30) {
         if (toUTF8) {
             if (dir->d_did == DIRDID_ROOT_PARENT) {
@@ -308,6 +307,9 @@ static int cname_mtouname(const struct vol *vol, const struct dir *dir, struct p
 
         /* check for OS X mangled filename :( */
         t = demangle_osx(vol, ret->m_name, dir->d_did, &fileid);
+        LOG(log_maxdebug, logtype_afpd, "cname_mtouname('%s',did:%u) {demangled:'%s', fileid:%u}",
+            ret->m_name, ntohl(dir->d_did), t, ntohl(fileid));
+
         if (t != ret->m_name) {
             ret->u_name = t;
             /* duplicate work but we can't reuse all convert_char we did in demangle_osx
@@ -2071,22 +2073,20 @@ int afp_createdir(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_
         return err;
     }
 
-    LOG(log_debug, logtype_afpd, "afp_createdir: alive1");
-
     if (of_stat(s_path) < 0) {
         return AFPERR_MISC;
     }
-    LOG(log_debug, logtype_afpd, "afp_createdir: alive2");
+
     curdir->offcnt++;
-    LOG(log_debug, logtype_afpd, "afp_createdir: alive3");
+
     if ((dir = dir_add(vol, curdir, s_path, strlen(s_path->u_name))) == NULL) {
         return AFPERR_MISC;
     }
-    LOG(log_debug, logtype_afpd, "afp_createdir: alive4");
+
     if ( movecwd( vol, dir ) < 0 ) {
         return( AFPERR_PARAM );
     }
-    LOG(log_debug, logtype_afpd, "afp_createdir: alive5");
+
     ad_init(&ad, vol->v_adouble, vol->v_ad_options);
     if (ad_open_metadata( ".", ADFLAGS_DIR, O_CREAT, &ad ) < 0)  {
         if (vol_noadouble(vol))
index 260d1e62adf9e31ffacc943d5dcdfdd95dfed42a..7769542df4a4fe8e9df8a8f94043bbab57b42866 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * $Id: mangle.c,v 1.19.4.1 2010-02-01 10:56:08 franklahm Exp $ 
+ * $Id: mangle.c,v 1.19.4.2 2010-02-01 14:25:45 franklahm Exp $ 
  *
  * Copyright (c) 2002. Joe Marcus Clarke (marcus@marcuscom.com)
  * All Rights Reserved.  See COPYRIGHT.
 
 #include <stdio.h>
 #include <ctype.h>
+
+#include <atalk/util.h>
+#include <atalk/bstradd.h>
+
 #include "mangle.h"
 #include "desktop.h"
-#include <atalk/util.h>  
+
 
 #define hextoint( c )   ( isdigit( c ) ? c - '0' : c + 10 - 'A' )
 #define isuxdigit(x)    (isdigit(x) || (isupper(x) && isxdigit(x)))
@@ -38,7 +42,7 @@ static size_t mangle_extension(const struct vol *vol, const char* uname,
   return 0;
 }
 
-static char *demangle_checks ( const struct vol *vol, char* uname, char * mfilename, size_t prefix, char * ext)
+static char *demangle_checks(const struct vol *vol, char* uname, char * mfilename, size_t prefix, char * ext)
 {
     u_int16_t flags;
     static char buffer[MAXPATHLEN +2];  /* for convert_charset dest_len parameter +2 */
@@ -48,18 +52,18 @@ static char *demangle_checks ( const struct vol *vol, char* uname, char * mfilen
     /* We need to check, whether we really need to demangle the filename       */
     /* i.e. it's not just a file with a valid #HEX in the name ...             */
     /* but we don't want to miss valid demangle as well.                       */
-
     /* check whether file extensions match */
-    {
-      char buf[MAX_EXT_LENGTH + 2];  /* for convert_charset dest_len parameter +2 */
-      size_t ext_len = mangle_extension(vol, uname, buf, CH_UTF8_MAC);
 
-      if (ext_len) {
-       buf[ext_len] = '\0';
-       if (strcmp(ext, buf)) return mfilename;
-      } else {
-       if (*ext) return mfilename;
-      }
+    char buf[MAX_EXT_LENGTH + 2];  /* for convert_charset dest_len parameter +2 */
+    size_t ext_len = mangle_extension(vol, uname, buf, CH_UTF8_MAC);
+
+    if (ext_len) {
+        buf[ext_len] = '\0';
+        if (strcmp(ext, buf))
+            return mfilename;
+    } else {
+        if (*ext)
+            return mfilename;
     }
 
     /* First we convert the unix name to our volume maccharset         */
@@ -170,7 +174,7 @@ private_demangle(const struct vol *vol, char *mfilename, cnid_t did, cnid_t *osx
 
     /* is it a dir?, there's a conflict with pre OSX 'trash #2'  */
     if ((dir = dirlookup(vol, id))) {
-        if (dir->d_did != did) {
+        if (dir->d_pdid != did) {
             /* not in the same folder, there's a race with outdate cache
              * but we have to live with it, hopefully client will recover
             */
@@ -178,13 +182,12 @@ private_demangle(const struct vol *vol, char *mfilename, cnid_t did, cnid_t *osx
         }
         if (!osx) {
             /* it's not from cname so mfilename and dir must be the same */
-            if (strcmp((char *)dir->d_m_name->data, mfilename) == 0) {
-                return (char *)dir->d_u_name->data;
+            if (strcmp(cfrombstring(dir->d_m_name), mfilename) == 0) {
+                return cfrombstring(dir->d_u_name);
             }
-        } 
-        else {
-            return demangle_checks (vol, (char *)dir->d_u_name->data, mfilename, prefix, t);
-       }
+        } else {
+            return demangle_checks(vol, cfrombstring(dir->d_u_name), mfilename, prefix, t);
+        }
     }
     else if (NULL != (u_name = cnid_resolve(vol->v_cdb, &id, buffer, len)) ) {
         if (id != did) {