make-install-support-for-transarc-and-prefix-style-universes-20010907
[openafs.git] / src / util / dirpath.hin
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #ifndef _DIRPATH_H
11 #define _DIRPATH_H
12
13 /* Dirpath package: Rationale and Usage
14  *
15  * With the port of AFS to Windows NT, it becomes necessary to support
16  * storing AFS system files (binaries, logs, etc.) in a user-specified
17  * installation directory.  This breaks from the traditional notion of
18  * all AFS system files being stored under /usr/afs or /usr/vice.
19  * In addition, now that OpenAFs supports configure, it is desirable
20  * to support the configure options for manipulating directories and
21   * setting the compilation prefix.
22  * For NT, the core concept is that there is a dynamically determined installation
23  * directory that is the prefix to a well-known AFS tree.  The structure
24  * of this well-known AFS tree remains unchanged.  For example, AFS server
25  * binaries reside in <install dir>/usr/afs/bin, server configuration files
26  * reside in <install dir>/usr/afs/etc, etcetera.  This scheme allows the
27  * flexibility required by NT.
28  * On UNIX, this header file is generated by configure.  Directory
29  * paths are substituted in based on options passed to configure.
30  * While  the server and client roots are maintained in the dirpath
31  * array,  they should never be used by the code as they tend to be 
32  * meaningless.
33  * Thus file paths can no longer be hard-coded; rather, all file paths are
34  * specified via the macros provided by this package.
35  *
36  * Utilizing a dynamically determined installation directory forces the
37  * notion of local versus canonical (wire-format) paths.  A local path is
38  * fully qualified (with a syntax determined by the native filesystem type)
39  * whereas a canonical path specifies location only within the well-known AFS
40  * tree.  Supporting the notion of canonical paths allows the same path to
41  * be sent to servers on different machines, having different installation
42  * directories, with the desired result.
43  *
44  * For example, 'bos create <mach> kaserver simple /usr/afs/bin/kasever' will
45  * work both on a Unix machine, where the kaserver executable actually resides
46  * in /usr/afs/bin, and on a NT machine, where the kaserver may reside in
47  * C:/Program Files/Transarc/AFS Server/usr/afs/bin.
48  *
49  * Conversion functions are provided that translate canonical (wire-format)
50  * paths to fully qualified local paths; see the documentation in dirpath.c
51  * for details.  Note that these conversion functions also try to 
52  * accomodate fully qualified paths on the wire, for exceptional 
53  * cases where this feature may be required.    Unfortunately there is 
54  * no way to distinguish between canonical and fully qualified paths
55  * so if for example /usr/afs/bin is both a valid canonical and local 
56  * path and they do not both map to the same place, then the canonical
57  * path  is used.
58  *
59  * The path macros provided here are divided into local (AFSDIR_*) and
60  * canonical (AFSDIR_CANONICAL_*).  The canonical macros MUST be used by
61  * commands that send a non-user-specified path to a server (i.e., over
62  * the wire).  The local macros MUST be used in all other cases.
63  */
64
65
66
67 #include <afs/param.h>
68
69 #ifdef AFS_NT40_ENV
70 #include <windef.h>
71 #endif
72 #include <limits.h>
73
74 /* Max dir path size for afs install dirs */
75 #ifdef AFS_NT40_ENV
76 #define AFSDIR_PATH_MAX MAX_PATH
77 #else /* unices */
78 #define AFSDIR_PATH_MAX    _POSIX_PATH_MAX
79 #endif
80  
81
82 /* ---------------------  Exported functions ---------------------- */
83
84
85 #define AFSDIR_CLIENT_PATHS_OK 0x1   /* client paths initialized correctly */
86 #define AFSDIR_SERVER_PATHS_OK 0x2   /* server paths initialized correctly */
87 extern unsigned int initAFSDirPath(void);
88
89 extern int
90 ConstructLocalPath(const char *cpath,
91                    const char *relativeTo,
92                    char **fullPathBufp);
93 extern int
94 ConstructLocalBinPath(const char *cpath,
95                       char **fullPathBufp);
96 extern int
97 ConstructLocalLogPath(const char *cpath,
98                       char **fullPathBufp);
99
100
101
102 /* -----------------  Directory/file name macros ------------------ */
103
104 /* afs installation dir names */
105 #define AFSDIR_SERVER_ETC_DIR   "@afsconfdir"
106 #define AFSDIR_CLIENT_ETC_DIR "@viceetcdir"
107 #define AFSDIR_SERVER_BIN_DIR   "@afssrvlibexecdir"
108 #define AFSDIR_CORES_DIR "cores"
109 #define AFSDIR_DB_DIR    "@afsdbdir"
110 #define AFSDIR_LOGS_DIR  "@afslogsdir"
111 #define AFSDIR_LOCAL_DIR "@afslocaldir"
112 #define AFSDIR_BACKUP_DIR "@afsbackupdir"
113 #define AFSDIR_MIGR_DIR  "@afslocaldir/migrate"
114 #define AFSDIR_BIN_FILE_DIR  "@afslocaldir/migrate/bin_files"
115 #define AFSDIR_BOSCONFIG_DIR "@afsbosconfigdir"
116 #define AFSDIR_BOSSERVER_DIR "@afssrvsbindir"
117
118 /* file names */ 
119 #define AFSDIR_THISCELL_FILE    "ThisCell"
120 #define AFSDIR_CELLSERVDB_FILE  "CellServDB"
121 #define AFSDIR_KEY_FILE         "KeyFile"
122 #define AFSDIR_ULIST_FILE       "UserList"
123 #define AFSDIR_NOAUTH_FILE      "NoAuth"
124 #define AFSDIR_BUDBLOG_FILE     "BackupLog"
125 #define AFSDIR_TAPECONFIG_FILE  "tapeconfig"
126 #define AFSDIR_KALOGDB_FILE     "AuthLog"
127 #define AFSDIR_KALOG_FILE       "AuthLog"
128 #define AFSDIR_KADB_FILE        "kaserver"
129 #define AFSDIR_NTPD_FILE        "ntpd"
130 #define AFSDIR_PRDB_FILE        "prdb"
131 #define AFSDIR_PTLOG_FILE       "PtLog"
132 #define AFSDIR_KCONF_FILE       "krb.conf"
133 #define AFSDIR_VLDB_FILE        "vldb"
134 #define AFSDIR_VLOG_FILE        "VLLog"
135 #define AFSDIR_CORE_FILE        "core"
136 #define AFSDIR_SLVGLOG_FILE     "SalvageLog"
137 #define AFSDIR_SALVAGER_FILE    "salvager"
138 #define AFSDIR_SLVGLOCK_FILE    "salvage.lock"
139 #define AFSDIR_BOZCONF_FILE     "BosConfig"
140 #define AFSDIR_BOZCONFNEW_FILE  "BosConfig.new"
141 #define AFSDIR_BOZINIT_FILE     "BozoInit"
142 #define AFSDIR_BOZLOG_FILE      "BosLog"
143 #define AFSDIR_BOSVR_FILE       "bosserver"
144 #define AFSDIR_VOLSERLOG_FILE   "VolserLog"
145 #define AFSDIR_AUDIT_FILE       "Audit"
146
147 #define AFSDIR_ROOTVOL_FILE     "RootVolume"
148 #define AFSDIR_HOSTDUMP_FILE    "hosts.dump"
149 #define AFSDIR_CLNTDUMP_FILE    "client.dump"
150 #define AFSDIR_CBKDUMP_FILE     "callback.dump"
151 #define AFSDIR_OLDSYSID_FILE    "sysid.old"
152 #define AFSDIR_SYSID_FILE       "sysid"
153 #define AFSDIR_FILELOG_FILE     "FileLog"
154 #define AFSDIR_MIGRATE_LOGNAME  "wtlog."
155
156 #define AFSDIR_CELLSERVDB_FILE_NTCLIENT  "afsdcell.ini"
157
158 #define AFSDIR_NETINFO_FILE     "NetInfo"
159 #define AFSDIR_NETRESTRICT_FILE "NetRestrict"
160
161 #define AFSDIR_LOCALRESIDENCY_FILE "LocalResidency"
162 #define AFSDIR_WEIGHTINGCONST_FILE "Weight.LocalConstants"
163 #define AFSDIR_THRESHOLDCONST_FILE "Thershold.LocalConstants"
164
165 /* -------------- Canonical (wire-format) path macros -------------- */
166
167 /* Each of the following is a canonical form of the corresponding
168  * local (AFSDIR_*) path macro.
169  */
170
171 #define AFSDIR_CANONICAL_USR_DIRPATH            "/usr"
172 #define AFSDIR_CANONICAL_SERVER_AFS_DIRPATH     "/usr/afs"
173 #define AFSDIR_CANONICAL_CLIENT_VICE_DIRPATH    "/usr/vice"
174 #ifdef AFS_DARWIN_ENV
175 #define AFSDIR_ALTERNATE_CLIENT_VICE_DIRPATH    "/var/db/openafs"
176 #endif
177
178 #define AFSDIR_CANONICAL_SERVER_BIN_DIRPATH \
179 AFSDIR_CANONICAL_SERVER_AFS_DIRPATH "/bin"
180
181 #define AFSDIR_CANONICAL_SERVER_ETC_DIRPATH \
182 AFSDIR_CANONICAL_SERVER_AFS_DIRPATH "/etc"
183
184 #define AFSDIR_CANONICAL_SERVER_LOGS_DIRPATH \
185 AFSDIR_CANONICAL_SERVER_AFS_DIRPATH "/logs"
186
187 #define AFSDIR_CANONICAL_SERVER_LOCAL_DIRPATH \
188 AFSDIR_CANONICAL_SERVER_AFS_DIRPATH "/local"
189
190
191 #define AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH \
192 AFSDIR_CANONICAL_SERVER_BIN_DIRPATH "/" AFSDIR_SALVAGER_FILE
193
194 #define AFSDIR_CANONICAL_SERVER_SLVGLOG_FILEPATH \
195 AFSDIR_CANONICAL_SERVER_LOGS_DIRPATH "/" AFSDIR_SLVGLOG_FILE
196
197
198 /* ---------------------  Local path macros ---------------------- */
199
200 /* Note: On NT, these should be used only after calling initAFSDirPath().
201  *       On Unix, the paths are implicitly initialized.
202  */
203
204 /* enums for indexes into the pathname array */
205 typedef enum afsdir_id { 
206       AFSDIR_USR_DIRPATH_ID,
207       AFSDIR_SERVER_AFS_DIRPATH_ID,
208       AFSDIR_SERVER_ETC_DIRPATH_ID,
209       AFSDIR_SERVER_BIN_DIRPATH_ID,
210       AFSDIR_SERVER_CORES_DIRPATH_ID,
211       AFSDIR_SERVER_DB_DIRPATH_ID,
212       AFSDIR_SERVER_LOGS_DIRPATH_ID,
213       AFSDIR_SERVER_LOCAL_DIRPATH_ID,
214       AFSDIR_SERVER_BACKUP_DIRPATH_ID,
215       AFSDIR_CLIENT_VICE_DIRPATH_ID,
216       AFSDIR_CLIENT_ETC_DIRPATH_ID,
217       AFSDIR_SERVER_THISCELL_FILEPATH_ID,
218       AFSDIR_SERVER_CELLSERVDB_FILEPATH_ID,
219       AFSDIR_SERVER_NOAUTH_FILEPATH_ID,
220       AFSDIR_SERVER_KEY_FILEPATH_ID,
221       AFSDIR_SERVER_ULIST_FILEPATH_ID,
222       AFSDIR_SERVER_BUDBLOG_FILEPATH_ID,
223       AFSDIR_SERVER_TAPECONFIG_FILEPATH_ID,
224       AFSDIR_SERVER_KALOGDB_FILEPATH_ID,
225       AFSDIR_SERVER_KALOG_FILEPATH_ID,
226       AFSDIR_SERVER_KADB_FILEPATH_ID,
227       AFSDIR_SERVER_NTPD_FILEPATH_ID,
228       AFSDIR_SERVER_PRDB_FILEPATH_ID,
229       AFSDIR_SERVER_PTLOG_FILEPATH_ID,
230       AFSDIR_SERVER_KCONF_FILEPATH_ID,
231       AFSDIR_SERVER_VLDB_FILEPATH_ID,
232       AFSDIR_SERVER_VLOG_FILEPATH_ID,
233       AFSDIR_SERVER_CORELOG_FILEPATH_ID,
234       AFSDIR_SERVER_SLVGLOG_FILEPATH_ID,
235       AFSDIR_SERVER_SALVAGER_FILEPATH_ID,
236       AFSDIR_SERVER_BOZCONF_FILEPATH_ID,
237       AFSDIR_SERVER_BOZCONFNEW_FILEPATH_ID,
238       AFSDIR_SERVER_BOZINIT_FILEPATH_ID,
239       AFSDIR_SERVER_BOZLOG_FILEPATH_ID,
240       AFSDIR_SERVER_BOSVR_FILEPATH_ID,
241       AFSDIR_SERVER_SLVGLOCK_FILEPATH_ID,
242       AFSDIR_SERVER_VOLSERLOG_FILEPATH_ID,
243       AFSDIR_SERVER_ROOTVOL_FILEPATH_ID,
244       AFSDIR_SERVER_HOSTDUMP_FILEPATH_ID,
245       AFSDIR_SERVER_CLNTDUMP_FILEPATH_ID,
246       AFSDIR_SERVER_CBKDUMP_FILEPATH_ID,
247       AFSDIR_SERVER_OLDSYSID_FILEPATH_ID,
248       AFSDIR_SERVER_SYSID_FILEPATH_ID,
249       AFSDIR_SERVER_FILELOG_FILEPATH_ID,
250       AFSDIR_SERVER_AUDIT_FILEPATH_ID,
251       AFSDIR_CLIENT_THISCELL_FILEPATH_ID,
252       AFSDIR_CLIENT_CELLSERVDB_FILEPATH_ID,
253       AFSDIR_CLIENT_NETINFO_FILEPATH_ID,
254       AFSDIR_CLIENT_NETRESTRICT_FILEPATH_ID,
255       AFSDIR_SERVER_NETINFO_FILEPATH_ID,
256       AFSDIR_SERVER_NETRESTRICT_FILEPATH_ID,
257       AFSDIR_SERVER_WEIGHTING_CONSTANTS_FILEPATH_ID,
258       AFSDIR_SERVER_THRESHOLD_CONSTANTS_FILEPATH_ID,
259       AFSDIR_SERVER_MIGRATE_DIRPATH_ID,
260       AFSDIR_SERVER_MIGRATELOG_FILEPATH_ID,
261       AFSDIR_SERVER_BIN_FILE_DIRPATH_ID,
262       AFSDIR_PATHSTRING_MAX } afsdir_id_t;
263
264 /* getDirPath() returns a pointer to a string from an internal array of path strings 
265  */
266 const char *getDirPath(afsdir_id_t string_id);
267
268 /* Top level usr dir */
269 #define AFSDIR_USR_DIRPATH getDirPath(AFSDIR_USR_DIRPATH_ID)
270
271 /* server subdir paths */
272 #define AFSDIR_SERVER_AFS_DIRPATH getDirPath(AFSDIR_SERVER_AFS_DIRPATH_ID)
273 #define AFSDIR_SERVER_ETC_DIRPATH getDirPath(AFSDIR_SERVER_ETC_DIRPATH_ID)
274 #define AFSDIR_SERVER_BIN_DIRPATH getDirPath(AFSDIR_SERVER_BIN_DIRPATH_ID)
275 #define AFSDIR_SERVER_CORES_DIRPATH getDirPath(AFSDIR_SERVER_CORES_DIRPATH_ID)
276 #define AFSDIR_SERVER_DB_DIRPATH getDirPath(AFSDIR_SERVER_DB_DIRPATH_ID)
277 #define AFSDIR_SERVER_LOGS_DIRPATH getDirPath(AFSDIR_SERVER_LOGS_DIRPATH_ID)
278 #define AFSDIR_SERVER_LOCAL_DIRPATH getDirPath(AFSDIR_SERVER_LOCAL_DIRPATH_ID)
279 #define AFSDIR_SERVER_BACKUP_DIRPATH getDirPath(AFSDIR_SERVER_BACKUP_DIRPATH_ID)
280 #define AFSDIR_SERVER_LOCAL_DIRPATH getDirPath(AFSDIR_SERVER_LOCAL_DIRPATH_ID)
281 #define AFSDIR_SERVER_MIGRATE_DIRPATH getDirPath(AFSDIR_SERVER_MIGRATE_DIRPATH_ID)
282 #define AFSDIR_SERVER_MIGRATE_DIRPATH getDirPath(AFSDIR_SERVER_MIGRATE_DIRPATH_ID)
283
284 /* client subdir paths */
285 #define AFSDIR_CLIENT_VICE_DIRPATH getDirPath(AFSDIR_CLIENT_VICE_DIRPATH_ID)
286 #define AFSDIR_CLIENT_ETC_DIRPATH getDirPath(AFSDIR_CLIENT_ETC_DIRPATH_ID)
287 #define AFSDIR_SERVER_BIN_FILE_DIRPATH getDirPath(AFSDIR_SERVER_BIN_FILE_DIRPATH_ID)
288
289 /* server file paths */
290 #define AFSDIR_SERVER_THISCELL_FILEPATH getDirPath(AFSDIR_SERVER_THISCELL_FILEPATH_ID)
291 #define AFSDIR_SERVER_CELLSERVDB_FILEPATH getDirPath(AFSDIR_SERVER_CELLSERVDB_FILEPATH_ID)
292 #define AFSDIR_SERVER_NOAUTH_FILEPATH getDirPath(AFSDIR_SERVER_NOAUTH_FILEPATH_ID)
293 #define AFSDIR_SERVER_KEY_FILEPATH getDirPath(AFSDIR_SERVER_KEY_FILEPATH_ID)
294 #define AFSDIR_SERVER_ULIST_FILEPATH getDirPath(AFSDIR_SERVER_ULIST_FILEPATH_ID)
295 #define AFSDIR_SERVER_BUDBLOG_FILEPATH getDirPath(AFSDIR_SERVER_BUDBLOG_FILEPATH_ID)
296 #define AFSDIR_SERVER_TAPECONFIG_FILEPATH getDirPath(AFSDIR_SERVER_TAPECONFIG_FILEPATH_ID)
297 #define AFSDIR_SERVER_KALOGDB_FILEPATH getDirPath(AFSDIR_SERVER_KALOGDB_FILEPATH_ID)
298 #define AFSDIR_SERVER_KALOG_FILEPATH getDirPath(AFSDIR_SERVER_KALOG_FILEPATH_ID)
299 #define AFSDIR_SERVER_KADB_FILEPATH getDirPath(AFSDIR_SERVER_KADB_FILEPATH_ID)
300 #define AFSDIR_SERVER_NTPD_FILEPATH getDirPath(AFSDIR_SERVER_NTPD_FILEPATH_ID)
301 #define AFSDIR_SERVER_PRDB_FILEPATH getDirPath(AFSDIR_SERVER_PRDB_FILEPATH_ID)
302 #define AFSDIR_SERVER_PTLOG_FILEPATH getDirPath(AFSDIR_SERVER_PTLOG_FILEPATH_ID)
303 #define AFSDIR_SERVER_KCONF_FILEPATH getDirPath(AFSDIR_SERVER_KCONF_FILEPATH_ID)
304 #define AFSDIR_SERVER_VLDB_FILEPATH getDirPath(AFSDIR_SERVER_VLDB_FILEPATH_ID)
305 #define AFSDIR_SERVER_VLOG_FILEPATH getDirPath(AFSDIR_SERVER_VLOG_FILEPATH_ID)
306 #define AFSDIR_SERVER_CORELOG_FILEPATH getDirPath(AFSDIR_SERVER_CORELOG_FILEPATH_ID)
307 #define AFSDIR_SERVER_SLVGLOG_FILEPATH getDirPath(AFSDIR_SERVER_SLVGLOG_FILEPATH_ID)
308 #define AFSDIR_SERVER_SALVAGER_FILEPATH getDirPath(AFSDIR_SERVER_SALVAGER_FILEPATH_ID)
309 #define AFSDIR_SERVER_BOZCONF_FILEPATH getDirPath(AFSDIR_SERVER_BOZCONF_FILEPATH_ID)
310 #define AFSDIR_SERVER_BOZCONFNEW_FILEPATH getDirPath(AFSDIR_SERVER_BOZCONFNEW_FILEPATH_ID)
311 #define AFSDIR_SERVER_BOZINIT_FILEPATH getDirPath(AFSDIR_SERVER_BOZINIT_FILEPATH_ID)
312 #define AFSDIR_SERVER_BOZLOG_FILEPATH getDirPath(AFSDIR_SERVER_BOZLOG_FILEPATH_ID)
313 #define AFSDIR_SERVER_BOSVR_FILEPATH getDirPath(AFSDIR_SERVER_BOSVR_FILEPATH_ID)
314 #define AFSDIR_SERVER_SLVGLOCK_FILEPATH getDirPath(AFSDIR_SERVER_SLVGLOCK_FILEPATH_ID)
315 #define AFSDIR_SERVER_VOLSERLOG_FILEPATH getDirPath(AFSDIR_SERVER_VOLSERLOG_FILEPATH_ID)
316 #define AFSDIR_SERVER_ROOTVOL_FILEPATH getDirPath(AFSDIR_SERVER_ROOTVOL_FILEPATH_ID)
317 #define AFSDIR_SERVER_HOSTDUMP_FILEPATH getDirPath(AFSDIR_SERVER_HOSTDUMP_FILEPATH_ID)
318 #define AFSDIR_SERVER_CLNTDUMP_FILEPATH getDirPath(AFSDIR_SERVER_CLNTDUMP_FILEPATH_ID)
319 #define AFSDIR_SERVER_CBKDUMP_FILEPATH getDirPath(AFSDIR_SERVER_CBKDUMP_FILEPATH_ID)
320 #define AFSDIR_SERVER_OLDSYSID_FILEPATH getDirPath(AFSDIR_SERVER_OLDSYSID_FILEPATH_ID)
321 #define AFSDIR_SERVER_SYSID_FILEPATH getDirPath(AFSDIR_SERVER_SYSID_FILEPATH_ID)
322 #define AFSDIR_SERVER_FILELOG_FILEPATH getDirPath(AFSDIR_SERVER_FILELOG_FILEPATH_ID)
323 #define AFSDIR_SERVER_AUDIT_FILEPATH getDirPath(AFSDIR_SERVER_AUDIT_FILEPATH_ID)
324 #define AFSDIR_SERVER_NETINFO_FILEPATH getDirPath(AFSDIR_SERVER_NETINFO_FILEPATH_ID)
325 #define AFSDIR_SERVER_NETRESTRICT_FILEPATH getDirPath(AFSDIR_SERVER_NETRESTRICT_FILEPATH_ID)
326 #define AFSDIR_SERVER_WEIGHTING_CONSTANTS_FILEPATH getDirPath(AFSDIR_SERVER_WEIGHTING_CONSTANTS_FILEPATH_ID)
327 #define AFSDIR_SERVER_THRESHOLD_CONSTANTS_FILEPATH getDirPath(AFSDIR_SERVER_THRESHOLD_CONSTANTS_FILEPATH_ID)
328 #define AFSDIR_SERVER_MIGRATELOG_FILEPATH getDirPath(AFSDIR_SERVER_MIGRATELOG_FILEPATH_ID)
329
330 /* client file paths */
331 #define AFSDIR_CLIENT_THISCELL_FILEPATH getDirPath(AFSDIR_CLIENT_THISCELL_FILEPATH_ID)
332 #define AFSDIR_CLIENT_CELLSERVDB_FILEPATH getDirPath(AFSDIR_CLIENT_CELLSERVDB_FILEPATH_ID)  
333 #define AFSDIR_CLIENT_NETINFO_FILEPATH getDirPath(AFSDIR_CLIENT_NETINFO_FILEPATH_ID)
334 #define AFSDIR_CLIENT_NETRESTRICT_FILEPATH getDirPath(AFSDIR_CLIENT_NETRESTRICT_FILEPATH_ID)
335
336 #endif /* _DIRPATH_H */