]> arthur.barton.de Git - netatalk.git/commitdiff
remove hash files
authorfranklahm <franklahm>
Tue, 29 Dec 2009 10:02:58 +0000 (10:02 +0000)
committerfranklahm <franklahm>
Tue, 29 Dec 2009 10:02:58 +0000 (10:02 +0000)
12 files changed:
libatalk/cnid/hash/Makefile.am [deleted file]
libatalk/cnid/hash/README [deleted file]
libatalk/cnid/hash/cnid_hash.h [deleted file]
libatalk/cnid/hash/cnid_hash_add.c [deleted file]
libatalk/cnid/hash/cnid_hash_close.c [deleted file]
libatalk/cnid/hash/cnid_hash_delete.c [deleted file]
libatalk/cnid/hash/cnid_hash_get.c [deleted file]
libatalk/cnid/hash/cnid_hash_lookup.c [deleted file]
libatalk/cnid/hash/cnid_hash_nextid.c [deleted file]
libatalk/cnid/hash/cnid_hash_open.c [deleted file]
libatalk/cnid/hash/cnid_hash_resolve.c [deleted file]
libatalk/cnid/hash/cnid_hash_update.c [deleted file]

diff --git a/libatalk/cnid/hash/Makefile.am b/libatalk/cnid/hash/Makefile.am
deleted file mode 100644 (file)
index b3fe934..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-# Makefile.am for libatalk/cnid/
-
-if USE_HASH_BACKEND
-noinst_LTLIBRARIES = libcnid_hash.la
-endif
-
-libcnid_hash_la_SOURCES = cnid_hash_add.c \
-                        cnid_hash_close.c \
-                        cnid_hash_delete.c \
-                        cnid_hash_get.c \
-                        cnid_hash_lookup.c \
-                        cnid_hash_open.c \
-                        cnid_hash_resolve.c \
-                        cnid_hash_update.c \
-                        cnid_hash.h
-
-EXTRA_DIST = README cnid_hash_nextid.c
diff --git a/libatalk/cnid/hash/README b/libatalk/cnid/hash/README
deleted file mode 100644 (file)
index b39889b..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-the catalog database keeps track of three mappings:
-    CNID     -> dev/ino and did/name
-    dev/ino  -> CNID
-    did/name -> CNID
-
-dev/ino is used to keep track of magically moved files. did/name is
-for quick lookups of CNIDs. 
-
-NOTE: the database will append a nul byte to the end of name. in
-addition, name should be given as it appears on disk. this allows the
-creation of cnid updating/cleaning programs that don't have to deal
-with knowing what the particular codepage is.
-
-here's the ritual:
-       1) open a volume. call cnid_open.
-       2) every time you need a CNID, call cnid_add(). it will
-          automatically look for an existing cnid and add a new one
-          if one isn't already there. you can pass a hint if you
-          want. the only use this has right now is to enable
-          consistency between AFP and HFS. in the future, it would
-          allow people to write conversion utilities that
-          pre-instantiate a database without needing to re-assign
-          CNIDs.
-       3) if you want to just look for a CNID without automatically
-          adding one in, you have two choices:
-            a) cnid_resolve takes a CNID, returns name, and
-               over-writes the CNID given with the parent DID. this
-               is good for FPResolveID.
-             b) cnid_lookup returns a CNID corresponding to the
-               dev/ino,did/name keys. it will auto-update the catalog
-               database if there's a discrepancy. 
-               NOTE: cnid_add calls this before adding a new CNID. 
-       4) when you delete a file or directory, you need to call
-          cnid_delete with the CNID for that file/directory.
-       5) call cnid_close when closing the volume.
diff --git a/libatalk/cnid/hash/cnid_hash.h b/libatalk/cnid/hash/cnid_hash.h
deleted file mode 100644 (file)
index a8592ff..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/* 
- * interface for database access to cnids. i do it this way to abstract
- * things a bit in case we want to change the underlying implementation.
- */
-
-#ifndef _ATALK_CNID_HASH__H
-#define _ATALK_CNID_HASH__H 1
-
-#include <sys/cdefs.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <netatalk/endian.h>
-#include <atalk/cnid.h>
-#define STANDALONE 1
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <string.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <signal.h>
-#include <atalk/tdb.h>
-
-#define HASH_ERROR_LINK  1
-#define HASH_ERROR_DEV   2
-#define HASH_ERROR_INODE 4
-
-struct _cnid_hash_private {
-    dev_t  st_dev;
-    int    st_set;
-    int    error;
-    TDB_CONTEXT *tdb;  
-};
-
-/* cnid_open.c */
-extern struct _cnid_module cnid_hash_module;
-extern struct _cnid_db *cnid_hash_open (const char *, mode_t, u_int32_t flags);
-
-/* cnid_close.c */
-extern void cnid_hash_close (struct _cnid_db *);
-
-/* cnid_add.c */
-extern cnid_t cnid_hash_add (struct _cnid_db *, const struct stat *, const cnid_t,
-                                 char *, const int, cnid_t);
-
-/* cnid_get.c */
-extern cnid_t cnid_hash_get (struct _cnid_db *, const cnid_t, char *, const int);
-extern char *cnid_hash_resolve (struct _cnid_db *, cnid_t *, void *, u_int32_t);
-extern cnid_t cnid_hash_lookup (struct _cnid_db *, const struct stat *, const cnid_t, char *, const int);
-
-/* cnid_update.c */
-extern int cnid_hash_update (struct _cnid_db *, const cnid_t, const struct stat *,
-                                 const cnid_t, char *, int);
-
-/* cnid_delete.c */
-extern int cnid_hash_delete (struct _cnid_db *, const cnid_t);
-
-/* cnid_nextid.c */
-extern cnid_t cnid_hash_nextid (struct _cnid_db *);
-
-#endif /* include/atalk/cnid_hash.h */
diff --git a/libatalk/cnid/hash/cnid_hash_add.c b/libatalk/cnid/hash/cnid_hash_add.c
deleted file mode 100644 (file)
index 6bf1607..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * $Id: cnid_hash_add.c,v 1.2 2005-04-28 20:50:01 bfernhomberg Exp $
- *
- * Copyright (c) 1999. Adrian Sun (asun@zoology.washington.edu)
- * All Rights Reserved. See COPYRIGHT.
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif /* HAVE_CONFIG_H */
-
-#ifdef CNID_BACKEND_HASH
-
-#include "cnid_hash.h"
-#include <atalk/util.h>
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <atalk/logger.h>
-
-/* ------------------------ */
-cnid_t cnid_hash_add(struct _cnid_db *cdb, const struct stat *st,
-                     const cnid_t did, char *name, const int len, cnid_t hint)
-{
-    struct stat lst;
-    const struct stat *lstp;
-    cnid_t aint;
-    struct _cnid_hash_private *priv;
-    static char buffer[sizeof(cnid_t) + MAXPATHLEN + 1];        
-    TDB_DATA key, data;       
-    
-    if (!cdb || !(cdb->_private))
-        return CNID_INVALID;
-
-    priv = (struct _cnid_hash_private *) (cdb->_private);
-    lstp = lstat(name, &lst) < 0 ? st : &lst;
-    aint = lstp->st_ino & 0xffffffff;
-
-    if (!priv->st_set) {
-        priv->st_set = 1;
-        priv->st_dev = lstp->st_dev;
-    }
-    if (!(priv->error & HASH_ERROR_DEV)) {
-        if (lstp->st_dev != priv->st_dev) {
-            priv->error |= HASH_ERROR_DEV;
-            LOG(log_error, logtype_default, "cnid_hash_add: %s not on the same device", name);
-        }
-    }
-    if (!(priv->error & HASH_ERROR_LINK)) {
-        if (!S_ISDIR(lstp->st_mode) && lstp->st_nlink > 1) {
-            priv->error |= HASH_ERROR_DEV;
-            LOG(log_error, logtype_default, "cnid_hash_add: %s more than one hardlink", name);
-        }
-    }
-    if (sizeof(ino_t) > 4 && !(priv->error & HASH_ERROR_INODE)) {
-        if (aint != lstp->st_ino) {
-            priv->error |= HASH_ERROR_INODE;
-            LOG(log_error, logtype_default, "cnid_hash_add: %s high bits set, duplicate", name);
-        }
-    }
-    key.dptr = (char *)&aint;
-    key.dsize = sizeof(cnid_t);
-                
-    memcpy(buffer, &did, sizeof(cnid_t));
-    memcpy(buffer+sizeof(cnid_t), name, len +1);
-    data.dptr = buffer;
-    data.dsize = len+1 +sizeof(cnid_t);
-    if (tdb_store(priv->tdb, key, data, TDB_REPLACE)) {
-        LOG(log_error, logtype_default, "cnid_hash_add: unable to add %s", name);
-    }
-    return aint;
-}
-
-#endif /* CNID_BACKEND_HASH */
diff --git a/libatalk/cnid/hash/cnid_hash_close.c b/libatalk/cnid/hash/cnid_hash_close.c
deleted file mode 100644 (file)
index e99bfdf..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * $Id: cnid_hash_close.c,v 1.2 2005-04-28 20:50:01 bfernhomberg Exp $
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif /* HAVE_CONFIG_H */
-
-#ifdef CNID_BACKEND_HASH
-
-#include "cnid_hash.h"
-
-void cnid_hash_close(struct _cnid_db *cdb)
-{
-    struct _cnid_hash_private *db;
-
-    free(cdb->volpath);
-    db = (struct _cnid_hash_private *)cdb->_private;
-    tdb_close(db->tdb);    
-    free(cdb->_private);
-    free(cdb);
-}
-
-#endif /* CNID_BACKEND_HASH */
diff --git a/libatalk/cnid/hash/cnid_hash_delete.c b/libatalk/cnid/hash/cnid_hash_delete.c
deleted file mode 100644 (file)
index 999dfa0..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * $Id: cnid_hash_delete.c,v 1.2 2005-04-28 20:50:01 bfernhomberg Exp $
- *
- * Copyright (c) 1999. Adrian Sun (asun@zoology.washington.edu)
- * All Rights Reserved. See COPYRIGHT.
- *
- * cnid_delete: delete a CNID from the database 
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif /* HAVE_CONFIG_H */
-
-#ifdef CNID_BACKEND_HASH
-
-#include "cnid_hash.h"
-
-int cnid_hash_delete(struct _cnid_db *cdb, const cnid_t id)
-{
-    struct _cnid_hash_private *db;
-    TDB_DATA key;      
-
-    if (!cdb || !(db = cdb->_private) || !id) {
-        return -1;
-    }
-    key.dptr  = (char *)&id;
-    key.dsize = sizeof(cnid_t);
-    tdb_delete(db->tdb, key); 
-
-    return 0;
-}
-
-#endif /* CNID_BACKEND_HASH */
diff --git a/libatalk/cnid/hash/cnid_hash_get.c b/libatalk/cnid/hash/cnid_hash_get.c
deleted file mode 100644 (file)
index db1b542..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * $Id: cnid_hash_get.c,v 1.2 2005-04-28 20:50:01 bfernhomberg Exp $
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif /* HAVE_CONFIG_H */
-
-#ifdef CNID_BACKEND_HASH
-
-#include "cnid_hash.h"
-
-/* Return CNID for a given did/name. */
-cnid_t cnid_hash_get(struct _cnid_db *cdb, const cnid_t did, char *name, const int len)
-{
-    return CNID_INVALID;
-}
-
-#endif /* CNID_BACKEND_HASH */
diff --git a/libatalk/cnid/hash/cnid_hash_lookup.c b/libatalk/cnid/hash/cnid_hash_lookup.c
deleted file mode 100644 (file)
index 13705f4..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * $Id: cnid_hash_lookup.c,v 1.2 2005-04-28 20:50:01 bfernhomberg Exp $
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif /* HAVE_CONFIG_H */
-
-#ifdef CNID_BACKEND_HASH
-
-#include "cnid_hash.h"
-
-cnid_t cnid_hash_lookup(struct _cnid_db *cdb, const struct stat *st, const cnid_t did, char *name, const int len)
-{
-    return cnid_hash_add(cdb, st, did, name, len, 0  /*hint*/);
-}
-
-#endif /* CNID_BACKEND_HASH */
diff --git a/libatalk/cnid/hash/cnid_hash_nextid.c b/libatalk/cnid/hash/cnid_hash_nextid.c
deleted file mode 100644 (file)
index a18d1d8..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * $Id: cnid_hash_nextid.c,v 1.2 2005-04-28 20:50:01 bfernhomberg Exp $
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif /* HAVE_CONFIG_H */
-
-#ifdef CNID_BACKEND_HASH
-
-#include "cnid_hash.h"
-
-cnid_t cnid_hash_nextid(struct _cnid_db *cdb)
-{
-    return CNID_INVALID;
-}
-
-#endif /* CNID_BACKEND_HASH */
diff --git a/libatalk/cnid/hash/cnid_hash_open.c b/libatalk/cnid/hash/cnid_hash_open.c
deleted file mode 100644 (file)
index 11ce7e4..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * $Id: cnid_hash_open.c,v 1.3 2009-11-24 12:18:20 didg Exp $
- *
- * Copyright (c) 1999. Adrian Sun (asun@zoology.washington.edu)
- * All Rights Reserved. See COPYRIGHT.
- *
- */
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifdef CNID_BACKEND_HASH
-#include <sys/param.h>   
-
-#include "cnid_hash.h"
-#include <atalk/logger.h>
-#include <stdlib.h>
-#define DBHOME       ".AppleDB" 
-#define DBNAME       "private_tdb.%sX"
-#define DBHOMELEN    9
-#define DBLEN        24 
-
-static struct _cnid_db *cnid_hash_new(const char *volpath)
-{
-    struct _cnid_db *cdb;
-    struct _cnid_hash_private *priv;
-
-    if ((cdb = (struct _cnid_db *) calloc(1, sizeof(struct _cnid_db))) == NULL)
-        return NULL;
-
-    if ((cdb->volpath = strdup(volpath)) == NULL) {
-        free(cdb);
-        return NULL;
-    }
-
-    if ((cdb->_private = calloc(1, sizeof(struct _cnid_hash_private))) == NULL) {
-        free(cdb->volpath);
-        free(cdb);
-        return NULL;
-    }
-
-    /* Set up private state */
-    priv = (struct _cnid_hash_private *) (cdb->_private);
-
-    /* Set up standard fields */
-    cdb->flags = CNID_FLAG_PERSISTENT;
-
-    cdb->cnid_add = cnid_hash_add;
-    cdb->cnid_delete = cnid_hash_delete;
-    cdb->cnid_get = cnid_hash_get;
-    cdb->cnid_lookup = cnid_hash_lookup;
-    cdb->cnid_nextid = NULL;    /*cnid_hash_nextid;*/
-    cdb->cnid_resolve = cnid_hash_resolve;
-    cdb->cnid_update = cnid_hash_update;
-    cdb->cnid_close = cnid_hash_close;
-    
-    return cdb;
-}
-
-/* ---------------------------- */
-struct _cnid_db *cnid_hash_open(const char *dir, mode_t mask, u_int32_t flags _U_)
-{
-    struct stat               st;
-    struct _cnid_db           *cdb;
-    struct _cnid_hash_private *db;
-    size_t                    len;
-    char                      path[MAXPATHLEN + 1];
-    
-    if (!dir) {
-        return NULL;
-    }
-
-    if ((len = strlen(dir)) > (MAXPATHLEN - DBLEN - 1)) {
-        LOG(log_error, logtype_default, "cnid_open: Pathname too large: %s", dir);
-        return NULL;
-    }
-    
-    if ((cdb = cnid_hash_new(dir)) == NULL) {
-        LOG(log_error, logtype_default, "cnid_open: Unable to allocate memory for hash");
-        return NULL;
-    }
-    strcpy(path, dir);
-    if (path[len - 1] != '/') {
-        strcat(path, "/");
-        len++;
-    }
-    strcpy(path + len, DBHOME);
-    if ((stat(path, &st) < 0) && (ad_mkdir(path, 0777 & ~mask) < 0)) {
-        LOG(log_error, logtype_default, "cnid_open: DBHOME mkdir failed for %s", path);
-        goto fail;
-    }
-    strcat(path, "/");
-    path[len + DBHOMELEN] = '\0';
-    strcat(path, DBNAME);
-    db = (struct _cnid_hash_private *)cdb->_private;
-    db->tdb = tdb_open(path, 0, TDB_CLEAR_IF_FIRST | TDB_INTERNAL, O_RDWR | O_CREAT | O_TRUNC, 0600);
-    if (!db->tdb) {
-        LOG(log_error, logtype_default, "cnid_open: unable to open tdb", path);
-        goto fail;
-    }
-
-    return cdb;
-
-fail:
-    free(cdb->_private);
-    free(cdb->volpath);
-    free(cdb);
-    
-    return NULL;
-}
-
-struct _cnid_module cnid_hash_module = {
-    "hash",
-    {NULL, NULL},
-    cnid_hash_open,
-};
-
-
-#endif /* CNID_BACKEND_HASH */
diff --git a/libatalk/cnid/hash/cnid_hash_resolve.c b/libatalk/cnid/hash/cnid_hash_resolve.c
deleted file mode 100644 (file)
index d0d26f0..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * $Id: cnid_hash_resolve.c,v 1.2 2005-04-28 20:50:01 bfernhomberg Exp $
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif /* HAVE_CONFIG_H */
-
-#ifdef CNID_BACKEND_HASH
-
-#include "cnid_hash.h"
-
-/* Return the did/name pair corresponding to a CNID. */
-char *cnid_hash_resolve(struct _cnid_db *cdb, cnid_t * id, void *buffer, u_int32_t len)
-{
-    struct _cnid_hash_private *db;
-    TDB_DATA key, data;      
-
-    if (!cdb || !(db = cdb->_private) || !id || !(*id)) {
-        return NULL;
-    }
-    key.dptr  = (char *)id;
-    key.dsize = sizeof(cnid_t);
-    data = tdb_fetch(db->tdb, key);
-    if (data.dptr) 
-    {
-        if (data.dsize < len && data.dsize > sizeof(cnid_t)) {
-            memcpy(id, data.dptr, sizeof(cnid_t));
-            memcpy(buffer, data.dptr +sizeof(cnid_t), data.dsize -sizeof(cnid_t));
-            free(data.dptr);
-            return buffer;
-        }
-        free(data.dptr);
-    }
-    return NULL;
-}
-
-#endif /* CNID_BACKEND_HASH */
diff --git a/libatalk/cnid/hash/cnid_hash_update.c b/libatalk/cnid/hash/cnid_hash_update.c
deleted file mode 100644 (file)
index e70da0d..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * $Id: cnid_hash_update.c,v 1.2 2005-04-28 20:50:01 bfernhomberg Exp $
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif /* HAVE_CONFIG_H */
-
-#ifdef CNID_BACKEND_HASH
-
-#include "cnid_hash.h"
-
-int cnid_hash_update(struct _cnid_db *cdb, const cnid_t id, const struct stat *st,
-                     const cnid_t did, char *name, const int len
-                     /*, const char *info, const int infolen */ )
-{
-    return 0;
-}
-
-#endif  /* CNID_BACKEND_HASH */