]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/volume.c
keep in each volume structure the last struct dir used, they are often reused
[netatalk.git] / etc / afpd / volume.c
index f9e0b2257b4e008bb1a49898f67c6aa021e0899f..81981e01c6604a3d219459f88cad896491f94f62 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: volume.c,v 1.99 2009-11-06 04:28:25 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.
@@ -770,7 +770,32 @@ static int creatvol(AFPObj *obj, struct passwd *pwd,
        else 
            volume->v_adouble = AD_VERSION;
 
+        /* Mac to Unix conversion flags*/
+        volume->v_mtou_flags = 0;
+        if (!(volume->v_flags & AFPVOL_NOHEX))
+            volume->v_mtou_flags |= CONV_ESCAPEHEX;
+        if (!(volume->v_flags & AFPVOL_USEDOTS))
+            volume->v_mtou_flags |= CONV_ESCAPEDOTS;
+        if ((volume->v_flags & AFPVOL_EILSEQ))
+            volume->v_mtou_flags |= CONV__EILSEQ;
+
+        if ((volume->v_casefold & AFPVOL_MTOUUPPER))
+            volume->v_mtou_flags |= CONV_TOUPPER;
+        else if ((volume->v_casefold & AFPVOL_MTOULOWER))
+            volume->v_mtou_flags |= CONV_TOLOWER;
+
+        /* Unix to Mac conversion flags*/
+        volume->v_utom_flags = CONV_IGNORE | CONV_UNESCAPEHEX;
+        if ((volume->v_casefold & AFPVOL_UTOMUPPER))
+            volume->v_utom_flags |= CONV_TOUPPER;
+        else if ((volume->v_casefold & AFPVOL_UTOMLOWER))
+            volume->v_utom_flags |= CONV_TOLOWER;
+
+        if ((volume->v_flags & AFPVOL_EILSEQ)) 
+            volume->v_utom_flags |= CONV__EILSEQ;
+
        initvol_vfs(volume);
+
 #ifdef FORCE_UIDGID
         if (options[VOLOPT_FORCEUID].c_value) {
             volume->v_forceuid = strdup(options[VOLOPT_FORCEUID].c_value);
@@ -1786,7 +1811,8 @@ int afp_openvol(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t
     char        *vol_uname;
     char        *vol_mname;
     char        *volname_tmp;
-
+    struct charset_functions *charset;
+    
     ibuf += 2;
     memcpy(&bitmap, ibuf, sizeof( bitmap ));
     bitmap = ntohs( bitmap );
@@ -1924,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;
@@ -1953,7 +1980,7 @@ int afp_openvol(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t
        goto openvol_err;
     }
 
-    if ( NULL == ( volume->v_vol = find_charset_functions(volume->v_volcodepage)) || volume->v_vol->flags & CHARSET_ICONV ) {
+    if ( NULL == (charset = find_charset_functions(volume->v_volcodepage)) || charset->flags & CHARSET_ICONV ) {
        LOG (log_warning, logtype_afpd, "WARNING: volume encoding %s is *not* supported by netatalk, expect problems !!!!", volume->v_volcodepage);
     }  
 
@@ -1966,11 +1993,12 @@ int afp_openvol(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t
        goto openvol_err;
     }
 
-    if ( NULL == ( volume->v_mac = find_charset_functions(volume->v_maccodepage)) || ! (volume->v_mac->flags & CHARSET_CLIENT) ) {
+    if ( NULL == ( charset = find_charset_functions(volume->v_maccodepage)) || ! (charset->flags & CHARSET_CLIENT) ) {
        LOG (log_error, logtype_afpd, "Fatal error: mac charset %s not supported", volume->v_maccodepage);
        ret = AFPERR_MISC;
        goto openvol_err;
-    }  
+    }
+    volume->v_kTextEncoding = htonl(charset->kTextEncoding);
 
     ret  = stat_vol(bitmap, volume, rbuf, rbuflen);
     if (ret == AFP_OK) {