2 * $Id: cnid.h,v 1.15 2010-03-31 09:47:32 franklahm Exp $
4 * Copyright (c) 2003 the Netatalk Team
5 * Copyright (c) 2003 Rafal Lewczuk <rlewczuk@pronet.pl>
7 * This program is free software; you can redistribute and/or modify
8 * it under the terms of the GNU General Public License as published
9 * by the Free Software Foundation version 2 of the License or later
10 * version if explicitly stated by any of above copyright holders.
15 * This file contains all generic CNID related stuff
16 * declarations. Included:
17 * - CNID factory, which retrieves (eventually instantiates)
18 * CNID objects on demand
19 * - selection of CNID backends (default, detected by volume)
20 * - full set of CNID operations needed by server core.
23 #ifndef _ATALK_CNID__H
24 #define _ATALK_CNID__H 1
26 #include <atalk/adouble.h>
27 #include <atalk/list.h>
29 /* CNID object flags */
30 #define CNID_FLAG_PERSISTENT 0x01 /* This backend implements DID persistence */
31 #define CNID_FLAG_MANGLING 0x02 /* This backend has name mangling feature. */
32 #define CNID_FLAG_SETUID 0x04 /* Set db owner to parent folder owner. */
33 #define CNID_FLAG_BLOCK 0x08 /* block signals in update. */
34 #define CNID_FLAG_NODEV 0x10 /* don't use device number only inode */
35 #define CNID_FLAG_LAZY_INIT 0x20 /* */
36 #define CNID_FLAG_MEMORY 0x40 /* this is a memory only db */
37 #define CNID_FLAG_INODE 0x80 /* in cnid_add the inode is authoritative */
39 #define CNID_INVALID 0
43 #define CNID_ERR_PARAM 0x80000001
44 #define CNID_ERR_PATH 0x80000002
45 #define CNID_ERR_DB 0x80000003
46 #define CNID_ERR_CLOSE 0x80000004 /* the db was not open */
47 #define CNID_ERR_MAX 0x80000005
50 * This is instance of CNID database object.
54 u_int32_t flags; /* Flags describing some CNID backend aspects. */
55 char *volpath; /* Volume path this particular CNID db refers to. */
56 void *_private; /* back-end speficic data */
58 cnid_t (*cnid_add)(struct _cnid_db *cdb, const struct stat *st, const cnid_t did,
59 char *name, const size_t, cnid_t hint);
60 int (*cnid_delete)(struct _cnid_db *cdb, cnid_t id);
61 cnid_t (*cnid_get)(struct _cnid_db *cdb, const cnid_t did, char *name, const size_t);
62 cnid_t (*cnid_lookup)(struct _cnid_db *cdb, const struct stat *st, const cnid_t did,
63 char *name, const size_t);
64 cnid_t (*cnid_nextid)(struct _cnid_db *cdb);
65 char *(*cnid_resolve)(struct _cnid_db *cdb, cnid_t *id, void *buffer, size_t len);
66 int (*cnid_update)(struct _cnid_db *cdb, const cnid_t id, const struct stat *st,
67 const cnid_t did, char *name, const size_t len);
68 void (*cnid_close)(struct _cnid_db *cdb);
69 int (*cnid_getstamp)(struct _cnid_db *cdb, void *buffer, const size_t len);
70 cnid_t (*cnid_rebuild_add)(struct _cnid_db *, const struct stat *, const cnid_t,
71 char *, const size_t, cnid_t);
73 typedef struct _cnid_db cnid_db;
76 * Consolidation of args passedn from main cnid_open to modules cnid_XXX_open, so
77 * that it's easier to add aditional args as required.
79 struct cnid_open_args {
83 const char *cnidserver; /* for dbd */
84 const char *cnidport; /* for dbd */
88 * CNID module - represents particular CNID implementation
92 struct list_head db_list; /* CNID modules are also stored on a bidirectional list. */
93 struct _cnid_db *(*cnid_open)(struct cnid_open_args *args);
94 u_int32_t flags; /* Flags describing some CNID backend aspects. */
97 typedef struct _cnid_module cnid_module;
99 /* Inititalize the CNID backends */
102 /* Registers new CNID backend module */
103 void cnid_register(struct _cnid_module *module);
105 /* This function opens a CNID database for selected volume. */
106 struct _cnid_db *cnid_open(const char *volpath,
110 const char *cnidsrv, /* Only for dbd */
111 const char *cnidport); /* Only for dbd */
113 cnid_t cnid_add(struct _cnid_db *cdb, const struct stat *st, const cnid_t did,
114 const char *name, const size_t len, cnid_t hint);
116 int cnid_delete(struct _cnid_db *cdb, cnid_t id);
118 cnid_t cnid_get (struct _cnid_db *cdb, const cnid_t did, char *name,const size_t len);
120 int cnid_getstamp(struct _cnid_db *cdb, void *buffer, const size_t len);
122 cnid_t cnid_lookup(struct _cnid_db *cdb, const struct stat *st, const cnid_t did,
123 char *name, const size_t len);
125 char *cnid_resolve(struct _cnid_db *cdb, cnid_t *id, void *buffer, size_t len);
127 int cnid_update (struct _cnid_db *cdb, const cnid_t id, const struct stat *st,
128 const cnid_t did, char *name, const size_t len);
130 cnid_t cnid_rebuild_add(struct _cnid_db *cdb, const struct stat *st, const cnid_t did,
131 char *name, const size_t len, cnid_t hint);
134 /* This function closes a CNID database and frees all resources assigned to it. */
135 void cnid_close(struct _cnid_db *db);
141 * Revision 1.15 2010-03-31 09:47:32 franklahm
142 * clustering support: new per volume option cnidserver
144 * Revision 1.14 2009/11/28 13:09:25 didg
145 * guard against confused DB returning junk values
147 * Revision 1.13 2009/11/24 12:18:19 didg
148 * add a flag parameter to cnid open functions
150 * Revision 1.12 2005/09/07 15:23:21 didg
152 * lazy init dbd database, help with pre tiger OS and a lot of volumes.
154 * Revision 1.11 2005/05/03 14:55:12 didg
158 * Revision 1.10 2005/04/28 20:49:51 bfernhomberg
160 * - merge branch-netatalk-afp-3x-dev, HEAD was tagged before
162 * Revision 1.9.6.8 2005/04/25 22:33:24 lenneis
163 * Add a new interface to the cdb and dbd backends: cnid_rebuild_add. It
164 * takes dev, ino, did, name and cnid and writes these values unconditionally
165 * into the cnid database. To be used in a recovery tool that writes cnids
166 * cached in AppleDouble files back into the database. Not used yet by
167 * any daemons or command line utilities.
169 * Revision 1.9.6.7 2005/02/08 11:46:59 didg
171 * warnings fixes from 2.0 branch
173 * Revision 1.9.6.6 2004/02/22 18:36:37 didg
177 * Revision 1.9.6.5 2004/01/14 23:15:19 lenneis
178 * Check if we can get a DB stamp sucessfully in afs_openvol and fail
181 * Revision 1.9.6.4 2004/01/10 07:19:31 bfernhomberg
182 * add cnid_init prototype
184 * Revision 1.9.6.3 2004/01/03 22:42:55 didg
186 * better errors handling in afpd for dbd cnid.
188 * Revision 1.9.6.2 2004/01/03 22:21:09 didg
190 * add nodev volume option (always use 0 for device number).
192 * Revision 1.9.6.1 2003/09/09 16:42:20 didg
194 * big merge for db frontend and unicode.
196 * Revision 1.9.4.2 2003/06/11 15:29:11 rlewczuk
197 * Removed obsolete parameter from cnid_add. Spotted by Didier.
199 * Revision 1.9.4.1 2003/05/29 07:53:19 rlewczuk
200 * Selectable CNIDs. Some refactoring. Propably needs more of refactoring, mainly
201 * a well designed API (current API is just an old cnid_* API enclosed in VMT).