[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Mon Aug 18 12:09:03 MDT 2014


The branch, master has been updated
       via  953c883 s4:torture:vfs_fruit: add tests for resource fork IO
       via  f773593 s4:torture:vfs_fruit: add test writing Netatalk metadata
       via  79a220e s4:torture:vfs_fruit: add test reading Netatalk metadata
       via  b15da5f s4:torture: add boilerplate code for vfs_fruit
       via  4a0ae59 s4:torture: add wrapper functions
       via  e935c62 s4:torture: add boilerplate code for testing specific VFS modules
       via  ed81d09 s4:torture:smb2: add utility function torture_smb2_con_sopt()
       via  e4a696b vfs_fruit: add manpage
       via  4df557e New VFS module vfs_fruit
       via  b3d17aa Fix AFP_BackupTime byte order and use ISO C99 integer types
      from  335171e s4:torture: use torture_assert instead of torture_comment and return in defer_open test

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 953c88395bb9a408ebfb65329aecee6ee1a43fdc
Author: Ralph Boehme <rb at sernet.de>
Date:   Fri Jul 11 12:58:37 2014 +0200

    s4:torture:vfs_fruit: add tests for resource fork IO
    
    Signed-off-by: Ralph Boehme <rb at sernet.de>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    Autobuild-User(master): Volker Lendecke <vl at samba.org>
    Autobuild-Date(master): Mon Aug 18 20:08:32 CEST 2014 on sn-devel-104

commit f773593f4db0bc325f0c7d3588e22bb9336c7aae
Author: Ralph Boehme <rb at sernet.de>
Date:   Thu Jul 10 16:40:28 2014 +0200

    s4:torture:vfs_fruit: add test writing Netatalk metadata
    
    Signed-off-by: Ralph Boehme <rb at sernet.de>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 79a220e86c9e794f805751a8f2437f1e84282282
Author: Ralph Boehme <rb at sernet.de>
Date:   Tue Jul 8 05:50:09 2014 +0200

    s4:torture:vfs_fruit: add test reading Netatalk metadata
    
    Signed-off-by: Ralph Boehme <rb at sernet.de>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit b15da5f90b2d3a47d1ac92b1de917fce45e5bdaf
Author: Ralph Boehme <rb at sernet.de>
Date:   Tue Jul 8 05:47:02 2014 +0200

    s4:torture: add boilerplate code for vfs_fruit
    
    Signed-off-by: Ralph Boehme <rb at sernet.de>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 4a0ae592f5561179ac3c8170189cb1d54a212ce8
Author: Ralph Boehme <rb at sernet.de>
Date:   Tue Jul 8 05:39:49 2014 +0200

    s4:torture: add wrapper functions
    
    Add wrapper functions that connect two trees with sharenames taken
    from passed option.
    
    Signed-off-by: Ralph Boehme <rb at sernet.de>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit e935c62657407ad4aada5484690db08f97e2de3c
Author: Ralph Boehme <rb at sernet.de>
Date:   Tue Jul 8 05:36:46 2014 +0200

    s4:torture: add boilerplate code for testing specific VFS modules
    
    Signed-off-by: Ralph Boehme <rb at sernet.de>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit ed81d09adea09082028a8beaf7599d9b63ac5d87
Author: Ralph Boehme <rb at sernet.de>
Date:   Sat Jun 28 01:09:58 2014 +0200

    s4:torture:smb2: add utility function torture_smb2_con_sopt()
    
    Add a utility function that takes an option name as parameter and then
    uses the value of the option 'torture:NAME' as share name in a tree
    connect.
    
    Signed-off-by: Ralph Boehme <rb at sernet.de>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit e4a696b51b73b398246e090b07fd560d2bbd65dd
Author: Ralph Boehme <rb at sernet.de>
Date:   Mon Jun 23 17:01:30 2014 +0200

    vfs_fruit: add manpage
    
    Signed-off-by: Ralph Boehme <rb at sernet.de>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 4df557e3ce9c483988a82274616b7ad076a84c95
Author: Ralph Boehme <rb at sernet.de>
Date:   Mon Jun 23 16:59:45 2014 +0200

    New VFS module vfs_fruit
    
    This module provides enhanced compatibility with Apple SMB clients and
    interoperability with a Netatalk 3 AFP fileserver.
    
    The module intercepts the OS X special streams "AFP_AfpInfo" and
    "AFP_Resource" and handles them in a special way. All other named
    streams are deferred to vfs_streams_xattr.
    
    The OS X client maps all NTFS illegal characters to the Unicode
    private range. This module optionally stores the charcters using their
    native ASCII encoding.
    
    Open modes are optionally checked against Netatalk AFP share modes.
    
    The "AFP_AfpInfo" named stream is a binary blob containing OS X
    extended metadata for files and directories. This module optionally
    reads and stores this metadata in a way compatible with Netatalk 3
    which stores the metadata in an EA "org.netatalk.metadata". Cf
    source3/include/MacExtensions.h for a description of the binary blobs
    content.
    
    The "AFP_Resource" named stream may be arbitrarily large, thus it
    can't be stored in an EA on most filesystem. ZFS on Solaris is an
    exception to the rule, because it there EAs can be of any size and EAs
    are first-class filesystem objects that can be used with normal file
    syscalls like open(), read(), write(), fcntl() asf. This module stores
    the AFP_Resource stream in an AppleDouble file, prepending "._" to the
    filename. On Solaris and ZFS the stream is optionally stored in an EA
    "org.netatalk.ResourceFork".
    
    Signed-off-by: Ralph Boehme <rb at sernet.de>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit b3d17aa5ba7d1d72bb96fdc07b575dde78d0da3e
Author: Ralph Boehme <rb at sernet.de>
Date:   Thu Jul 10 16:32:15 2014 +0200

    Fix AFP_BackupTime byte order and use ISO C99 integer types
    
    AFP_BackupTime value must be 0x80000000 and all existing defines use
    native byte order, not byte swapped.
    
    Signed-off-by: Ralph Boehme <rb at sernet.de>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 docs-xml/manpages/vfs_fruit.8.xml |  183 +++
 docs-xml/wscript_build            |    1 +
 selftest/target/Samba3.pm         |    8 +
 selftest/target/Samba4.pm         |    8 +
 source3/include/MacExtensions.h   |   10 +-
 source3/modules/vfs_fruit.c       | 2945 +++++++++++++++++++++++++++++++++++++
 source3/modules/wscript_build     |    8 +
 source3/selftest/tests.py         |    7 +-
 source3/wscript                   |    2 +-
 source4/torture/smb2/util.c       |   42 +
 source4/torture/vfs/fruit.c       |  645 ++++++++
 source4/torture/vfs/vfs.c         |  114 ++
 source4/torture/wscript_build     |   12 +-
 13 files changed, 3977 insertions(+), 8 deletions(-)
 create mode 100644 docs-xml/manpages/vfs_fruit.8.xml
 create mode 100644 source3/modules/vfs_fruit.c
 create mode 100644 source4/torture/vfs/fruit.c
 create mode 100644 source4/torture/vfs/vfs.c


Changeset truncated at 500 lines:

diff --git a/docs-xml/manpages/vfs_fruit.8.xml b/docs-xml/manpages/vfs_fruit.8.xml
new file mode 100644
index 0000000..500fbec
--- /dev/null
+++ b/docs-xml/manpages/vfs_fruit.8.xml
@@ -0,0 +1,183 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE refentry PUBLIC "-//Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc">
+<refentry id="vfs_fruit.8">
+
+<refmeta>
+	<refentrytitle>vfs_fruit</refentrytitle>
+	<manvolnum>8</manvolnum>
+	<refmiscinfo class="source">Samba</refmiscinfo>
+	<refmiscinfo class="manual">System Administration tools</refmiscinfo>
+	<refmiscinfo class="version">4.1</refmiscinfo>
+</refmeta>
+
+
+<refnamediv>
+	<refname>vfs_fruit</refname>
+	<refpurpose>Enhanced OS X and Netatalk interoperability</refpurpose>
+</refnamediv>
+
+<refsynopsisdiv>
+	<cmdsynopsis>
+		<command>vfs objects = fruit</command>
+	</cmdsynopsis>
+</refsynopsisdiv>
+
+<refsect1>
+	<title>DESCRIPTION</title>
+
+	<para>This VFS module is part of the
+	<citerefentry><refentrytitle>samba</refentrytitle>
+	<manvolnum>7</manvolnum></citerefentry> suite.</para>
+
+	<para>The <command>vfs_fruit</command> module provides
+	enhanced compatibility with Apple SMB clients and
+	interoperability with a Netatalk 3 AFP fileserver.</para>
+
+	<para>The module should be stacked with
+	<command>vfs_catia</command> if enabling character conversion and
+	must be stacked with <command>vfs_streams_xattr</command>, see the
+	example section for the correct config.</para>
+
+	<para>The module enables alternate data streams (ADS) support
+	for a share, intercepts the OS X special streams "AFP_AfpInfo"
+	and "AFP_Resource" and handles them in a special way. All
+	other named streams are deferred to
+	<command>vfs_streams_xattr</command> which must be loaded
+	together with <command>vfs_fruit</command>.</para>
+
+	<para>Having shares with ADS support enabled for OS X client
+	is worthwhile because it resembles the behaviour of Apple's
+	own SMB server implementation and it avoids certain severe
+	performance degradations caused by Samba's case sensitivity
+	semantics.</para>
+
+	<para>The OS X metadata and resource fork stream can be stored
+	in a way compatible with Netatalk 3 by setting
+	<command>fruit:resource = file</command> and
+	<command>fruit:metadata = netatalk</command>.</para>
+
+	<para>OS X maps NTFS illegal characters to the Unicode private
+	range in SMB requests. By setting <command>fruit:encoding =
+	native</command>, all mapped characters are converted to
+	native ASCII characters.</para>
+
+	<para>Finally, share access modes are optionally checked
+	against Netatalk AFP sharing modes by setting
+	<command>fruit:locking = netatalk</command>.</para>
+
+	<para>This module is not stackable other then described in
+	this manpage.</para>
+
+</refsect1>
+
+<refsect1>
+	<title>OPTIONS</title>
+
+	<variablelist>
+
+	  <varlistentry>
+	    <term>fruit:resource = [ file | xattr | stream ]</term>
+	    <listitem>
+	      <para>Controls where the OS X resource fork is stored:</para>
+
+	      <itemizedlist>
+		<listitem><para><command>file (default)</command> - use a ._
+		AppleDouble file compatible with OS X and
+		Netatalk</para></listitem>
+
+		<listitem><para><command>xattr</command> - use a
+		xattr, requires a filesystem with large xattr support
+		and a file IO API compatible with xattrs, this boils
+		down to Solaris and derived platforms and
+		ZFS</para></listitem>
+
+		<listitem><para><command>stream</command> - pass the
+		stream on to the next module in the VFS
+		stack</para></listitem>
+	      </itemizedlist>
+
+	    </listitem>
+	  </varlistentry>
+
+	  <varlistentry>
+	    <term>fruit:metadata = [ stream | netatalk ]</term>
+	    <listitem>
+	      <para>Controls where the OS X metadata stream is stored:</para>
+
+	      <itemizedlist>
+		<listitem><para><command>netatalk (default)</command> - use
+		Netatalk compatible xattr</para></listitem>
+
+		<listitem><para><command>stream</command> - pass the
+		stream on to the next module in the VFS
+		stack</para></listitem>
+	      </itemizedlist>
+
+	    </listitem>
+	  </varlistentry>
+
+	  <varlistentry>
+	    <term>fruit:locking = [ netatalk | none ]</term>
+	    <listitem>
+	      <para></para>
+	      <itemizedlist>
+		<listitem><para><command>none (default)</command> - no
+		cross protocol locking</para></listitem>
+
+		<listitem><para><command>netatalk</command> - use
+		cross protocol locking with Netatalk</para></listitem>
+
+	      </itemizedlist>
+	    </listitem>
+	  </varlistentry>
+
+	  <varlistentry>
+	    <term>fruit:encoding = [ native | private ]</term>
+	    <listitem>
+
+	      <para>Controls how the set of illegal NTFS ASCII
+	      character, commonly used by OS X clients, are stored in
+	      the filesystem:</para>
+
+	      <itemizedlist>
+
+		<listitem><para><command>private (default)</command> -
+		store characters as encoded by the OS X client: mapped
+		to the Unicode private range</para></listitem>
+
+		<listitem><para><command>native</command> - store
+		characters with their native ASCII
+		value</para></listitem>
+
+	      </itemizedlist>
+	    </listitem>
+	  </varlistentry>
+
+	</variablelist>
+</refsect1>
+
+<refsect1>
+	<title>EXAMPLES</title>
+
+<programlisting>
+        <smbconfsection name="[share]"/>
+	<smbconfoption name="vfs objects">catia fruit streams_xattr</smbconfoption>
+	<smbconfoption name="fruit:resource">file</smbconfoption>
+	<smbconfoption name="fruit:metadata">netatalk</smbconfoption>
+	<smbconfoption name="fruit:locking">netatalk</smbconfoption>
+	<smbconfoption name="fruit:encoding">native</smbconfoption>
+</programlisting>
+
+</refsect1>
+
+<refsect1>
+	<title>AUTHOR</title>
+
+	<para>The original Samba software and related utilities
+	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.</para>
+
+</refsect1>
+
+</refentry>
diff --git a/docs-xml/wscript_build b/docs-xml/wscript_build
index 42c9a85..e7c8931 100644
--- a/docs-xml/wscript_build
+++ b/docs-xml/wscript_build
@@ -60,6 +60,7 @@ manpages='''
          manpages/vfs_extd_audit.8
          manpages/vfs_fake_perms.8
          manpages/vfs_fileid.8
+         manpages/vfs_fruit.8
          manpages/vfs_full_audit.8
          manpages/vfs_gpfs.8
          manpages/vfs_linux_xfs_sgid.8
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index 394d637..a17f2f6 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -1169,6 +1169,14 @@ sub provision($$$$$$)
 
 [print\$]
 	copy = tmp
+
+[vfs_fruit]
+	path = $shrdir
+	vfs objects = catia fruit streams_xattr
+	fruit:ressource = file
+	fruit:metadata = netatalk
+	fruit:locking = netatalk
+	fruit:encoding = native
 	";
 	close(CONF);
 
diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm
index 412fbff..ec0f439 100755
--- a/selftest/target/Samba4.pm
+++ b/selftest/target/Samba4.pm
@@ -879,6 +879,14 @@ sub provision($$$$$$$$$)
 	copy = simple
 	ntvfs handler = cifsposix
 
+[vfs_fruit]
+	path = $ctx->{share}
+	vfs objects = catia fruit streams_xattr
+	fruit:ressource = file
+	fruit:metadata = netatalk
+	fruit:locking = netatalk
+	fruit:encoding = native
+
 $extra_smbconf_shares
 ";
 
diff --git a/source3/include/MacExtensions.h b/source3/include/MacExtensions.h
index a60f894..5b00998 100644
--- a/source3/include/MacExtensions.h
+++ b/source3/include/MacExtensions.h
@@ -49,7 +49,7 @@
 #define AFP_INFO_SIZE		0x3c
 #define AFP_Signature		0x41465000 
 #define AFP_Version			0x00000100
-#define AFP_BackupTime		0x00000080
+#define AFP_BackupTime		0x80000000
 #define AFP_FinderSize		32
 /*
 ** Orginal AFP_AfpInfo stream used by NT 
@@ -59,10 +59,10 @@
 */
 typedef struct _AfpInfo
 {
-	 uint32       	afpi_Signature;   		/* Must be *(PDWORD)"AFP" */
-	 uint32       	afpi_Version;     		/* Must be 0x00010000 */
-	 uint32       	afpi_Reserved1;
-	 uint32       	afpi_BackupTime;  		/* Backup time for the file/dir */
+	 uint32_t      	afpi_Signature;   		/* Must be *(PDWORD)"AFP" */
+	 uint32_t      	afpi_Version;     		/* Must be 0x00010000 */
+	 uint32_t      	afpi_Reserved1;
+	 uint32_t      	afpi_BackupTime;  		/* Backup time for the file/dir */
 	 unsigned char 	afpi_FinderInfo[AFP_FinderSize];  	/* Finder Info (32 bytes) */
 	 unsigned char 	afpi_ProDosInfo[6];  	/* ProDos Info (6 bytes) # */
 	 unsigned char 	afpi_Reserved2[6];
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
new file mode 100644
index 0000000..1226dc0
--- /dev/null
+++ b/source3/modules/vfs_fruit.c
@@ -0,0 +1,2945 @@
+/*
+ * OS X and Netatalk interoperability VFS module for Samba-3.x
+ *
+ * Copyright (C) Ralph Boehme, 2013, 2014
+ *
+ * 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
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "includes.h"
+#include "MacExtensions.h"
+#include "smbd/smbd.h"
+#include "system/filesys.h"
+#include "lib/util/time.h"
+#include "../lib/crypto/md5.h"
+#include "system/shmem.h"
+#include "locking/proto.h"
+#include "smbd/globals.h"
+#include "messages.h"
+#include "libcli/security/security.h"
+
+/*
+ * Enhanced OS X and Netatalk compatibility
+ * ========================================
+ *
+ * This modules takes advantage of vfs_streams_xattr and
+ * vfs_catia. VFS modules vfs_fruit and vfs_streams_xattr must be
+ * loaded in the correct order:
+ *
+ *   vfs modules = catia fruit streams_xattr
+ *
+ * The module intercepts the OS X special streams "AFP_AfpInfo" and
+ * "AFP_Resource" and handles them in a special way. All other named
+ * streams are deferred to vfs_streams_xattr.
+ *
+ * The OS X client maps all NTFS illegal characters to the Unicode
+ * private range. This module optionally stores the charcters using
+ * their native ASCII encoding using vfs_catia. If you're not enabling
+ * this feature, you can skip catia from vfs modules.
+ *
+ * Finally, open modes are optionally checked against Netatalk AFP
+ * share modes.
+ *
+ * The "AFP_AfpInfo" named stream is a binary blob containing OS X
+ * extended metadata for files and directories. This module optionally
+ * reads and stores this metadata in a way compatible with Netatalk 3
+ * which stores the metadata in an EA "org.netatalk.metadata". Cf
+ * source3/include/MacExtensions.h for a description of the binary
+ * blobs content.
+ *
+ * The "AFP_Resource" named stream may be arbitrarily large, thus it
+ * can't be stored in an xattr on most filesystem. ZFS on Solaris is
+ * the only available filesystem where xattrs can be of any size and
+ * the OS supports using the file APIs for xattrs.
+ *
+ * The AFP_Resource stream is stored in an AppleDouble file prepending
+ * "._" to the filename. On Solaris with ZFS the stream is optionally
+ * stored in an EA "org.netatalk.ressource".
+ *
+ *
+ * Extended Attributes
+ * ===================
+ *
+ * The OS X SMB client sends xattrs as ADS too. For xattr interop with
+ * other protocols you may want to adjust the xattr names the VFS
+ * module vfs_streams_xattr uses for storing ADS's. This defaults to
+ * user.DosStream.ADS_NAME:$DATA and can be changed by specifying
+ * these module parameters:
+ *
+ *   streams_xattr:prefix = user.
+ *   streams_xattr:store_stream_type = false
+ *
+ *
+ * TODO
+ * ====
+ *
+ * - log diagnostic if any needed VFS module is not loaded
+ *   (eg with lp_vfs_objects())
+ * - add tests
+ */
+
+static int vfs_fruit_debug_level = DBGC_VFS;
+
+#undef DBGC_CLASS
+#define DBGC_CLASS vfs_fruit_debug_level
+
+#define FRUIT_PARAM_TYPE_NAME "fruit"
+#define ADOUBLE_NAME_PREFIX "._"
+
+/*
+ * REVIEW:
+ * This is hokey, but what else can we do?
+ */
+#if defined(HAVE_ATTROPEN) || defined(FREEBSD)
+#define AFPINFO_EA_NETATALK "org.netatalk.Metadata"
+#define AFPRESOURCE_EA_NETATALK "org.netatalk.ResourceFork"
+#else
+#define AFPINFO_EA_NETATALK "user.org.netatalk.Metadata"
+#define AFPRESOURCE_EA_NETATALK "user.org.netatalk.ResourceFork"
+#endif
+
+enum apple_fork {APPLE_FORK_DATA, APPLE_FORK_RSRC};
+
+enum fruit_rsrc {FRUIT_RSRC_STREAM, FRUIT_RSRC_ADFILE, FRUIT_RSRC_XATTR};
+enum fruit_meta {FRUIT_META_STREAM, FRUIT_META_NETATALK};
+enum fruit_locking {FRUIT_LOCKING_NETATALK, FRUIT_LOCKING_NONE};
+enum fruit_encoding {FRUIT_ENC_NATIVE, FRUIT_ENC_PRIVATE};
+
+struct fruit_config_data {
+	enum fruit_rsrc rsrc;
+	enum fruit_meta meta;
+	enum fruit_locking locking;
+	enum fruit_encoding encoding;
+};
+
+static const struct enum_list fruit_rsrc[] = {
+	{FRUIT_RSRC_STREAM, "stream"}, /* pass on to vfs_streams_xattr */
+	{FRUIT_RSRC_ADFILE, "file"}, /* ._ AppleDouble file */
+	{FRUIT_RSRC_XATTR, "xattr"}, /* Netatalk compatible xattr (ZFS only) */
+	{ -1, NULL}
+};
+
+static const struct enum_list fruit_meta[] = {
+	{FRUIT_META_STREAM, "stream"}, /* pass on to vfs_streams_xattr */
+	{FRUIT_META_NETATALK, "netatalk"}, /* Netatalk compatible xattr */
+	{ -1, NULL}
+};
+
+static const struct enum_list fruit_locking[] = {
+	{FRUIT_LOCKING_NETATALK, "netatalk"}, /* synchronize locks with Netatalk */
+	{FRUIT_LOCKING_NONE, "none"},
+	{ -1, NULL}
+};
+
+static const struct enum_list fruit_encoding[] = {
+	{FRUIT_ENC_NATIVE, "native"}, /* map unicode private chars to ASCII */
+	{FRUIT_ENC_PRIVATE, "private"}, /* keep unicode private chars */
+	{ -1, NULL}
+};
+
+/*****************************************************************************
+ * Defines, functions and data structures that deal with AppleDouble
+ *****************************************************************************/
+
+/*
+ * There are two AppleDouble blobs we deal with:
+ *
+ * - ADOUBLE_META - AppleDouble blob used by Netatalk for storing
+ *   metadata in an xattr
+ *
+ * - ADOUBLE_RSRC - AppleDouble blob used by OS X and Netatalk in
+ *   ._ files
+ */
+typedef enum {ADOUBLE_META, ADOUBLE_RSRC} adouble_type_t;
+
+/* Version info */
+#define AD_VERSION2     0x00020000
+#define AD_VERSION      AD_VERSION2
+
+/*
+ * AppleDouble entry IDs.
+ */
+#define ADEID_DFORK         1
+#define ADEID_RFORK         2
+#define ADEID_NAME          3
+#define ADEID_COMMENT       4
+#define ADEID_ICONBW        5
+#define ADEID_ICONCOL       6
+#define ADEID_FILEI         7
+#define ADEID_FILEDATESI    8
+#define ADEID_FINDERI       9
+#define ADEID_MACFILEI      10
+#define ADEID_PRODOSFILEI   11
+#define ADEID_MSDOSFILEI    12
+#define ADEID_SHORTNAME     13
+#define ADEID_AFPFILEI      14
+#define ADEID_DID           15
+
+/* Private Netatalk entries */
+#define ADEID_PRIVDEV       16
+#define ADEID_PRIVINO       17
+#define ADEID_PRIVSYN       18
+#define ADEID_PRIVID        19
+#define ADEID_MAX           (ADEID_PRIVID + 1)
+
+/*
+ * These are the real ids for the private entries,
+ * as stored in the adouble file
+ */
+#define AD_DEV              0x80444556
+#define AD_INO              0x80494E4F
+#define AD_SYN              0x8053594E
+#define AD_ID               0x8053567E
+
+/* Number of actually used entries */
+#define ADEID_NUM_XATTR      8
+#define ADEID_NUM_DOT_UND    2
+#define ADEID_NUM_RSRC_XATTR 1
+
+/* AppleDouble magic */
+#define AD_APPLESINGLE_MAGIC 0x00051600
+#define AD_APPLEDOUBLE_MAGIC 0x00051607
+#define AD_MAGIC             AD_APPLEDOUBLE_MAGIC
+
+/* Sizes of relevant entry bits */
+#define ADEDLEN_MAGIC       4
+#define ADEDLEN_VERSION     4
+#define ADEDLEN_FILLER      16
+#define AD_FILLER_TAG       "Netatalk        " /* should be 16 bytes */
+#define ADEDLEN_NENTRIES    2
+#define AD_HEADER_LEN       (ADEDLEN_MAGIC + ADEDLEN_VERSION + \
+			     ADEDLEN_FILLER + ADEDLEN_NENTRIES) /* 26 */
+#define AD_ENTRY_LEN_EID    4
+#define AD_ENTRY_LEN_OFF    4
+#define AD_ENTRY_LEN_LEN    4
+#define AD_ENTRY_LEN (AD_ENTRY_LEN_EID + AD_ENTRY_LEN_OFF + AD_ENTRY_LEN_LEN)
+


-- 
Samba Shared Repository


More information about the samba-cvs mailing list