]> arthur.barton.de Git - netatalk.git/blob - libatalk/cnid/cdb/cnid_cdb_private.h
remove gcc warnings and cleanup inline mess
[netatalk.git] / libatalk / cnid / cdb / cnid_cdb_private.h
1 /*
2  * $Id: cnid_cdb_private.h,v 1.1.4.7.2.2 2008-11-25 15:16:34 didg Exp $
3  */
4
5 #ifndef LIBATALK_CDB_PRIVATE_H
6 #define LIBATALK_CDB_PRIVATE_H 1
7
8 #ifdef HAVE_CONFIG_H
9 #include "config.h"
10 #endif /* HAVE_CONFIG_H */
11
12 #include <netatalk/endian.h>
13
14 #ifdef HAVE_UNISTD_H
15 #include <unistd.h>
16 #endif /* HAVE_UNISTD_H */
17 #include <stdlib.h>
18 #include <string.h>
19 #include <errno.h>
20 #ifdef HAVE_FCNTL_H
21 #include <fcntl.h>
22 #endif /* HAVE_FCNTL_H */
23 #include <sys/param.h>
24 #include <sys/stat.h>
25 #ifdef HAVE_SYS_TIME_H
26 #include <sys/time.h>
27 #endif /* HAVE_SYS_TIME_H */
28 #ifdef HAVE_TIME_H
29 #include <time.h>
30 #endif
31 #include <sys/cdefs.h>
32 #include <db.h>
33
34 #include <atalk/logger.h>
35 #include <atalk/adouble.h>
36 #include <atalk/cnid.h>
37 #include <atalk/util.h>
38 #include "cnid_cdb.h"
39
40 #define CNID_DB_MAGIC   0x434E4944U  /* CNID */
41 #define CNID_DATA_MAGIC 0x434E4945U  /* CNIE */
42
43 /* record structure 
44    cnid                4
45    dev                 8
46    inode               8
47    type/last cnid      4 Not used    
48    did                 4
49    name                strlen(name) +1
50
51 primary key 
52 cnid
53 secondary keys
54 dev/inode
55 did/name   
56
57 */
58
59 typedef struct cnid_record { /* helper for debug don't use */
60   unsigned int  cnid;
61   dev_t    dev;
62   ino_t    inode;
63   unsigned int  type;
64   unsigned int  did;
65   char          name[50];
66 } cnid_record;
67
68 #define CNID_OFS                 0
69 #define CNID_LEN                 4
70
71 #define CNID_DEV_OFS             CNID_LEN
72 #define CNID_DEV_LEN             8
73
74 #define CNID_INO_OFS             (CNID_DEV_OFS + CNID_DEV_LEN)
75 #define CNID_INO_LEN             8
76
77 #define CNID_DEVINO_OFS          CNID_LEN
78 #define CNID_DEVINO_LEN          (CNID_DEV_LEN +CNID_INO_LEN)
79
80 #define CNID_TYPE_OFS            (CNID_DEVINO_OFS +CNID_DEVINO_LEN)
81 #define CNID_TYPE_LEN            4
82
83 #define CNID_DID_OFS             (CNID_TYPE_OFS +CNID_TYPE_LEN)
84 #define CNID_DID_LEN             CNID_LEN
85
86 #define CNID_NAME_OFS            (CNID_DID_OFS + CNID_DID_LEN)
87 #define CNID_HEADER_LEN          (CNID_NAME_OFS)
88
89 #define CNID_START               17
90
91 #define CNIDFLAG_ROOTINFO_RO     (1 << 0)
92 #define CNIDFLAG_DB_RO           (1 << 1)
93
94 /* the key is cnid 0 
95  * we use 0/RootInfo. */
96 #define ROOTINFO_KEY    "\0\0\0\0"
97 #define ROOTINFO_KEYLEN 4
98
99 /*                         cnid   - dev        - inode     - type  - did  - name */
100 #define ROOTINFO_DATA    "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0RootInfo"
101 #define ROOTINFO_DATALEN (3*4 +2*8  +9)
102
103
104 typedef struct CNID_private {
105     u_int32_t magic;
106     DB *db_cnid;
107     DB *db_didname;
108     DB *db_devino;
109     DB_ENV *dbenv;
110     int lockfd, flags;
111     char lock_file[MAXPATHLEN + 1];
112 } CNID_private;
113
114 /* on-disk data format (in network byte order where appropriate) --
115  * db_cnid:      (key: cnid)
116  * name          size (in bytes)
117  * dev           4
118  * ino           4
119  * did           4
120  * unix name     strlen(name) + 1 
121  *
122  * db_didname:   (key: did/unix name)
123  * -- this also caches the bits of .AppleDouble used by FPGetFilDirParam
124  *    so that we don't have to open the header file.
125  *    NOTE: FPCatSearch has to search through all of the directories as
126  *          this stuff doesn't get entered until needed.
127  *          if the entire volume is in the database, though, we can use
128  *          cursor operations to make this faster.
129  *
130  *    version number is stored with did/name key of 0/0
131  *
132  * cnid          4
133  * modfiller     4 (dates only use 4 bytes right now, but we leave space 
134  * moddate       4  for 8. moddate is also used to keep this info 
135  * createfiller  4  up-to-date.)
136  * createdate    4
137  * backfiller    4
138  * backupdate    4
139  * accfiller     4 (unused)
140  * accdate       4 (unused)
141  * AFP info      4 (stores a couple permission bits as well)
142  * finder info   32
143  * prodos info   8
144  * rforkfiller   4
145  * rforklen      4
146  * macname       32 (nul-terminated)
147  * shortname     12 (nul-terminated)
148  * longname      longnamelen (nul-terminated)
149  * ---------------
150  *             132 bytes + longnamelen
151  * 
152  * db_devino:    (key: dev/ino) 
153  * -- this is only used for consistency checks and isn't 1-1
154  * cnid          4 
155  *
156  * these correspond to the different path types. longname is for the
157  * 255 unicode character names (path type == ?), macname is for the
158  * 32-character names (path type == 2), and shortname is for the
159  * 8+3-character names (path type == 1).
160  *
161  * db_longname: (key: did/longname)
162  * name          namelen = strlen(name) + 1
163  *
164  * db_macname:   (key: did/macname)
165  * name          namelen = strlen(name) + 1
166  *
167  * db_shortname: (key: did/shortname)
168  * name namelen = strlen(name) + 1 
169  */
170
171 /* construct db_cnid data. NOTE: this is not re-entrant.  */
172 extern unsigned char *make_cnid_data __P((const struct stat *,const cnid_t ,
173                                        const char *, const size_t ));
174
175 #endif /* atalk/cnid/cnid_private.h */