From bb680efb0a40ecfe86206acef379e5f9e09ea5bf Mon Sep 17 00:00:00 2001 From: Guenter Kukkukk Date: Wed, 27 Feb 2013 05:34:05 +0100 Subject: [PATCH 1/5] vfs_catia: add debug class for that module Signed-off-by: Guenter Kukkukk Reviewed-by: Jeremy Allison --- source3/modules/vfs_catia.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c index b9f241e..3140df9 100644 --- a/source3/modules/vfs_catia.c +++ b/source3/modules/vfs_catia.c @@ -29,6 +29,11 @@ #include "includes.h" #include "smbd/smbd.h" +static int vfs_catia_debug_level = DBGC_VFS; + +#undef DBGC_CLASS +#define DBGC_CLASS vfs_catia_debug_level + #define GLOBAL_SNUM 0xFFFFFFF #define MAP_SIZE 0xFF #define MAP_NUM 0x101 /* max unicode charval / MAP_SIZE */ @@ -929,6 +934,23 @@ static struct vfs_fn_pointers vfs_catia_fns = { NTSTATUS vfs_catia_init(void) { - return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "catia", + NTSTATUS ret; + + ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "catia", &vfs_catia_fns); + if (!NT_STATUS_IS_OK(ret)) + return ret; + + vfs_catia_debug_level = debug_add_class("catia"); + if (vfs_catia_debug_level == -1) { + vfs_catia_debug_level = DBGC_VFS; + DEBUG(0, ("vfs_catia: Couldn't register custom debugging " + "class!\n")); + } else { + DEBUG(10, ("vfs_catia: Debug class number of " + "'catia': %d\n", vfs_catia_debug_level)); + } + + return ret; + } -- 1.8.1.3 From f7a63dc3ae784254a289348139d279f87b819ee1 Mon Sep 17 00:00:00 2001 From: Guenter Kukkukk Date: Wed, 27 Feb 2013 05:50:52 +0100 Subject: [PATCH 2/5] vfs_catia: fix the translation to "vfs_translate_to_windows" THANKS to an IRC user (Raimund ?) who asked for a char mapping possibility. I suggested vfs_catia - but it did not work! Hopefully now it will. :-) Signed-off-by: Guenter Kukkukk Reviewed-by: Jeremy Allison --- source3/modules/vfs_catia.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c index 3140df9..145f384 100644 --- a/source3/modules/vfs_catia.c +++ b/source3/modules/vfs_catia.c @@ -300,7 +300,7 @@ static NTSTATUS catia_translate_name(struct vfs_handle_struct *handle, { char *name = NULL; char *mapped_name; - NTSTATUS ret; + NTSTATUS status, ret; /* * Copy the supplied name and free the memory for mapped_name, @@ -313,12 +313,12 @@ static NTSTATUS catia_translate_name(struct vfs_handle_struct *handle, errno = ENOMEM; return NT_STATUS_NO_MEMORY; } - ret = catia_string_replace_allocate(handle->conn, name, + status = catia_string_replace_allocate(handle->conn, name, &mapped_name, direction); TALLOC_FREE(name); - if (!NT_STATUS_IS_OK(ret)) { - return ret; + if (!NT_STATUS_IS_OK(status)) { + return status; } ret = SMB_VFS_NEXT_TRANSLATE_NAME(handle, mapped_name, direction, @@ -326,6 +326,8 @@ static NTSTATUS catia_translate_name(struct vfs_handle_struct *handle, if (NT_STATUS_EQUAL(ret, NT_STATUS_NONE_MAPPED)) { *pmapped_name = talloc_move(mem_ctx, &mapped_name); + /* we need to return the former translation result here */ + ret = status; } else { TALLOC_FREE(mapped_name); } -- 1.8.1.3 From 5f38125c147c329da1e4e853b99022f1a3e77ba2 Mon Sep 17 00:00:00 2001 From: Guenter Kukkukk Date: Thu, 28 Feb 2013 06:12:36 +0100 Subject: [PATCH 3/5] vfs_catia: fix the completely outdated manual page The complete rework around 3.5.0 was not even mentioned somewhere. (i was not able to find any info about that major change) Signed-off-by: Guenter Kukkukk Reviewed-by: Jeremy Allison --- docs-xml/manpages/vfs_catia.8.xml | 57 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/docs-xml/manpages/vfs_catia.8.xml b/docs-xml/manpages/vfs_catia.8.xml index a5f6233..e86f73d 100644 --- a/docs-xml/manpages/vfs_catia.8.xml +++ b/docs-xml/manpages/vfs_catia.8.xml @@ -31,18 +31,31 @@ The Catia CAD package commonly creates filenames that use characters that are illegal in CIFS filenames. The - vfs_catia VFS module implements a fixed character + vfs_catia VFS module implements a character mapping so that these files can be shared with CIFS clients. This module is stackable. + Up to samba version 3.4.x a fixed character mapping was used. + The invalid windows characters \ / : * ? " < > | and the blank + character were mapped in a hardcoded way. + + + Starting with samba-3.5.0 a more flexible mapping was introduced. + The new parameter "catia:mappings" now specifies the mapping on a char by char + basis using the notation: unix hex char 0x.. : windows hex char 0x.. + Multiple character mappings are separated by a comma. + + + EXAMPLES + Samba versions up to 3.4.x: Map Catia filenames on the [CAD] share: @@ -51,12 +64,51 @@ catia + Samba versions 3.5.0 and later: + Map Catia filenames on the [CAD] share: + + + + /data/cad + catia + 0x22:0xa8 + + + To get the full formerly fixed mappings: + + + /data/cad + catia + 0x22:0xa8,0x2a:0xa4,0x2f:0xf8,0x3a:0xf7,0x3c:0xab,0x3e:0xbb,0x3f:0xbf,0x5c:0xff,0x7c:0xa6,0x20:0xb1 + + + Note that the character mapping must work in BOTH directions + (unix -> windows and windows -> unix) to get unique and existing file names! + + + A NOT working example: + + + + /data/cad + catia + 0x3a:0x5f + + + Here the colon ":" is mapped to the underscore "_". + Assuming a unix filename "a:should_work", which is well translated + to windows as "a_should_work". + BUT the reverse mapping from windows "a_should_work" to unix + will result to "a:should:work" - something like "file not found" + would be returned. + + VERSION - This man page is correct for version 3.0.25 of the Samba suite. + This man page is correct for all versions up to 4.0.3 of the Samba suite. @@ -67,6 +119,7 @@ were created by Andrew Tridgell. Samba is now developed by the Samba Team as an Open Source project similar to the way the Linux kernel is developed. + Written by Guenter Kukkukk kukks@samba.org -- 1.8.1.3 From 4b4f8f3a2994f282bd3bd75d4f1fb83c82169e9a Mon Sep 17 00:00:00 2001 From: Guenter Kukkukk Date: Fri, 1 Mar 2013 00:36:08 +0100 Subject: [PATCH 4/5] vfs_catia: add a sample for filename mapping to the manual page Signed-off-by: Guenter Kukkukk Reviewed-by: Jeremy Allison --- docs-xml/manpages/vfs_catia.8.xml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/docs-xml/manpages/vfs_catia.8.xml b/docs-xml/manpages/vfs_catia.8.xml index e86f73d..b18dc48 100644 --- a/docs-xml/manpages/vfs_catia.8.xml +++ b/docs-xml/manpages/vfs_catia.8.xml @@ -82,6 +82,15 @@ 0x22:0xa8,0x2a:0xa4,0x2f:0xf8,0x3a:0xf7,0x3c:0xab,0x3e:0xbb,0x3f:0xbf,0x5c:0xff,0x7c:0xa6,0x20:0xb1 + Unix filename to be translated (Note that the path delimiter "/" is not used here): + + a\a:a*a?a"a<a>a|a a + + Resulting windows filename: + + aÿa÷a¤a¿a¨a«a»a¦a±a + + Note that the character mapping must work in BOTH directions (unix -> windows and windows -> unix) to get unique and existing file names! @@ -99,8 +108,8 @@ Assuming a unix filename "a:should_work", which is well translated to windows as "a_should_work". BUT the reverse mapping from windows "a_should_work" to unix - will result to "a:should:work" - something like "file not found" - would be returned. + will result in "a:should:work" - something like "file not found" + will be returned. @@ -119,7 +128,7 @@ were created by Andrew Tridgell. Samba is now developed by the Samba Team as an Open Source project similar to the way the Linux kernel is developed. - Written by Guenter Kukkukk kukks@samba.org + New version written by Guenter Kukkukk kukks@samba.org -- 1.8.1.3 From 0e2492d28a10758ee44f2e25f9673b991f56336c Mon Sep 17 00:00:00 2001 From: Guenter Kukkukk Date: Fri, 1 Mar 2013 00:58:05 +0100 Subject: [PATCH 5/5] vfs_catia: add my copyright Signed-off-by: Guenter Kukkukk Reviewed-by: Jeremy Allison --- source3/modules/vfs_catia.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c index 145f384..f7c0e7b 100644 --- a/source3/modules/vfs_catia.c +++ b/source3/modules/vfs_catia.c @@ -10,6 +10,7 @@ * * Copyright (C) Volker Lendecke, 2005 * Copyright (C) Aravind Srinivasan, 2009 + * Copyright (C) Guenter Kukkukk, 2013 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by -- 1.8.1.3