+/* ------------------------- */
+static int volume_codepage(AFPObj *obj, struct vol *volume)
+{
+ struct charset_functions *charset;
+ /* Codepages */
+
+ if (!volume->v_volcodepage)
+ volume->v_volcodepage = strdup("UTF8");
+
+ if ( (charset_t) -1 == ( volume->v_volcharset = add_charset(volume->v_volcodepage)) ) {
+ LOG (log_error, logtype_afpd, "Setting codepage %s as volume codepage failed", volume->v_volcodepage);
+ return -1;
+ }
+
+ 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);
+ }
+
+ if (!volume->v_maccodepage)
+ volume->v_maccodepage = strdup(obj->options.maccodepage);
+
+ if ( (charset_t) -1 == ( volume->v_maccharset = add_charset(volume->v_maccodepage)) ) {
+ LOG (log_error, logtype_afpd, "Setting codepage %s as mac codepage failed", volume->v_maccodepage);
+ return -1;
+ }
+
+ 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);
+ return -1;
+ }
+ volume->v_kTextEncoding = htonl(charset->kTextEncoding);
+ return 0;
+}
+
+/* ------------------------- */
+static int volume_openDB(struct vol *volume)
+{
+ int flags = 0;
+
+ if ((volume->v_flags & AFPVOL_NODEV)) {
+ flags |= CNID_FLAG_NODEV;
+ }
+
+ if (volume->v_cnidscheme == NULL) {
+ volume->v_cnidscheme = strdup(DEFAULT_CNID_SCHEME);
+ LOG(log_info, logtype_afpd, "Volume %s use CNID scheme %s.", volume->v_path, volume->v_cnidscheme);
+ }
+ if (volume->v_dbpath)
+ volume->v_cdb = cnid_open (volume->v_dbpath, volume->v_umask, volume->v_cnidscheme, flags);
+ else
+ volume->v_cdb = cnid_open (volume->v_path, volume->v_umask, volume->v_cnidscheme, flags);
+ return (!volume->v_cdb)?-1:0;
+}
+