1 #ifndef LIBATALK_CNID_PRIVATE_H
2 #define LIBATALK_CNID_PRIVATE_H 1
11 #include <atalk/adouble.h>
12 #include <atalk/cnid.h>
14 #define CNID_DB_MAGIC 0x434E4944U /* CNID */
15 #define CNID_DATA_MAGIC 0x434E4945U /* CNIE */
17 #define CNID_DEVINO_LEN 8
18 #define CNID_DID_LEN 4
19 #define CNID_HEADER_LEN (CNID_DEVINO_LEN + CNID_DID_LEN)
23 #define CNIDFLAG_ROOTINFO_RO (1 << 0)
24 #define CNIDFLAG_DB_RO (1 << 1)
26 typedef struct CNID_private {
28 DB *db_cnid, *db_didname, *db_devino,
29 *db_shortname, *db_macname, *db_longname;
31 struct adouble rootinfo;
35 /* on-disk data format (in network byte order where appropriate) --
36 * db_cnid: (key: cnid)
37 * name size (in bytes)
41 * unix name strlen(name) + 1
43 * db_didname: (key: did/unix name)
44 * -- this also caches the bits of .AppleDouble used by FPGetFilDirParam
45 * so that we don't have to open the header file.
46 * NOTE: FPCatSearch has to search through all of the directories as
47 * this stuff doesn't get entered until needed.
48 * if the entire volume is in the database, though, we can use
49 * cursor operations to make this faster.
51 * version number is stored with did/name key of 0/0
54 * modfiller 4 (dates only use 4 bytes right now, but we leave space
55 * moddate 4 for 8. moddate is also used to keep this info
56 * createfiller 4 up-to-date.)
60 * accfiller 4 (unused)
62 * AFP info 4 (stores a couple permission bits as well)
67 * macname 32 (nul-terminated)
68 * shortname 12 (nul-terminated)
69 * longname longnamelen (nul-terminated)
71 * 132 bytes + longnamelen
73 * db_devino: (key: dev/ino)
74 * -- this is only used for consistency checks and isn't 1-1
77 * these correspond to the different path types. longname is for the
78 * 255 unicode character names (path type == ?), macname is for the
79 * 32-character names (path type == 2), and shortname is for the
80 * 8+3-character names (path type == 1).
82 * db_longname: (key: did/longname)
83 * name namelen = strlen(name) + 1
85 * db_macname: (key: did/macname)
86 * name namelen = strlen(name) + 1
88 * db_shortname: (key: did/shortname)
89 * name namelen = strlen(name) + 1
96 /* construct db_cnid data. NOTE: this is not re-entrant. */
97 static __inline__ char *make_cnid_data(const struct stat *st,
99 const char *name, const int len)
101 static char start[CNID_HEADER_LEN + MAXPATHLEN + 1];
104 if (len > MAXPATHLEN)
107 i = htonl(st->st_dev);
108 memcpy(start, &i, sizeof(i));
109 i = htonl(st->st_ino);
110 memcpy(start + sizeof(i), &i, sizeof(i));
111 /* did is already in network byte order */
112 memcpy(start + CNID_DEVINO_LEN, &did, sizeof(did));
113 memcpy(start + CNID_HEADER_LEN, name, len);
120 #endif /* atalk/cnid/cnid_private.h */