]> arthur.barton.de Git - netatalk.git/blob - include/atalk/cnid.h
add cnid_init prototype
[netatalk.git] / include / atalk / cnid.h
1 /* 
2  * $Id: cnid.h,v 1.9.6.4 2004-01-10 07:19:31 bfernhomberg Exp $
3  *
4  * Copyright (c) 2003 the Netatalk Team
5  * Copyright (c) 2003 Rafal Lewczuk <rlewczuk@pronet.pl>
6  * 
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.
11  *
12  */
13
14 /* 
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.
21  */
22
23 #ifndef _ATALK_CNID__H
24 #define _ATALK_CNID__H 1
25
26 #include <sys/cdefs.h>
27 #include <atalk/adouble.h>
28 #include <atalk/list.h>
29
30 /* CNID object flags */
31 #define CNID_FLAG_PERSISTENT   0x01      /* This backend implements DID persistence */
32 #define CNID_FLAG_MANGLING     0x02      /* This backend has name mangling feature. */
33 #define CNID_FLAG_SETUID       0x04      /* Set db owner to parent folder owner. */
34 #define CNID_FLAG_BLOCK        0x08      /* block signals in update. */
35 #define CNID_FLAG_NODEV        0x10      /* don't use device number only inode */
36
37 #define CNID_INVALID   0
38
39 #define CNID_ERR_PARAM 0x80000001
40 #define CNID_ERR_PATH  0x80000002
41 #define CNID_ERR_DB    0x80000003
42 #define CNID_ERR_CLOSE 0x80000004   /* the db was not open */
43 #define CNID_ERR_MAX   0x80000005
44
45 /*
46  * This is instance of CNID database object.
47  */
48 struct _cnid_db {
49         
50         u_int32_t flags;             /* Flags describing some CNID backend aspects. */
51         char *volpath;               /* Volume path this particular CNID db refers to. */
52         void *_private;              /* back-end speficic data */
53
54         cnid_t (*cnid_add)(struct _cnid_db *cdb, const struct stat *st, const cnid_t did, 
55                         const char *name, const int len, cnid_t hint);
56         int (*cnid_delete)(struct _cnid_db *cdb, cnid_t id);
57         cnid_t (*cnid_get)(struct _cnid_db *cdb, const cnid_t did, const char *name,
58                         const int len);
59         cnid_t (*cnid_lookup)(struct _cnid_db *cdb, const struct stat *st, const cnid_t did,
60                         const char *name, const int len);
61         cnid_t (*cnid_nextid)(struct _cnid_db *cdb);
62         char *(*cnid_resolve)(struct _cnid_db *cdb, cnid_t *id, void *buffer, u_int32_t len);
63         int (*cnid_update)(struct _cnid_db *cdb, const cnid_t id, const struct stat *st, 
64                         const cnid_t did, const char *name, const int len);     
65         void (*cnid_close)(struct _cnid_db *cdb);
66         int  (*cnid_getstamp)(struct _cnid_db *cdb, void *buffer, const int len);
67 };
68 typedef struct _cnid_db cnid_db;
69
70 /*
71  * CNID module - represents particular CNID implementation
72  */
73 struct _cnid_module {
74         char *name;
75         struct list_head db_list;   /* CNID modules are also stored on a bidirectional list. */
76         struct _cnid_db *(*cnid_open)(const char *dir, mode_t mask);
77         u_int32_t flags;            /* Flags describing some CNID backend aspects. */
78
79 };
80 typedef struct _cnid_module cnid_module;
81
82 /* Inititalize the CNID backends */
83 void cnid_init();
84
85 /* Registers new CNID backend module */
86 void cnid_register(struct _cnid_module *module);
87
88 /* This function opens a CNID database for selected volume. */
89 struct _cnid_db *cnid_open(const char *volpath, mode_t mask, char *type, int flags);
90
91 cnid_t cnid_add(struct _cnid_db *cdb, const struct stat *st, const cnid_t did, 
92                         const char *name, const int len, cnid_t hint);
93
94 int    cnid_delete(struct _cnid_db *cdb, cnid_t id);
95
96 cnid_t cnid_get   (struct _cnid_db *cdb, const cnid_t did, const char *name,const int len);
97
98 cnid_t cnid_getstamp(struct _cnid_db *cdb, void *buffer, const int len);
99
100 cnid_t cnid_lookup(struct _cnid_db *cdb, const struct stat *st, const cnid_t did,
101                         const char *name, const int len);
102
103 char *cnid_resolve(struct _cnid_db *cdb, cnid_t *id, void *buffer, u_int32_t len);
104
105 int cnid_update   (struct _cnid_db *cdb, const cnid_t id, const struct stat *st, 
106                         const cnid_t did, const char *name, const int len);     
107
108 /* This function closes a CNID database and frees all resources assigned to it. */ 
109 void cnid_close(struct _cnid_db *db);
110
111 #endif
112
113 /*
114  * $Log: cnid.h,v $
115  * Revision 1.9.6.4  2004-01-10 07:19:31  bfernhomberg
116  * add cnid_init prototype
117  *
118  * Revision 1.9.6.3  2004/01/03 22:42:55  didg
119  *
120  * better errors handling in afpd for dbd cnid.
121  *
122  * Revision 1.9.6.2  2004/01/03 22:21:09  didg
123  *
124  * add nodev volume option (always use 0 for device number).
125  *
126  * Revision 1.9.6.1  2003/09/09 16:42:20  didg
127  *
128  * big merge for db frontend and unicode.
129  *
130  * Revision 1.9.4.2  2003/06/11 15:29:11  rlewczuk
131  * Removed obsolete parameter from cnid_add. Spotted by Didier.
132  *
133  * Revision 1.9.4.1  2003/05/29 07:53:19  rlewczuk
134  * Selectable CNIDs. Some refactoring. Propably needs more of refactoring, mainly
135  * a well designed API (current API is just an old cnid_* API enclosed in VMT).
136  *
137  */
138