]> arthur.barton.de Git - netatalk.git/commitdiff
Merge master
authorFrank Lahm <franklahm@googlemail.com>
Wed, 10 Nov 2010 13:04:03 +0000 (14:04 +0100)
committerFrank Lahm <franklahm@googlemail.com>
Wed, 10 Nov 2010 13:04:03 +0000 (14:04 +0100)
configure.in
include/atalk/adouble.h
libatalk/adouble/ad_open.c

index ec3a24fde37c898266d4b429edb268cee4fd25f3..9f8ef7b8f1ec69cfb1691e2f4e5fa652d7b6b7ee 100644 (file)
@@ -21,9 +21,11 @@ AC_PROG_LIBTOOL
 AC_PROG_PERL
 AC_PROG_GREP
 AC_PROG_PS
-
 AM_PROG_CC_C_O
 
+dnl Request SUSv4 standard interfaces
+CFLAGS="$CFLAGS -D_XOPEN_SOURCE=700"
+
 dnl Checks for header files.
 AC_HEADER_DIRENT
 AC_HEADER_STDC
index 53337c789f113a27c25c6c3436affedc89b4019e..b125fc74784b1e86112fa2422512d664760b3c82 100644 (file)
@@ -1,5 +1,4 @@
 /*
- * $Id: adouble.h,v 1.55 2010-03-30 12:55:26 franklahm Exp $
  * Copyright (c) 1990,1991 Regents of The University of Michigan.
  * All Rights Reserved.
  *
 #include <config.h>
 #endif
 
-/* -------------------
- * need pread() and pwrite()
- */
-#ifdef HAVE_PREAD
-
-#ifndef HAVE_PWRITE
-#undef HAVE_PREAD
-#endif
-
-#endif
-
-#ifdef HAVE_PWRITE
-#ifndef HAVE_PREAD
-#undef HAVE_PWRITE
-#endif
-#endif
-
-/*
-  Still have to figure out which platforms really
-  need _XOPEN_SOURCE defined for pread.
-*/
-#if defined(HAVE_PREAD) && !defined(SOLARIS) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__FreeBSD__) && !defined(TRU64)
-#ifndef _XOPEN_SOURCE
-#define _XOPEN_SOURCE 500
-#endif
-#endif
-
 #include <sys/types.h>
 #include <sys/stat.h>
-
-#ifdef HAVE_UNISTD_H
-#undef __USE_MISC
-#define __USE_MISC
 #include <unistd.h>
-#endif
-
 #include <sys/cdefs.h>
-
-#ifdef HAVE_FCNTL_H
 #include <fcntl.h>
-#endif
-
 #include <sys/mman.h>
-#ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
-#endif
+
 #include <netatalk/endian.h>
 
 /* version info */
-#define AD_VERSION1     0x00010000
-#define SFM_VERSION     AD_VERSION1
-
 #define AD_VERSION2     0x00020000
 #define AD_VERSION2_OSX 0x00020001
-/*
-  #define AD_VERSION1_ADS 0x00010002
-*/
-#define AD_VERSION1_SFM 0x00010003
-#define AD_VERSION      AD_VERSION2
+#define AD_VERSION2_EA  0x00020002
+#define AD_VERSION      AD_VERSION2_EA
 
 /*
  * AppleDouble entry IDs.
  */
 #define ADEID_DFORK         1
 #define ADEID_RFORK         2
-#define ADEID_NAME          3 /* Note: starting with Netatalk 2.1 we do NOT alway set the name */
+#define ADEID_NAME          3
 #define ADEID_COMMENT       4
 #define ADEID_ICONBW        5
 #define ADEID_ICONCOL       6
 #define ADEID_AFPFILEI      14 /* where the rest of the FILEI info goes */
 #define ADEID_DID           15
 
-#if AD_VERSION == AD_VERSION1
-#define ADEID_MAX           16
-#else
 /* netatalk private note fileid reused DID */
 #define ADEID_PRIVDEV       16
 #define ADEID_PRIVINO       17
 #define ADEID_PRIVSYN       18 /* in synch with database */
 #define ADEID_PRIVID        19
-#define ADEID_SFMRESERVE1   20
-#define ADEID_SFMRESERVE2   21
+#define ADEID_MAX           19
 
+/* These are the real ids for these entries, as stored in the adouble file */
 #define AD_DEV              0x80444556
 #define AD_INO              0x80494E4F
 #define AD_SYN              0x8053594E
 #define AD_ID               0x8053567E
-#define ADEID_MAX           22
-#endif
 
 /* magic */
 #define AD_APPLESINGLE_MAGIC 0x00051600
 #define AD_APPLEDOUBLE_MAGIC 0x00051607
 #define AD_MAGIC             AD_APPLEDOUBLE_MAGIC
