2 * $Id: cnid_db3_private.h,v 1.1.4.3.2.2 2008-11-25 15:16:35 didg Exp $
5 #ifndef LIBATALK_CNID_PRIVATE_H
6 #define LIBATALK_CNID_PRIVATE_H 1
13 #endif /* HAVE_UNISTD_H */
14 #include <sys/cdefs.h>
17 #include <atalk/adouble.h>
20 #define CNID_DB_MAGIC 0x434E4944U /* CNID */
21 #define CNID_DATA_MAGIC 0x434E4945U /* CNIE */
23 #define CNID_DEVINO_LEN 8
24 #define CNID_DID_LEN 4
25 #define CNID_HEADER_LEN (CNID_DEVINO_LEN + CNID_DID_LEN)
29 #define CNIDFLAG_ROOTINFO_RO (1 << 0)
30 #define CNIDFLAG_DB_RO (1 << 1)
32 /* the key is in the form of a did/name pair. in this case,
33 * we use 0/RootInfo. */
34 #define ROOTINFO_KEY "\0\0\0\0RootInfo"
35 #define ROOTINFO_KEYLEN 12
37 typedef struct CNID_private {
44 char lock_file[MAXPATHLEN + 1];
47 /* on-disk data format (in network byte order where appropriate) --
48 * db_cnid: (key: cnid)
49 * name size (in bytes)
53 * unix name strlen(name) + 1
55 * db_didname: (key: did/unix name)
56 * -- this also caches the bits of .AppleDouble used by FPGetFilDirParam
57 * so that we don't have to open the header file.
58 * NOTE: FPCatSearch has to search through all of the directories as
59 * this stuff doesn't get entered until needed.
60 * if the entire volume is in the database, though, we can use
61 * cursor operations to make this faster.
63 * version number is stored with did/name key of 0/0
66 * modfiller 4 (dates only use 4 bytes right now, but we leave space
67 * moddate 4 for 8. moddate is also used to keep this info
68 * createfiller 4 up-to-date.)
72 * accfiller 4 (unused)
74 * AFP info 4 (stores a couple permission bits as well)
79 * macname 32 (nul-terminated)
80 * shortname 12 (nul-terminated)
81 * longname longnamelen (nul-terminated)
83 * 132 bytes + longnamelen
85 * db_devino: (key: dev/ino)
86 * -- this is only used for consistency checks and isn't 1-1
89 * these correspond to the different path types. longname is for the
90 * 255 unicode character names (path type == ?), macname is for the
91 * 32-character names (path type == 2), and shortname is for the
92 * 8+3-character names (path type == 1).
94 * db_longname: (key: did/longname)
95 * name namelen = strlen(name) + 1
97 * db_macname: (key: did/macname)
98 * name namelen = strlen(name) + 1
100 * db_shortname: (key: did/shortname)
101 * name namelen = strlen(name) + 1
104 /* construct db_cnid data. NOTE: this is not re-entrant. */
105 static inline unsigned char *make_cnid_data(const struct stat *st,
107 const char *name, const size_t len)
109 static unsigned char start[CNID_HEADER_LEN + MAXPATHLEN + 1];
110 unsigned char *buf = start;
113 if (len > MAXPATHLEN)
116 i = htonl(st->st_dev);
117 buf = memcpy(buf, &i, sizeof(i));
118 i = htonl(st->st_ino);
119 buf = memcpy(buf + sizeof(i), &i, sizeof(i));
120 /* did is already in network byte order */
121 buf = memcpy(buf + sizeof(i), &did, sizeof(did));
122 buf = memcpy(buf + sizeof(did), name, len);
129 #endif /* atalk/cnid/cnid_private.h */