2 * $Id: cnid_private.h,v 1.2 2001-06-29 14:14:46 rufustfirefly Exp $
5 #ifndef LIBATALK_CNID_PRIVATE_H
6 #define LIBATALK_CNID_PRIVATE_H 1
13 #endif /* HAVE_UNISTD_H */
17 #include <atalk/adouble.h>
18 #include <atalk/cnid.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 typedef struct CNID_private {
34 DB *db_cnid, *db_didname, *db_devino,
35 *db_shortname, *db_macname, *db_longname;
37 struct adouble rootinfo;
41 /* on-disk data format (in network byte order where appropriate) --
42 * db_cnid: (key: cnid)
43 * name size (in bytes)
47 * unix name strlen(name) + 1
49 * db_didname: (key: did/unix name)
50 * -- this also caches the bits of .AppleDouble used by FPGetFilDirParam
51 * so that we don't have to open the header file.
52 * NOTE: FPCatSearch has to search through all of the directories as
53 * this stuff doesn't get entered until needed.
54 * if the entire volume is in the database, though, we can use
55 * cursor operations to make this faster.
57 * version number is stored with did/name key of 0/0
60 * modfiller 4 (dates only use 4 bytes right now, but we leave space
61 * moddate 4 for 8. moddate is also used to keep this info
62 * createfiller 4 up-to-date.)
66 * accfiller 4 (unused)
68 * AFP info 4 (stores a couple permission bits as well)
73 * macname 32 (nul-terminated)
74 * shortname 12 (nul-terminated)
75 * longname longnamelen (nul-terminated)
77 * 132 bytes + longnamelen
79 * db_devino: (key: dev/ino)
80 * -- this is only used for consistency checks and isn't 1-1
83 * these correspond to the different path types. longname is for the
84 * 255 unicode character names (path type == ?), macname is for the
85 * 32-character names (path type == 2), and shortname is for the
86 * 8+3-character names (path type == 1).
88 * db_longname: (key: did/longname)
89 * name namelen = strlen(name) + 1
91 * db_macname: (key: did/macname)
92 * name namelen = strlen(name) + 1
94 * db_shortname: (key: did/shortname)
95 * name namelen = strlen(name) + 1
100 #endif /* __inline__ */
102 /* construct db_cnid data. NOTE: this is not re-entrant. */
103 static __inline__ char *make_cnid_data(const struct stat *st,
105 const char *name, const int len)
107 static char start[CNID_HEADER_LEN + MAXPATHLEN + 1];
110 if (len > MAXPATHLEN)
113 i = htonl(st->st_dev);
114 memcpy(start, &i, sizeof(i));
115 i = htonl(st->st_ino);
116 memcpy(start + sizeof(i), &i, sizeof(i));
117 /* did is already in network byte order */
118 memcpy(start + CNID_DEVINO_LEN, &did, sizeof(did));
119 memcpy(start + CNID_HEADER_LEN, name, len);
126 #endif /* atalk/cnid/cnid_private.h */