-#define SFM_MAGIC            0x00504641
 
 /* sizes of relevant entry bits */
 #define ADEDLEN_MAGIC       4
 #define ADEDLEN_VERSION     4
 #define ADEDLEN_FILLER      16
 #define ADEDLEN_NENTRIES    2
-
-/* 26 */
-#define AD_HEADER_LEN       (ADEDLEN_MAGIC + ADEDLEN_VERSION + \
-                             ADEDLEN_FILLER + ADEDLEN_NENTRIES)
+#define AD_HEADER_LEN       (ADEDLEN_MAGIC + ADEDLEN_VERSION + ADEDLEN_FILLER + ADEDLEN_NENTRIES)
 #define AD_ENTRY_LEN        12  /* size of a single entry header */
 
-/* v1 field widths */
-#define ADEDLEN_NAME        255
-#define ADEDLEN_COMMENT     200
-#define ADEDLEN_FILEI       16
-#define ADEDLEN_FINDERI     32
-
-/* v2 field widths */
+/* field widths */
+#define ADEDLEN_NAME            255
+#define ADEDLEN_COMMENT         200
+#define ADEDLEN_FILEI           16
+#define ADEDLEN_FINDERI         32
 #define ADEDLEN_FILEDATESI      16
 #define ADEDLEN_SHORTNAME       12 /* length up to 8.3 */
 #define ADEDLEN_AFPFILEI        4
 #define ADEDLEN_PRIVSYN         8
 #define ADEDLEN_PRIVID          4
 
-#define ADEID_NUM_V1            5
 #define ADEID_NUM_V2            13
-
-// #define ADEID_NUM_SFM        5
-/* sizeof SFM meta data */
-#define AD_SFM_LEN 60
-
-/* 589 */
-#define AD_DATASZ1      (AD_HEADER_LEN + ADEDLEN_NAME + ADEDLEN_COMMENT + ADEDLEN_FILEI + ADEDLEN_FINDERI + \
-                         (ADEID_NUM_V1 * AD_ENTRY_LEN))
-
-#if AD_DATASZ1 != 589
-#error bad size for AD_DATASZ1
-#endif
-
-#define AD_NEWSZ2       (ADEDLEN_DID + ADEDLEN_AFPFILEI + ADEDLEN_SHORTNAME + ADEDLEN_PRODOSFILEI \
-                         + ADEDLEN_PRIVDEV + ADEDLEN_PRIVINO + ADEDLEN_PRIVSYN + ADEDLEN_PRIVID)
-
-/* 725 */
-#define AD_DATASZ2      (AD_DATASZ1 + AD_NEWSZ2 + ((ADEID_NUM_V2 - ADEID_NUM_V1) * AD_ENTRY_LEN))
-
+#define ADEID_NUM_OSX           2
+#define ADEID_NUM_EA            5
+#define AD_DATASZ2 (AD_HEADER_LEN + ADEDLEN_NAME + ADEDLEN_COMMENT + ADEDLEN_FILEI + \
+                    ADEDLEN_FINDERI + ADEDLEN_DID + ADEDLEN_AFPFILEI + ADEDLEN_SHORTNAME + \
+                    ADEDLEN_PRODOSFILEI + ADEDLEN_PRIVDEV + ADEDLEN_PRIVINO + \
+                    ADEDLEN_PRIVSYN + ADEDLEN_PRIVID + (ADEID_NUM_V2 * AD_ENTRY_LEN))
 #if AD_DATASZ2 != 741
 #error bad size for AD_DATASZ2
 #endif
 
-#define AD_DATASZ_MAX   1024
-#if AD_VERSION == AD_VERSION1
-#define AD_DATASZ   AD_DATASZ1 /* hold enough for the entries */
-#elif AD_VERSION == AD_VERSION2
-#define AD_DATASZ   AD_DATASZ2
+#define AD_DATASZ_EA (AD_HEADER_LEN + (ADEID_NUM_EA * AD_ENTRY_LEN) + ADEID_FINDERI + \
+                      ADEID_COMMENT + ADEID_FILEDATESI + ADEID_AFPFILEI + ADEID_PRIVID)
+#if AD_DATASZ_EA != 342
+#error bad size for AD_DATASZ_EA
 #endif
 
-/*
- * some legacy defines from netatalk-990130
- * (to keep from breaking certain packages)
- *
- */
-
-#define ADEDOFF_RFORK   589
-#define ADEDOFF_NAME    86
-#define ADEDOFF_COMMENT 341
-#define ADEDOFF_FINDERI 557
-#ifndef ADEDOFF_FILEI
-#define ADEDOFF_FILEI   541
+#define AD_DATASZ_MAX   1024
+#if AD_VERSION == AD_VERSION2
+#define AD_DATASZ   AD_DATASZ2
+#elif AD_VERSION == AD_VERSION2_EA
+#define AD_DATASZ   AD_DATASZ_EA
 #endif
 
 typedef u_int32_t cnid_t;
 
