]> arthur.barton.de Git - netatalk.git/blob - libatalk/cnid/cdb/cnid_cdb_private.h
Merge master
[netatalk.git] / libatalk / cnid / cdb / cnid_cdb_private.h
1 #ifndef LIBATALK_CDB_PRIVATE_H
2 #define LIBATALK_CDB_PRIVATE_H 1
3
4 #ifdef HAVE_CONFIG_H
5 #include "config.h"
6 #endif /* HAVE_CONFIG_H */
7
8 #include <unistd.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <errno.h>
12 #include <fcntl.h>
13 #include <sys/param.h>
14 #include <sys/stat.h>
15 #include <sys/time.h>
16 #include <time.h>
17 #include <arpa/inet.h>
18
19 #include <db.h>
20
21 #include <atalk/logger.h>
22 #include <atalk/adouble.h>
23 #include <atalk/cnid_private.h>
24 #include <atalk/cnid.h>
25 #include <atalk/util.h>
26 #include "cnid_cdb.h"
27
28 /* record structure 
29    cnid                4
30    dev                 8
31    inode               8
32    type/last cnid      4 Not used    
33    did                 4
34    name                strlen(name) +1
35
36 primary key 
37 cnid
38 secondary keys
39 dev/inode
40 did/name   
41
42 */
43
44 typedef struct cnid_record { /* helper for debug don't use */
45   unsigned int  cnid;
46   dev_t    dev;
47   ino_t    inode;
48   unsigned int  type;
49   unsigned int  did;
50   char          name[50];
51 } cnid_record;
52
53 typedef struct CNID_private {
54     u_int32_t magic;
55     DB *db_cnid;
56     DB *db_didname;
57     DB *db_devino;
58     DB_ENV *dbenv;
59     int lockfd, flags;
60     char lock_file[MAXPATHLEN + 1];
61 } CNID_private;
62
63 /* XXX stuff below is outdate */
64 /* on-disk data format (in network byte order where appropriate) --
65  * db_cnid:      (key: cnid)
66  * name          size (in bytes)
67  * dev           4
68  * ino           4
69  * did           4
70  * unix name     strlen(name) + 1 
71  *
72  * db_didname:   (key: did/unix name)
73  * -- this also caches the bits of .AppleDouble used by FPGetFilDirParam
74  *    so that we don't have to open the header file.
75  *    NOTE: FPCatSearch has to search through all of the directories as
76  *          this stuff doesn't get entered until needed.
77  *          if the entire volume is in the database, though, we can use
78  *          cursor operations to make this faster.
79  *
80  *    version number is stored with did/name key of 0/0
81  *
82  * cnid          4
83  * modfiller     4 (dates only use 4 bytes right now, but we leave space 
84  * moddate       4  for 8. moddate is also used to keep this info 
85  * createfiller  4  up-to-date.)
86  * createdate    4
87  * backfiller    4
88  * backupdate    4
89  * accfiller     4 (unused)
90  * accdate       4 (unused)
91  * AFP info      4 (stores a couple permission bits as well)
92  * finder info   32
93  * prodos info   8
94  * rforkfiller   4
95  * rforklen      4
96  * macname       32 (nul-terminated)
97  * shortname     12 (nul-terminated)
98  * longname      longnamelen (nul-terminated)
99  * ---------------
100  *             132 bytes + longnamelen
101  * 
102  * db_devino:    (key: dev/ino) 
103  * -- this is only used for consistency checks and isn't 1-1
104  * cnid          4 
105  *
106  * these correspond to the different path types. longname is for the
107  * 255 unicode character names (path type == ?), macname is for the
108  * 32-character names (path type == 2), and shortname is for the
109  * 8+3-character names (path type == 1).
110  *
111  * db_longname: (key: did/longname)
112  * name          namelen = strlen(name) + 1
113  *
114  * db_macname:   (key: did/macname)
115  * name          namelen = strlen(name) + 1
116  *
117  * db_shortname: (key: did/shortname)
118  * name namelen = strlen(name) + 1 
119  */
120
121 /* construct db_cnid data. NOTE: this is not re-entrant.  */
122 extern unsigned char *make_cnid_data (u_int32_t flags, const struct stat *,const cnid_t ,
123                                        const char *, const size_t );
124
125 #endif /* atalk/cnid/cnid_private.h */