2 * $Id: cnid_private.h,v 1.3.2.1 2001-12-03 05:05:50 jmarcus 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 /* 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 {
46 #endif /* EXTENDED_DB */
51 /* on-disk data format (in network byte order where appropriate) --
52 * db_cnid: (key: cnid)
53 * name size (in bytes)
57 * unix name strlen(name) + 1
59 * db_didname: (key: did/unix name)
60 * -- this also caches the bits of .AppleDouble used by FPGetFilDirParam
61 * so that we don't have to open the header file.
62 * NOTE: FPCatSearch has to search through all of the directories as
63 * this stuff doesn't get entered until needed.
64 * if the entire volume is in the database, though, we can use
65 * cursor operations to make this faster.
67 * version number is stored with did/name key of 0/0
70 * modfiller 4 (dates only use 4 bytes right now, but we leave space
71 * moddate 4 for 8. moddate is also used to keep this info
72 * createfiller 4 up-to-date.)
76 * accfiller 4 (unused)
78 * AFP info 4 (stores a couple permission bits as well)
83 * macname 32 (nul-terminated)
84 * shortname 12 (nul-terminated)
85 * longname longnamelen (nul-terminated)
87 * 132 bytes + longnamelen
89 * db_devino: (key: dev/ino)
90 * -- this is only used for consistency checks and isn't 1-1
93 * these correspond to the different path types. longname is for the
94 * 255 unicode character names (path type == ?), macname is for the
95 * 32-character names (path type == 2), and shortname is for the
96 * 8+3-character names (path type == 1).
98 * db_longname: (key: did/longname)
99 * name namelen = strlen(name) + 1
101 * db_macname: (key: did/macname)
102 * name namelen = strlen(name) + 1
104 * db_shortname: (key: did/shortname)
105 * name namelen = strlen(name) + 1
110 #endif /* __inline__ */
112 /* construct db_cnid data. NOTE: this is not re-entrant. */
113 static __inline__ char *make_cnid_data(const struct stat *st,
115 const char *name, const int len)
117 static char start[CNID_HEADER_LEN + MAXPATHLEN + 1];
121 if (len > MAXPATHLEN)
124 i = htonl(st->st_dev);
125 buf = memcpy(buf, &i, sizeof(i));
126 i = htonl(st->st_ino);
127 buf = memcpy(buf + sizeof(i), &i, sizeof(i));
128 /* did is already in network byte order */
129 buf = memcpy(buf + sizeof(i), &did, sizeof(did));
130 buf = memcpy(buf + sizeof(did), name, len);
137 #endif /* atalk/cnid/cnid_private.h */