]> arthur.barton.de Git - netatalk.git/blob - include/atalk/cnid_dbd_private.h
- merge branch-netatalk-afp-3x-dev, HEAD was tagged before
[netatalk.git] / include / atalk / cnid_dbd_private.h
1 /*
2  *  Interface to the cnid_dbd daemon that stores/retrieves CNIDs from a database.
3  */
4
5
6 #ifndef _ATALK_CNID_DBD_PRIVATE_H
7 #define _ATALK_CNID_DBD_PRIVATE_H 1
8
9 #include <sys/stat.h>
10 #include <atalk/adouble.h>
11 #include <sys/param.h>
12
13 #define CNID_DBD_OP_OPEN        0x01
14 #define CNID_DBD_OP_CLOSE       0x02
15 #define CNID_DBD_OP_ADD         0x03
16 #define CNID_DBD_OP_GET         0x04
17 #define CNID_DBD_OP_RESOLVE     0x05
18 #define CNID_DBD_OP_LOOKUP      0x06
19 #define CNID_DBD_OP_UPDATE      0x07
20 #define CNID_DBD_OP_DELETE      0x08
21 #define CNID_DBD_OP_MANGLE_ADD  0x09
22 #define CNID_DBD_OP_MANGLE_GET  0x0a
23 #define CNID_DBD_OP_GETSTAMP    0x0b
24 #define CNID_DBD_OP_REBUILD_ADD 0x0c
25
26 #define CNID_DBD_RES_OK            0x00
27 #define CNID_DBD_RES_NOTFOUND      0x01
28 #define CNID_DBD_RES_ERR_DB        0x02
29 #define CNID_DBD_RES_ERR_MAX       0x03
30 #define CNID_DBD_RES_ERR_DUPLCNID  0x04
31
32 #define CNID_DB_MAGIC   0x434E4944U  /* CNID */
33 #define CNID_DATA_MAGIC 0x434E4945U  /* CNIE */
34
35 #define CNID_OFS                 0
36 #define CNID_LEN                 4
37  
38 #define CNID_DEV_OFS             CNID_LEN
39 #define CNID_DEV_LEN             8
40  
41 #define CNID_INO_OFS             (CNID_DEV_OFS + CNID_DEV_LEN)
42 #define CNID_INO_LEN             8
43  
44 #define CNID_DEVINO_OFS          CNID_LEN
45 #define CNID_DEVINO_LEN          (CNID_DEV_LEN +CNID_INO_LEN)
46  
47 #define CNID_TYPE_OFS            (CNID_DEVINO_OFS +CNID_DEVINO_LEN)
48 #define CNID_TYPE_LEN            4
49  
50 #define CNID_DID_OFS             (CNID_TYPE_OFS +CNID_TYPE_LEN)
51 #define CNID_DID_LEN             CNID_LEN
52  
53 #define CNID_NAME_OFS            (CNID_DID_OFS + CNID_DID_LEN)
54 #define CNID_HEADER_LEN          (CNID_NAME_OFS)
55
56 #define CNID_START               17
57
58 #define CNIDFLAG_ROOTINFO_RO     (1 << 0)
59 #define CNIDFLAG_DB_RO           (1 << 1)
60
61 /* special key/data pair we use to store current cnid and database stamp in cnid2.db */
62
63 #define ROOTINFO_KEY    "\0\0\0\0"
64 #define ROOTINFO_KEYLEN 4
65
66 /*                         cnid   - dev        - inode     - type  - did  - name */
67 #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"
68 #define ROOTINFO_DATALEN (3*4 +2*8  +9)
69
70
71
72
73 struct cnid_dbd_rqst {
74     int     op;
75     cnid_t  cnid;
76     dev_t   dev;
77     ino_t   ino;
78     u_int32_t type;
79     cnid_t  did;
80     char   *name;
81     size_t  namelen;
82 };
83
84 struct cnid_dbd_rply {
85     int     result;    
86     cnid_t  cnid;
87     cnid_t  did;
88     char   *name;
89     size_t  namelen;
90 };
91
92 typedef struct CNID_private {
93     u_int32_t magic;
94     char      db_dir[MAXPATHLEN + 1]; /* Database directory without /.AppleDB appended */
95     int       fd;               /* File descriptor to cnid_dbd */
96     char      stamp[ADEDLEN_PRIVSYN]; /* db timestamp */
97     int       notfirst;   /* already open before */
98     int       changed;  /* stamp differ */
99 } CNID_private;
100
101
102 #endif /* include/atalk/cnid_dbd.h */