-/*
- * The header of the AppleDouble Header File looks like this:
- *
- *  NAME            SIZE
- *  ====            ====
- *  Magic           4
- *  Version         4
- *  Home File System    16  (this becomes filler in ad v2)
- *  Number of Entries   2
- *  Entry Descriptors for each entry:
- *      Entry ID    4
- *      Offset      4
- *      Length      4
- */
-
 struct ad_entry {
-    u_int32_t   ade_off;
-    u_int32_t   ade_len;
+    uint32_t   ade_off;
+    uint32_t   ade_len;
 };
 
 typedef struct adf_lock_t {
@@ -243,11 +150,9 @@ typedef struct adf_lock_t {
 
 struct ad_fd {
     int          adf_fd;        /* -1: invalid, -2: symlink */
-
 #ifndef HAVE_PREAD
     off_t        adf_off;
 #endif
-
     char         *adf_syml;
     int          adf_flags;
     int          adf_excl;
@@ -257,7 +162,15 @@ struct ad_fd {
 
 /* some header protection */
 #define AD_INITED  0xad494e54  /* ad"INT" */
-struct adouble_fops;
+
+struct adouble_fops {
+    char *(*ad_path)(const char *, int);
+    int  (*ad_mkrf)(char *);
+    int  (*ad_rebuild_header)(struct adouble *);
+    int  (*ad_check_header)(struct adouble *, struct stat *);
+    int  (*ad_header_read)(struct adouble *, struct stat *);
+    int  (*ad_header_upgrade)(struct adouble *, char *);
+};
 
 struct adouble {
     u_int32_t           ad_magic;
@@ -266,7 +179,6 @@ struct adouble {
     struct ad_entry     ad_eid[ ADEID_MAX ];
     struct ad_fd        ad_data_fork, ad_resource_fork, ad_metadata_fork;
     struct ad_fd        *ad_md; /* either ad_resource or ad_metadata */
-
     int                 ad_flags;    /* This really stores version info too (AD_VERSION*) */
     int                 ad_adflags;  /* ad_open flags adflags like ADFLAGS_DIR */
     unsigned int        ad_inited;
@@ -274,13 +186,11 @@ struct adouble {
     int                 ad_fileordir;
     int                 ad_refcount; /* used in afpd/ofork.c */
     off_t               ad_rlen;     /* ressource fork len with AFP 3.0
-                                        the header parameter size is too small.
-                                     */
+                                        the header parameter size is too small. */
     char                *ad_m_name;   /* mac name for open fork */
     int                 ad_m_namelen;
     struct adouble_fops *ad_ops;
     u_int16_t       ad_open_forks;      /* open forks (by others) */
-
 #ifdef USE_MMAPPED_HEADERS
     char                *ad_data;
 #else
@@ -288,21 +198,9 @@ struct adouble {
 #endif
 };
 
-struct adouble_fops {
-    char *(*ad_path)(const char *, int);
-    int  (*ad_mkrf)(char *);
-    int  (*ad_rebuild_header)(struct adouble *);
-    int  (*ad_check_header)(struct adouble *, struct stat *);
-    int  (*ad_header_read)(struct adouble *, struct stat *);
-    int  (*ad_header_upgrade)(struct adouble *, char *);
-};
-
 #define ADFLAGS_DF        (1<<0)
 #define ADFLAGS_HF        (1<<1)
 #define ADFLAGS_DIR       (1<<2)
-/*
-#define ADFLAGS_NOADOUBLE (1<<3)
-*/
 #define ADFLAGS_V1COMPAT  (1<<4)
 #define ADFLAGS_NOHF      (1<<5)  /* not an error if no ressource fork */
 #define ADFLAGS_RDONLY    (1<<6)  /* don't try readwrite */
@@ -311,7 +209,6 @@ struct adouble_fops {
 #define ADFLAGS_MD        ADFLAGS_HF /* (1<<9) */
 #define ADFLAGS_CREATE    (1<<9)
 
-/* adouble v2 cnid cache */
 #define ADVOL_NODEV      (1 << 0)
 #define ADVOL_CACHE      (1 << 1)
 #define ADVOL_UNIXPRIV   (1 << 2) /* adouble unix priv */
@@ -554,22 +451,15 @@ extern int ad_getdate (const struct adouble *, unsigned int, u_int32_t *);
 /* ad_attr.c */
 extern int       ad_setattr (const struct adouble *, const u_int16_t);
 extern int       ad_getattr (const struct adouble *, u_int16_t *);
-
-/* Note: starting with Netatalk 2.1 we do NOT alway set the name */
 extern int       ad_setname (struct adouble *, const char *);
-
-#if AD_VERSION == AD_VERSION2
 extern int       ad_setid (struct adouble *, const dev_t dev,const ino_t ino, const u_int32_t, const u_int32_t, const void *);
 extern u_int32_t ad_getid (struct adouble *, const dev_t, const ino_t, const cnid_t, const void *);
 extern u_int32_t ad_forcegetid (struct adouble *adp);
-#else
-#define ad_setid(a, b, c)
-#endif
 
 #ifdef WITH_SENDFILE
 extern int ad_readfile_init(const struct adouble *ad, 
-                                      const int eid, off_t *off,
-                                      const int end);
+                            const int eid, off_t *off,
+                            const int end);
 #endif
 
 #if 0
index 7adb4abda262c7261a8197463d36f9369a2a7426..1c0e7921563ef339d3c55de81fa87958d7ee5401 100644 (file)
 #endif /* HAVE_CONFIG_H */
 
 #include <errno.h>
-
-#include <atalk/adouble.h>
 #include <sys/param.h>
-#include <atalk/logger.h>
+#include <stdlib.h>
+#include <string.h>
 
+#include <atalk/logger.h>
+#include <atalk/adouble.h>
 #include <atalk/util.h>
-#include <string.h>
 
 #include "ad_private.h"
-#include <stdlib.h>
 
 #ifndef MAX
 #define MAX(a, b)  ((a) < (b) ? (b) : (a))
@@ -74,9 +73,6 @@
  *
  * so, all we need to do is replace FILEI with FILEDATESI, move RFORK,
  * and add in the new fields.
- *
- * NOTE: the HFS module will need similar modifications to interact with
- * afpd correctly.
  */
 
 #define ADEDOFF_MAGIC        (0)
 #define ADEDOFF_COMMENT_V2   (ADEDOFF_NAME_V2 + ADEDLEN_NAME)
 #define ADEDOFF_FILEDATESI   (ADEDOFF_COMMENT_V2 + ADEDLEN_COMMENT)
 #define ADEDOFF_FINDERI_V2   (ADEDOFF_FILEDATESI + ADEDLEN_FILEDATESI)
-#define ADEDOFF_DID      (ADEDOFF_FINDERI_V2 + ADEDLEN_FINDERI)
+#define ADEDOFF_DID          (ADEDOFF_FINDERI_V2 + ADEDLEN_FINDERI)
 #define ADEDOFF_AFPFILEI     (ADEDOFF_DID + ADEDLEN_DID)
 #define ADEDOFF_SHORTNAME    (ADEDOFF_AFPFILEI + ADEDLEN_AFPFILEI)
 #define ADEDOFF_PRODOSFILEI  (ADEDOFF_SHORTNAME + ADEDLEN_SHORTNAME)
 #define ADEDOFF_PRIVINO      (ADEDOFF_PRIVDEV + ADEDLEN_PRIVDEV)
 #define ADEDOFF_PRIVSYN      (ADEDOFF_PRIVINO + ADEDLEN_PRIVINO)
 #define ADEDOFF_PRIVID       (ADEDOFF_PRIVSYN + ADEDLEN_PRIVSYN)
-
 #define ADEDOFF_RFORK_V2     (ADEDOFF_PRIVID + ADEDLEN_PRIVID)
 
-#define ADEID_NUM_OSX        2
 #define ADEDOFF_FINDERI_OSX  (AD_HEADER_LEN + ADEID_NUM_OSX*AD_ENTRY_LEN)
 #define ADEDOFF_RFORK_OSX    (ADEDOFF_FINDERI_OSX + ADEDLEN_FINDERI)
 
 
 
 struct entry {
-    u_int32_t id, offset, len;
+    uint32_t id, offset, len;
 };
 
-static const struct entry entry_order1[ADEID_NUM_V1 +1] = {
-    {ADEID_NAME,    ADEDOFF_NAME_V1,    ADEDLEN_INIT},      /* 3 */
-    {ADEID_COMMENT, ADEDOFF_COMMENT_V1, ADEDLEN_INIT},      /* 4 */
-    {ADEID_FILEI,   ADEDOFF_FILEI,      ADEDLEN_FILEI},     /* 7 */
-    {ADEID_FINDERI, ADEDOFF_FINDERI_V1, ADEDLEN_FINDERI},   /* 9 */
-    {ADEID_RFORK,   ADEDOFF_RFORK_V1,   ADEDLEN_INIT},      /* 2 */
-    {0, 0, 0}
-};
-
-#if AD_VERSION == AD_VERSION1
-#define DISK_EID(ad, a) (a)
-
-#else /* AD_VERSION == AD_VERSION2 */
-
-static u_int32_t get_eid(struct adouble *ad, u_int32_t eid)
+static uint32_t get_eid(struct adouble *ad, u_int32_t eid)
 {
     if (eid <= 15)
         return eid;
-    if (ad->ad_version == AD_VERSION1)
-        return 0;
     if (eid == AD_DEV)
         return ADEID_PRIVDEV;
     if (eid == AD_INO)
@@ -167,7 +145,7 @@ static u_int32_t get_eid(struct adouble *ad, u_int32_t eid)
 
 #define DISK_EID(ad, a) get_eid(ad, a)
 
-static const struct entry entry_order2[ADEID_NUM_V2 +1] = {
+static const struct entry entry_order2[ADEID_NUM_V2 + 1] = {
     {ADEID_NAME, ADEDOFF_NAME_V2, ADEDLEN_INIT},
     {ADEID_COMMENT, ADEDOFF_COMMENT_V2, ADEDLEN_INIT},
     {ADEID_FILEDATESI, ADEDOFF_FILEDATESI, ADEDLEN_FILEDATESI},
@@ -181,32 +159,26 @@ static const struct entry entry_order2[ADEID_NUM_V2 +1] = {
     {ADEID_PRIVSYN,     ADEDOFF_PRIVSYN, ADEDLEN_INIT},
     {ADEID_PRIVID,     ADEDOFF_PRIVID, ADEDLEN_INIT},
     {ADEID_RFORK, ADEDOFF_RFORK_V2, ADEDLEN_INIT},
-
     {0, 0, 0}
 };
 
-/* OS X adouble finder info and resource fork only
- */
-static const struct entry entry_order_osx[ADEID_NUM_OSX +1] = {
+/* OS X adouble finder info and resource fork only */
+static const struct entry entry_order_osx[ADEID_NUM_OSX + 1] = {
     {ADEID_FINDERI, ADEDOFF_FINDERI_OSX, ADEDLEN_FINDERI},
     {ADEID_RFORK, ADEDOFF_RFORK_OSX, ADEDLEN_INIT},
-
     {0, 0, 0}
 };
 
-#define ADEID_NUM_SFM 3
-static const struct entry entry_order_sfm[ADEID_NUM_SFM +1] = {
-    {ADEID_FINDERI,     16,         ADEDLEN_FINDERI},   /* 9 */
-    {ADEID_SFMRESERVE2, 16+32,      6},                 /* 21 */
-    {ADEID_FILEI,       60,         ADEDLEN_FILEI},     /* 7 */
-
+/* Using Extended Attributes */
+static const struct entry entry_order_ea[ADEID_NUM_EA + 1] = {
+    {ADEID_FINDERI, ADEDOFF_FINDERI_OSX, ADEDLEN_FINDERI},
+    {ADEID_COMMENT, ADEDOFF_COMMENT_V2, ADEDLEN_INIT},
+    {ADEID_FILEDATESI, ADEDOFF_FILEDATESI, ADEDLEN_FILEDATESI},
+    {ADEID_AFPFILEI, ADEDOFF_AFPFILEI, ADEDLEN_AFPFILEI},
+    {ADEID_PRIVID,     ADEDOFF_PRIVID, ADEDLEN_INIT},
     {0, 0, 0}
 };
 
-#endif /* AD_VERSION == AD_VERSION2 */
-
-#if AD_VERSION == AD_VERSION2
-
 /* update a version 2 adouble resource fork with our private entries */
 static int ad_update(struct adouble *ad, const char *path)
 {
@@ -487,7 +459,6 @@ bail_lock:
 bail_err:
     return ret;
 }
-#endif /* AD_VERSION == AD_VERSION2 */
 
 /* -------------------------------------
    read in the entries
@@ -522,6 +493,9 @@ static void parse_entries(struct adouble *ad, char *buf,
     }
 }
 
+/***********************************************************************
+ * adouble v2 scheme funcs
+ ***********************************************************************/
 
 /* this reads enough of the header so that we can figure out all of
  * the entry lengths and offsets. once that's done, we just read/mmap
@@ -575,11 +549,8 @@ static int ad_header_read(struct adouble *ad, struct stat *hst)
         ad->ad_version = ntohl( ad->ad_version );
     }
 
-    if ((ad->ad_magic != AD_MAGIC) || ((ad->ad_version != AD_VERSION1)
-#if AD_VERSION == AD_VERSION2
-                                       && (ad->ad_version != AD_VERSION2)
-#endif /* AD_VERSION == AD_VERSION2 */
-            )) {
+    if ((ad->ad_magic != AD_MAGIC) ||
+        ((ad->ad_version != AD_VERSION1) && (ad->ad_version != AD_VERSION2))) {
         LOG(log_debug, logtype_default, "ad_open: can't parse AppleDouble header.");
         errno = EIO;
         return -1;
@@ -648,114 +619,7 @@ static int ad_header_read(struct adouble *ad, struct stat *hst)
     return 0;
 }
 
-/* ---------------------------
-   SFM structure
-*/
-#if 0
-typedef struct {
-    byte    afpi_Signature[4];      /* Must be 0x00504641 */
-    byte    afpi_Version[4];        /* Must be 0x00010000 */
-    byte    afpi_Reserved1[4];
-    byte    afpi_BackupTime[4];     /* Backup time for the file/dir */
-    byte    finderinfo[32];         /* Finder info */
-    byte    afpi_ProDosInfo[6];     /* ProDos Info */
-    byte    afpi_Reserved2[6];
-} sfm_info;
-#endif
-
-static int ad_header_sfm_read(struct adouble *ad, struct stat *hst)
-{
-    char                *buf = ad->ad_data;
-    const struct entry  *eid;
-    ssize_t             header_len;
-    struct stat         st;
-
-    /* read the header */
-    if ((header_len = adf_pread( ad->ad_md, buf, sizeof(ad->ad_data), 0)) < 0) {
-        return -1;
-    }
-    if (header_len != AD_SFM_LEN) {
-        errno = EIO;
-        return -1;
-    }
-
-    memcpy(&ad->ad_magic, buf, sizeof( ad->ad_magic ));
-    memcpy(&ad->ad_version, buf + 4, sizeof( ad->ad_version ));
-
-    /* FIXME in the great Microsoft tradition they aren't in network order */
-#if 0
-    if (ad->ad_magic == SFM_MAGIC && ad->ad_version == AD_VERSION1) {
-        static int          warning = 0;
-        if (!warning) {
-            LOG(log_debug, logtype_default, "notice: fixing up byte-swapped v1 magic/version.");
-            warning++;
-        }
-
-    } else {
-        ad->ad_magic = ntohl( ad->ad_magic );
-        ad->ad_version = ntohl( ad->ad_version );
-    }
-#endif
-    if ((ad->ad_magic != SFM_MAGIC) || ((ad->ad_version != AD_VERSION1) )) {
-        errno = EIO;
-        LOG(log_debug, logtype_default, "ad_header_sfm_read: can't parse AppleDouble header.");
-        return -1;
-    }
-
-    /* reinit adouble table */
-    eid = entry_order_sfm;
-    while (eid->id) {
-        ad->ad_eid[eid->id].ade_off = eid->offset;
-        ad->ad_eid[eid->id].ade_len = eid->len;
-        eid++;
-    }
-
-    /* steal some prodos for attribute */
-    {
-
-        u_int16_t attribute;
-        memcpy(&attribute, buf + 48 +4, sizeof(attribute));
-        ad_setattr(ad, attribute );
-    }
-
-    if (ad->ad_resource_fork.adf_fd != -1) {
-        /* we have a resource fork use it rather than the metadata */
-        if (fstat(ad->ad_resource_fork.adf_fd, &st) < 0) {
-            /* XXX set to zero ?
-               ad->ad_rlen =  0;
-            */
-            return 1;
-        }
-        ad->ad_rlen = st.st_size;
-        hst = &st;
-    }
-    else if (hst == NULL) {
-        hst = &st;
-        if (fstat(ad->ad_md->adf_fd, &st) < 0) {
-            return 1; /* fail silently */
-        }
-    }
-
-    /* fix up broken dates */
-    if (ad->ad_version == AD_VERSION1) {
-        u_int32_t aint;
-
-        /* check to see if the ad date is wrong. just see if we have
-         * a modification date in the future. */
-        if (((ad_getdate(ad, AD_DATE_MODIFY | AD_DATE_UNIX, &aint)) == 0) &&
-            (aint > TIMEWARP_DELTA + hst->st_mtime)) {
-            ad_setdate(ad, AD_DATE_MODIFY | AD_DATE_UNIX, aint - AD_DATE_DELTA);
-            ad_getdate(ad, AD_DATE_CREATE | AD_DATE_UNIX, &aint);
-            ad_setdate(ad, AD_DATE_CREATE | AD_DATE_UNIX, aint - AD_DATE_DELTA);
-            ad_getdate(ad, AD_DATE_BACKUP | AD_DATE_UNIX, &aint);
-            ad_setdate(ad, AD_DATE_BACKUP | AD_DATE_UNIX, aint - AD_DATE_DELTA);
-        }
-    }
-
-    return 0;
-}
-
-/* ---------------------------------------
+/*
  * Put the .AppleDouble where it needs to be:
  *
  *      /   a/.AppleDouble/b
@@ -764,8 +628,7 @@ static int ad_header_sfm_read(struct adouble *ad, struct stat *hst)
  *
  * FIXME: should do something for pathname > MAXPATHLEN
  */
-char *
-ad_path( const char *path, int adflags)
+char *ad_path( const char *path, int adflags)
 {
     static char pathbuf[ MAXPATHLEN + 1];
     const char *slash;
@@ -797,7 +660,6 @@ ad_path( const char *path, int adflags)
     return( pathbuf );
 }
 
-/* -------------------- */
 static int ad_mkrf(char *path)
 {
     char *slash;
@@ -816,12 +678,15 @@ static int ad_mkrf(char *path)
     return 0;
 }
 
-/* ---------------------------------------
- * Put the resource fork where it needs to be:
- * ._name
+
+/***********************************************************************
+ * OS X adouble scheme funcs
+ ***********************************************************************/
+
+/*
+ * Put the resource fork where it needs to be: ._name
  */
-char *
-ad_path_osx(const char *path, int adflags _U_)
+char *ad_path_osx(const char *path, int adflags _U_)
 {
     static char pathbuf[ MAXPATHLEN + 1];
     char    c, *slash, buf[MAXPATHLEN + 1];
@@ -846,88 +711,10 @@ ad_path_osx(const char *path, int adflags _U_)
     strlcat( pathbuf, slash, MAXPATHLEN +1);
     return pathbuf;
 }
-/* -------------------- */
-static int ad_mkrf_osx(char *path _U_)
-{
-    return 0;
-}
-
-/* ---------------------------------------
- * Put the .AppleDouble where it needs to be:
- *
- *      /   a/.AppleDouble/b/AFP_AfpInfo
- *  a/b
- *      \   b/.AppleDouble/.Parent/AFP_AfpInfo
- *
- */
-char *
-ad_path_sfm( const char *path, int adflags)
-{
-    static char pathbuf[ MAXPATHLEN + 1];
-    char    c, *slash, buf[MAXPATHLEN + 1];
-    size_t      l;
-
-    l = strlcpy(buf, path, MAXPATHLEN +1);
-    if ( adflags & ADFLAGS_DIR ) {
-        strcpy( pathbuf, buf);
-        if ( *buf != '\0' && l < MAXPATHLEN) {
-            pathbuf[l++] = '/';
-            pathbuf[l] = 0;
-        }
-        slash = ".Parent";
-    } else {
-        if (NULL != ( slash = strrchr( buf, '/' )) ) {
-            c = *++slash;
-            *slash = '\0';
-            strcpy( pathbuf, buf);
-            *slash = c;
-        } else {
-            pathbuf[ 0 ] = '\0';
-            slash = buf;
-        }
-    }
-    strlcat( pathbuf, ".AppleDouble/", MAXPATHLEN +1);
-    strlcat( pathbuf, slash, MAXPATHLEN +1);
-
-    if ((adflags == ADFLAGS_RF)) {
-        strlcat( pathbuf, "/AFP_Resource", MAXPATHLEN +1);
-    }
-    else {
-        strlcat( pathbuf, "/AFP_AfpInfo", MAXPATHLEN +1);
-    }
-    return( pathbuf );
-}
 
 /* -------------------- */
-static int ad_mkrf_sfm(char *path)
+static int ad_mkrf_osx(char *path _U_)
 {
-    char *slash;
-    /*
-     * Probably .AppleDouble doesn't exist, try to mkdir it.
-     */
-    if (NULL == ( slash = strrchr( path, '/' )) ) {
-        return -1;
-    }
-    *slash = 0;
-    errno = 0;
-    if ( ad_mkdir( path, 0777 ) < 0 ) {
-        if ( errno == ENOENT ) {
-            char *slash1;
-
-            if (NULL == ( slash1 = strrchr( path, '/' )) )
-                return -1;
-            errno = 0;
-            *slash1 = 0;
-            if ( ad_mkdir( path, 0777 ) < 0 )
-                return -1;
-            *slash1 = '/';
-            if ( ad_mkdir( path, 0777 ) < 0 )
-                return -1;
-        }
-        else
-            return -1;
-    }
-    *slash = '/';
     return 0;
 }
 
@@ -939,8 +726,7 @@ static int ad_mkrf_sfm(char *path)
 
 #define DEFMASK 07700   /* be conservative */
 
-char
-*ad_dir(const char *path)
+char *ad_dir(const char *path)
 {
     static char     modebuf[ MAXPATHLEN + 1];
     char        *slash;
@@ -1133,12 +919,10 @@ static int ad_check_size_sfm(struct adouble *ad _U_, struct stat *st)
 /* --------------------------- */
 static int ad_header_upgrade(struct adouble *ad, char *name)
 {
-#if AD_VERSION == AD_VERSION2
     int ret;
     if ( (ret = ad_convert(ad, name)) < 0 || (ret = ad_update(ad, name) < 0)) {
         return ret;
     }
-#endif
     return 0;
 }
 
@@ -1154,31 +938,27 @@ static struct adouble_fops ad_osx = {
     &ad_mkrf_osx,
     &ad_rebuild_adouble_header,
     &ad_check_size,
-
     &ad_header_read,
     &ad_header_upgrade,
 };
 
-static struct adouble_fops ad_sfm = {
-    &ad_path_sfm,
-    &ad_mkrf_sfm,
-    &ad_rebuild_sfm_header,
-    &ad_check_size_sfm,
-
-    &ad_header_sfm_read,
-    &ad_header_upgrade_none,
-};
-
 static struct adouble_fops ad_adouble = {
     &ad_path,
     &ad_mkrf,
     &ad_rebuild_adouble_header,
     &ad_check_size,
-
     &ad_header_read,
     &ad_header_upgrade,
 };
 
+static struct adouble_fops ad_adouble_ea = {
+    &ad_path,
+    &ad_mkrf,
+    &ad_rebuild_adouble_header,
+    &ad_check_size,
+    &ad_header_read,
+    &ad_header_upgrade,
+};
 
 void ad_init(struct adouble *ad, int flags, int options)
 {
@@ -1188,22 +968,20 @@ void ad_init(struct adouble *ad, int flags, int options)
         ad->ad_ops = &ad_osx;
         ad->ad_md = &ad->ad_resource_fork;
     }
-    else if (flags == AD_VERSION1_SFM) {
-        ad->ad_ops = &ad_sfm;
-        ad->ad_md = &ad->ad_metadata_fork;
-    }
-    else {
+    else if (flags == AD_VERSION2) {
         ad->ad_ops = &ad_adouble;
         ad->ad_md = &ad->ad_resource_fork;
     }
+    else {
+        ad->ad_ops = &ad_adouble_ea;
+        ad->ad_md = &ad->ad_metadata_fork;
+    }
     ad->ad_options = options;
 
     ad_data_fileno(ad) = -1;
     ad_reso_fileno(ad) = -1;
     ad_meta_fileno(ad) = -1;
-    /* following can be read even if there's no
-     * meda data.
-     */
+    /* following can be read even if there's no meda data. */
     memset(ad->ad_eid, 0, sizeof( ad->ad_eid ));
     ad->ad_rlen = 0;
 }
@@ -1218,7 +996,6 @@ void ad_init(struct adouble *ad, int flags, int options)
  * @endcode
  *
  * @param path    Path to file or directory
- *
  * @param adflags ADFLAGS_DF: open data file/fork\n
  *                ADFLAGS_HF: open header (metadata) file\n
  *                ADFLAGS_RF: open ressource fork *** FIXME: not used ?! *** \n
@@ -1230,15 +1007,12 @@ void ad_init(struct adouble *ad, int flags, int options)
  *                ADFLAGS_OPENFORKS: check for open forks from other processes\n
  *                ADFLAGS_MD: alias for ADFLAGS_HF\n
  *                ADFLAGS_V1COMPAT: obsolete
- *
  * @param oflags  flags passed through to open syscall: \n
  *                O_RDONLY: *** FIXME *** \n
  *                O_RDWR: *** FIXME *** \n
  *                O_CREAT: create fork\n
  *                O_EXCL: fail if exists with O_CREAT
- *
  * @param mode    passed to open with O_CREAT
- *
  * @param ad      pointer to struct adouble
  *
  * @returns 0 on success
@@ -1632,18 +1406,13 @@ static int new_rfork(const char *path, struct adouble *ad, int adflags)
     memset(ad->ad_filler, 0, sizeof( ad->ad_filler ));
     memset(ad->ad_data, 0, sizeof(ad->ad_data));
 
-#if AD_VERSION == AD_VERSION2
     if (ad->ad_flags == AD_VERSION2)
         eid = entry_order2;
     else if (ad->ad_flags == AD_VERSION2_OSX)
         eid = entry_order_osx;
-    else  if (ad->ad_flags == AD_VERSION1_SFM) {
-        ad->ad_magic = SFM_MAGIC;
-        eid = entry_order_sfm;
+    else {
+        eid = entry_order_ea;
     }
-    else
-#endif
-        eid = entry_order1;
 
     while (eid->id) {
         ad->ad_eid[eid->id].ade_off = eid->offset;