/*
- * $Id: cnid_last.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.
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <arpa/inet.h>
/* ------------------------ */
cnid_t cnid_last_add(struct _cnid_db *cdb, const struct stat *st,
- const cnid_t did, char *name, const int len, cnid_t hint)
+ cnid_t did _U_, const char *name _U_, size_t len _U_, cnid_t hint _U_)
{
/* FIXME: it relies on fact, that this is never called twice for the same file/dir. */
struct _cnid_last_private *priv;
- if (!cdb || !(cdb->_private))
+ if (!cdb || !(cdb->cnid_db_private))
return CNID_INVALID;
- priv = (struct _cnid_last_private *) (cdb->_private);
+ priv = (struct _cnid_last_private *) (cdb->cnid_db_private);
if (S_ISDIR(st->st_mode))
return htonl(priv->last_did++);
void cnid_last_close(struct _cnid_db *cdb)
{
- free(cdb->volpath);
- free(cdb->_private);
+ free(cdb->cnid_db_private);
free(cdb);
}
-int cnid_last_delete(struct _cnid_db *cdb, const cnid_t id)
+int cnid_last_delete(struct _cnid_db *cdb _U_, const cnid_t id _U_)
{
return CNID_INVALID;
}
-
/* Return CNID for a given did/name. */
-cnid_t cnid_last_get(struct _cnid_db *cdb, const cnid_t did, char *name, const int len)
+cnid_t cnid_last_get(struct _cnid_db *cdb _U_, cnid_t did _U_, const char *name _U_, size_t len _U_)
{
/* FIXME: it relies on fact, that this is never called twice for the same file/dir. */
/* Propably we should look through DID tree. */
}
-
/* */
-cnid_t cnid_last_lookup(struct _cnid_db *cdb, const struct stat *st, const cnid_t did, char *name, const int len)
+cnid_t cnid_last_lookup(struct _cnid_db *cdb _U_, const struct stat *st _U_, cnid_t did _U_,
+ const char *name _U_, size_t len _U_)
{
/* FIXME: this function doesn't work in [last] scheme ! */
/* Should be never called or CNID should be somewhat refactored again. */
}
-static struct _cnid_db *cnid_last_new(const char *volpath)
+static struct _cnid_db *cnid_last_new(struct vol *vol)
{
struct _cnid_db *cdb;
struct _cnid_last_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_last_private))) == NULL) {
- free(cdb->volpath);
+ if ((cdb->cnid_db_private = calloc(1, sizeof(struct _cnid_last_private))) == NULL) {
free(cdb);
return NULL;
}
/* Set up private state */
- priv = (struct _cnid_last_private *) (cdb->_private);
+ priv = (struct _cnid_last_private *) (cdb->cnid_db_private);
priv->last_did = 17;
/* Set up standard fields */
- cdb->flags = 0;
+ cdb->cnid_db_flags = 0;
cdb->cnid_add = cnid_last_add;
cdb->cnid_delete = cnid_last_delete;
cdb->cnid_get = cnid_last_get;
cdb->cnid_resolve = cnid_last_resolve;
cdb->cnid_update = cnid_last_update;
cdb->cnid_close = cnid_last_close;
-
+ cdb->cnid_wipe = NULL;
+
return cdb;
}
-struct _cnid_db *cnid_last_open(const char *dir, mode_t mask)
+struct _cnid_db *cnid_last_open(struct cnid_open_args *args)
{
struct _cnid_db *cdb;
- if (!dir) {
- return NULL;
- }
-
- if ((cdb = cnid_last_new(dir)) == NULL) {
+ if ((cdb = cnid_last_new(args->cnid_args_vol)) == NULL) {
LOG(log_error, logtype_default, "cnid_open: Unable to allocate memory for database");
return NULL;
}
};
/* Return the did/name pair corresponding to a CNID. */
-char *cnid_last_resolve(struct _cnid_db *cdb, cnid_t * id, void *buffer, u_int32_t len)
+char *cnid_last_resolve(struct _cnid_db *cdb _U_, cnid_t * id _U_, void *buffer _U_, size_t len _U_)
{
/* FIXME: frankly, it does not work. As get, add and other functions. */
return NULL;
}
-int cnid_last_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 */ )
+int cnid_last_update(struct _cnid_db *cdb _U_, cnid_t id _U_, const struct stat *st _U_,
+ cnid_t did _U_, const char *name _U_, size_t len _U_)
{
return 0;
}