2 * $Id: cnid.h,v 1.10 2005-04-28 20:49:51 bfernhomberg 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 */
36 #define CNID_INVALID 0
38 #define CNID_ERR_PARAM 0x80000001
39 #define CNID_ERR_PATH 0x80000002
40 #define CNID_ERR_DB 0x80000003
41 #define CNID_ERR_CLOSE 0x80000004 /* the db was not open */
42 #define CNID_ERR_MAX 0x80000005
45 * This is instance of CNID database object.
49 u_int32_t flags; /* Flags describing some CNID backend aspects. */
50 char *volpath; /* Volume path this particular CNID db refers to. */
51 void *_private; /* back-end speficic data */
53 cnid_t (*cnid_add)(struct _cnid_db *cdb, const struct stat *st, const cnid_t did,
54 char *name, const int len, cnid_t hint);
55 int (*cnid_delete)(struct _cnid_db *cdb, cnid_t id);
56 cnid_t (*cnid_get)(struct _cnid_db *cdb, const cnid_t did, char *name,
58 cnid_t (*cnid_lookup)(struct _cnid_db *cdb, const struct stat *st, const cnid_t did,
59 char *name, const int len);
60 cnid_t (*cnid_nextid)(struct _cnid_db *cdb);
61 char *(*cnid_resolve)(struct _cnid_db *cdb, cnid_t *id, void *buffer, u_int32_t len);
62 int (*cnid_update)(struct _cnid_db *cdb, const cnid_t id, const struct stat *st,
63 const cnid_t did, char *name, const int len);
64 void (*cnid_close)(struct _cnid_db *cdb);
65 int (*cnid_getstamp)(struct _cnid_db *cdb, void *buffer, const int len);
66 cnid_t (*cnid_rebuild_add)(struct _cnid_db *, const struct stat *, const cnid_t,
67 const char *, const int, cnid_t);
69 typedef struct _cnid_db cnid_db;
72 * CNID module - represents particular CNID implementation
76 struct list_head db_list; /* CNID modules are also stored on a bidirectional list. */
77 struct _cnid_db *(*cnid_open)(const char *dir, mode_t mask);
78 u_int32_t flags; /* Flags describing some CNID backend aspects. */
81 typedef struct _cnid_module cnid_module;
83 /* Inititalize the CNID backends */
86 /* Registers new CNID backend module */
87 void cnid_register(struct _cnid_module *module);
89 /* This function opens a CNID database for selected volume. */
90 struct _cnid_db *cnid_open(const char *volpath, mode_t mask, char *type, int flags);
92 cnid_t cnid_add(struct _cnid_db *cdb, const struct stat *st, const cnid_t did,
93 char *name, const int len, cnid_t hint);
95 int cnid_delete(struct _cnid_db *cdb, cnid_t id);
97 cnid_t cnid_get (struct _cnid_db *cdb, const cnid_t did, char *name,const int len);
99 int cnid_getstamp(struct _cnid_db *cdb, void *buffer, const int len);
101 cnid_t cnid_lookup(struct _cnid_db *cdb, const struct stat *st, const cnid_t did,
102 char *name, const int len);
104 char *cnid_resolve(struct _cnid_db *cdb, cnid_t *id, void *buffer, u_int32_t len);
106 int cnid_update (struct _cnid_db *cdb, const cnid_t id, const struct stat *st,
107 const cnid_t did, char *name, const int len);
109 cnid_t cnid_rebuild_add(struct _cnid_db *cdb, const struct stat *st, const cnid_t did,
110 const char *name, const int len, cnid_t hint);
113 /* This function closes a CNID database and frees all resources assigned to it. */
114 void cnid_close(struct _cnid_db *db);
120 * Revision 1.10 2005-04-28 20:49:51 bfernhomberg
122 * - merge branch-netatalk-afp-3x-dev, HEAD was tagged before
124 * Revision 1.9.6.8 2005/04/25 22:33:24 lenneis
125 * Add a new interface to the cdb and dbd backends: cnid_rebuild_add. It
126 * takes dev, ino, did, name and cnid and writes these values unconditionally
127 * into the cnid database. To be used in a recovery tool that writes cnids
128 * cached in AppleDouble files back into the database. Not used yet by
129 * any daemons or command line utilities.
131 * Revision 1.9.6.7 2005/02/08 11:46:59 didg
133 * warnings fixes from 2.0 branch
135 * Revision 1.9.6.6 2004/02/22 18:36:37 didg
139 * Revision 1.9.6.5 2004/01/14 23:15:19 lenneis
140 * Check if we can get a DB stamp sucessfully in afs_openvol and fail
143 * Revision 1.9.6.4 2004/01/10 07:19:31 bfernhomberg
144 * add cnid_init prototype
146 * Revision 1.9.6.3 2004/01/03 22:42:55 didg
148 * better errors handling in afpd for dbd cnid.
150 * Revision 1.9.6.2 2004/01/03 22:21:09 didg
152 * add nodev volume option (always use 0 for device number).
154 * Revision 1.9.6.1 2003/09/09 16:42:20 didg
156 * big merge for db frontend and unicode.
158 * Revision 1.9.4.2 2003/06/11 15:29:11 rlewczuk
159 * Removed obsolete parameter from cnid_add. Spotted by Didier.
161 * Revision 1.9.4.1 2003/05/29 07:53:19 rlewczuk
162 * Selectable CNIDs. Some refactoring. Propably needs more of refactoring, mainly
163 * a well designed API (current API is just an old cnid_* API enclosed in VMT).