From: Sam Hartman Date: Fri, 7 Sep 2001 04:18:59 +0000 (+0000) Subject: dirpath-support-configure-path-options-and-decanonicalization-20010906 X-Git-Tag: BP-openafs-stable-1_2_x~24 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=11b021e1b1480230d64def8217288a49958d20e9;p=packages%2Fo%2Fopenafs.git dirpath-support-configure-path-options-and-decanonicalization-20010906 Sam's notes: "Here is a patch that supports directory paths, documentation for the above and decanonicalization of of supplied paths. Here are tests I have run: * Build with both transarc and non-transarc paths and examined dirpath.o * Build with roughly FHS-style paths and tested on Debian * confirmed that bos salvage works even when salvager not in /usr/afs/bin (it gets the log correctly too) * confirms that bos getlog can get logs from /usr/afs/logs even when /ur/afs/logs is /var/lib/openafs/logs * confirmed that bos getlog can get /etc/motd " --- diff --git a/NEWS b/NEWS index 720a6b1e0..6baed968b 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,13 @@ Openafs News -- history of user Visible changes. 11 July 2001 +* Changes since OpenAFS 1.1.1 + +** AFS now supports --prefix and the other directory options of + configure. By default AFS builds assuming it will be installed in + /usr/local. In order to get traditional AFS directory paths (/usr/afs + and /usr/vice/etc) use the --enable-transarc-paths option to +configure. More details on the new directory layout are found in README. + * Changes since Openafs 1.0 ** AFS now builds with configure. The README for building has been diff --git a/README b/README index 7646e1eb7..b71fbadfd 100644 --- a/README +++ b/README @@ -37,9 +37,9 @@ A. Creating the proper directory structure. 2. Using configure in the top level directory, configure for your AFS system type, providing the necessary flags: - % ./configure --with-afs-sysname=sun4x_58 + % ./configure --with-afs-sysname=sun4x_58 --enable-transarc-paths - For Linux systems you need also provide the patch in which your + For Linux systems you need also provide the path in which your kernel headers for your configured kernel can be found. This should be the path of the directory containing a child directory named "include". So if your version file was @@ -55,6 +55,29 @@ A. Creating the proper directory structure. or insecure software included with OpenAFS. See README.obsolete and README.insecure for more details. + There are two modes for directory path handling: "Transarc mode" and "default mode": + - In Transarc mode, we retain compatibility with Transarc/IBM AFS tools + by putting client configuaration files in /usr/vice/etc, and server + files in /usr/afs under the traditional directory layout. + - In default mode, files are located in standardized locations, usually + under $(prefix). + - Client programs, libraries, and related files always go in standard + directories under $(prefix). This rule covers things that would go + into $(bindir), $(includedir), $(libdir), $(mandir), and $(sbindir). + - Other files get located in the following places: + + Directory Transarc Mode Default Mode + ============ ========================= ============================== + viceetcdir /usr/vice/etc $(sysconfdir)/openafs + afssrvdir /usr/afs/bin (servers) $(libexecdir)/openafs + afsconfdir /usr/afs/etc $(sysconfdir)/openafs/server + afslocaldir /usr/afs/local $(localstatedir)/openafs + afsdbdir /usr/afs/db $(localstatedir)/openafs/db + afslogdir /usr/afs/logs $(localstatedir)/openafs/logs + afsbosconfig $(afslocaldir)/BosConfig $(afsconfdir)/BosConfig + afsbosserver $(afsbindir)/bosserver $(sbindir)/bosserver + + B Building 1. Now, you can build OpenAFS. diff --git a/configure.in b/configure.in index 377775eaa..36585f85b 100644 --- a/configure.in +++ b/configure.in @@ -35,6 +35,9 @@ AC_ARG_ENABLE(kernel-module, AC_ARG_ENABLE(redhat-buildsys, [ --enable-redhat-buildsys enable compilation of the redhat build system kernel (defaults to disabled)],, enable_redhat_buildsys="no" ) +AC_ARG_ENABLE(transarc-paths, +[ --enable-transarc-paths Use Transarc style paths like /usr/afs and /usr/vice],, enable_transarc_paths="no" +) AC_PROG_CC @@ -392,6 +395,39 @@ AC_CHECK_HEADERS(security/pam_modules.h siad.h usersec.h) AC_CHECK_FUNCS(utimes random srandom getdtablesize snprintf re_comp re_exec) +dnl Directory PATH handling +if test "x$enable_transarc_paths" = "xyes" ; then + afsconfdir=${afsconfdir=/usr/afs/etc} + viceetcdir=${viceetcdir=/usr/vice/etc} + afssrvdir=${afssrvdir=/usr/afs/bin} + afsdbdir=${afsdbdir=/usr/afs/db} + afslogsdir=${afslogsdir=/usr/afs/logs} + afslocaldir=${afslocaldir=/usr/afs/local} + afsbackupdir=${afsbackupdir=/usr/afs/backup} + afsbosconfigdir=${afsbosconfigdir=/usr/afs/local} + afsbosserverdir=${afsbosserverdir=/usr/afs/bin} + else + afsconfdir=${afsconfdir=$sysconfdir/openafs/server} + viceetcdir=${viceetcdir=$sysconfdir/openafs} + afssrvdir=${afssrvdir=$libexecdir/openafs} + afsdbdir=${afsdbdir=$localstatedir/openafs/db} + afslogsdir=${afslogsdir=$localstatedir/openafs/logs} + afslocaldir=${afslocaldir=$localstatedir/openafs} + afsbackupdir=${afsbackupdir=$localstatedir/openafs/backup} + afsbosconfigdir=${afsbosconfigdir=$sysconfdir/openafs} + afsbosserverdir=${afsbosserverdir=$sbindir} + +fi +AC_SUBST(afsconfdir) +AC_SUBST(viceetcdir) +AC_SUBST(afssrvdir) +AC_SUBST(afsdbdir) +AC_SUBST(afslogsdir) +AC_SUBST(afslocaldir) +AC_SUBST(afsbackupdir) +AC_SUBST(afsbosconfigdir) +AC_SUBST(afsbosserverdir) + if test "x$enable_kernel_module" = "xyes"; then ENABLE_KERNEL_MODULE=libafs fi diff --git a/src/util/Makefile.in b/src/util/Makefile.in index 1b9f6b241..8de23bde0 100644 --- a/src/util/Makefile.in +++ b/src/util/Makefile.in @@ -9,6 +9,17 @@ DESTDIR=@DESTDIR@ SRCDIR=@SRCDIR@ TOP_SRCDIR=@TOP_SRCDIR@ SYS_NAME=@AFS_SYSNAME@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +afsconfdir=@afsconfdir@ +viceetcdir=@viceetcdir@ +afssrvdir=@afssrvdir@ +afsdbdir=@afsdbdir@ +afslogsdir=@afslogsdir@ +afslocaldir=@afslocaldir@ +afsbackupdir=@afsbackupdir@ +afsbosconfigdir=@afsbosconfigdir@ +afsbosserverdir=@afsbosserverdir@ SHELL = /bin/sh @@ -24,6 +35,19 @@ objects = assert.o base64.o casestrcpy.o ktime.o volparse.o hostparse.o \ all: install +dirpath.h: dirpath.hin Makefile + ( sed \ + -e "s+@afsconfdir+${afsconfdir}+" \ + -e "s+@viceetcdir+${viceetcdir}+" \ + -e "s+@afssrvdir+${afssrvdir}+" \ + -e "s+@afsdbdir+${afsdbdir}+" \ + -e "s+@afslogsdir+${afslogsdir}+" \ + -e "s+@afslocaldir+${afslocaldir}+" \ + -e "s+@afsbackupdir+${afsbackupdir}+" \ + -e "s+@afsbosconfigdir+${afsbosconfigdir}+" \ + -e "s+@afsbosserverdir+${afsbosserverdir}+" \ + dirpath.hin >dirpath.h.tmp && \ + mv dirpath.h.tmp dirpath.h ) util.a: ${objects} AFS_component_version_number.o $(RM) -f util.a $(AR) crv util.a ${objects} AFS_component_version_number.o @@ -266,7 +290,7 @@ ${UKDIR}/afs_lhash.h: afs_lhash.h # clean: - $(RM) -f ${objects} sys + $(RM) -f ${objects} sys dirpath.h $(RM) -f util.a *.o core AFS_component_version_number.c test: diff --git a/src/util/dirpath.c b/src/util/dirpath.c index 158326331..9eabd31ea 100644 --- a/src/util/dirpath.c +++ b/src/util/dirpath.c @@ -61,16 +61,16 @@ static void initDirPathArray(void); /* Additional macros for ease of use */ /* buf is expected to be atleast AFS_PATH_MAX bytes long */ #define AFSDIR_SERVER_DIRPATH(buf, dir) \ - strcompose(buf, AFSDIR_PATH_MAX, dirPathArray[AFSDIR_SERVER_AFS_DIRPATH_ID], "/", dir, NULL) + strcompose(buf, AFSDIR_PATH_MAX, serverPrefix, dir, NULL) #define AFSDIR_SERVER_FILEPATH(buf, dir, file) \ - strcompose(buf, AFSDIR_PATH_MAX, dirPathArray[AFSDIR_SERVER_AFS_DIRPATH_ID], "/", dir, "/", file, NULL) + strcompose(buf, AFSDIR_PATH_MAX, serverPrefix, dir, "/", file, NULL) #define AFSDIR_CLIENT_DIRPATH(buf, dir) \ - strcompose(buf, AFSDIR_PATH_MAX, dirPathArray[AFSDIR_CLIENT_VICE_DIRPATH_ID], "/", dir, NULL) + strcompose(buf, AFSDIR_PATH_MAX, clientPrefix, dir, NULL) #define AFSDIR_CLIENT_FILEPATH(buf, dir, file) \ - strcompose(buf, AFSDIR_PATH_MAX, dirPathArray[AFSDIR_CLIENT_VICE_DIRPATH_ID], "/", dir, "/", file, NULL) + strcompose(buf, AFSDIR_PATH_MAX, clientPrefix, dir, "/", file, NULL) /* initAFSDirPath() -- External users call this function to initialize @@ -105,7 +105,9 @@ unsigned int initAFSDirPath(void) static void initDirPathArray(void) { char *pathp; - + const char * clientPrefix = ""; + const char * serverPrefix = ""; + #ifdef AFS_NT40_ENV char *buf; int status; @@ -145,6 +147,7 @@ static void initDirPathArray(void) strcpy(ntClientConfigDirShort, ntClientConfigDirLong); } FilepathNormalize(ntClientConfigDirShort); + clientPrefix = ntClientConfigDirShort; /* setup the root server directory path (/usr/afs equivalent) */ strcpy(afsSrvDirPath, ntServerInstallDirShort); @@ -155,6 +158,7 @@ static void initDirPathArray(void) /* setup top level dirpath (/usr equivalent); valid for server ONLY */ strcpy(dirPathArray[AFSDIR_USR_DIRPATH_ID], ntServerInstallDirShort); + serverPrefix = ntInstallDirShort; strcat(dirPathArray[AFSDIR_USR_DIRPATH_ID], AFSDIR_CANONICAL_USR_DIRPATH); #else /* AFS_NT40_ENV */ @@ -182,10 +186,10 @@ static void initDirPathArray(void) strcpy(dirPathArray[AFSDIR_SERVER_AFS_DIRPATH_ID], afsSrvDirPath); pathp = dirPathArray[AFSDIR_SERVER_ETC_DIRPATH_ID]; - AFSDIR_SERVER_DIRPATH(pathp, AFSDIR_ETC_DIR); + AFSDIR_SERVER_DIRPATH(pathp, AFSDIR_SERVER_ETC_DIR); pathp = dirPathArray[AFSDIR_SERVER_BIN_DIRPATH_ID]; - AFSDIR_SERVER_DIRPATH(pathp, AFSDIR_BIN_DIR); + AFSDIR_SERVER_DIRPATH(pathp, AFSDIR_SERVER_BIN_DIR); pathp = dirPathArray[AFSDIR_SERVER_CORES_DIRPATH_ID]; AFSDIR_SERVER_DIRPATH(pathp, AFSDIR_CORES_DIR); @@ -218,16 +222,16 @@ static void initDirPathArray(void) strcpy(dirPathArray[AFSDIR_CLIENT_VICE_DIRPATH_ID], afsClntDirPath); pathp = dirPathArray[AFSDIR_CLIENT_ETC_DIRPATH_ID]; - AFSDIR_CLIENT_DIRPATH(pathp, AFSDIR_ETC_DIR); + AFSDIR_CLIENT_DIRPATH(pathp, AFSDIR_CLIENT_ETC_DIR); #endif /* AFS_NT40_ENV */ /* server file paths */ pathp = dirPathArray[AFSDIR_SERVER_THISCELL_FILEPATH_ID]; - AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_ETC_DIR, AFSDIR_THISCELL_FILE); + AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_SERVER_ETC_DIR, AFSDIR_THISCELL_FILE); pathp = dirPathArray[AFSDIR_SERVER_CELLSERVDB_FILEPATH_ID]; - AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_ETC_DIR, AFSDIR_CELLSERVDB_FILE); + AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_SERVER_ETC_DIR, AFSDIR_CELLSERVDB_FILE); pathp = dirPathArray[AFSDIR_SERVER_NOAUTH_FILEPATH_ID]; AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_LOCAL_DIR, AFSDIR_NOAUTH_FILE); @@ -248,7 +252,7 @@ static void initDirPathArray(void) AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_DB_DIR, AFSDIR_KADB_FILE); pathp = dirPathArray[AFSDIR_SERVER_NTPD_FILEPATH_ID]; - AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_BIN_DIR, AFSDIR_NTPD_FILE); + AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_SERVER_BIN_DIR, AFSDIR_NTPD_FILE); pathp = dirPathArray[AFSDIR_SERVER_PRDB_FILEPATH_ID]; AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_DB_DIR, AFSDIR_PRDB_FILE); @@ -257,7 +261,7 @@ static void initDirPathArray(void) AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_LOGS_DIR, AFSDIR_PTLOG_FILE); pathp = dirPathArray[AFSDIR_SERVER_KCONF_FILEPATH_ID]; - AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_ETC_DIR, AFSDIR_KCONF_FILE); + AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_SERVER_ETC_DIR, AFSDIR_KCONF_FILE); pathp = dirPathArray[AFSDIR_SERVER_VLDB_FILEPATH_ID]; AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_DB_DIR, AFSDIR_VLDB_FILE); @@ -272,37 +276,37 @@ static void initDirPathArray(void) AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_LOGS_DIR, AFSDIR_SLVGLOG_FILE); pathp = dirPathArray[AFSDIR_SERVER_SALVAGER_FILEPATH_ID]; - AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_BIN_DIR, AFSDIR_SALVAGER_FILE); + AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_SERVER_BIN_DIR, AFSDIR_SALVAGER_FILE); pathp = dirPathArray[AFSDIR_SERVER_SLVGLOCK_FILEPATH_ID]; AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_LOCAL_DIR, AFSDIR_SLVGLOCK_FILE); pathp = dirPathArray[AFSDIR_SERVER_KEY_FILEPATH_ID]; - AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_ETC_DIR, AFSDIR_KEY_FILE); + AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_SERVER_ETC_DIR, AFSDIR_KEY_FILE); pathp = dirPathArray[AFSDIR_SERVER_ULIST_FILEPATH_ID]; - AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_ETC_DIR, AFSDIR_ULIST_FILE); + AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_SERVER_ETC_DIR, AFSDIR_ULIST_FILE); pathp = dirPathArray[AFSDIR_SERVER_BOZCONF_FILEPATH_ID]; - AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_LOCAL_DIR, AFSDIR_BOZCONF_FILE); + AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_BOSCONFIG_DIR, AFSDIR_BOZCONF_FILE); pathp = dirPathArray[AFSDIR_SERVER_BOZCONFNEW_FILEPATH_ID]; - AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_LOCAL_DIR, AFSDIR_BOZCONFNEW_FILE); + AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_BOSCONFIG_DIR, AFSDIR_BOZCONFNEW_FILE); pathp = dirPathArray[AFSDIR_SERVER_BOZLOG_FILEPATH_ID]; AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_LOGS_DIR, AFSDIR_BOZLOG_FILE); pathp = dirPathArray[AFSDIR_SERVER_BOZINIT_FILEPATH_ID]; - AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_LOCAL_DIR, AFSDIR_BOZINIT_FILE); + AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_BOSCONFIG_DIR, AFSDIR_BOZINIT_FILE); pathp = dirPathArray[AFSDIR_SERVER_BOSVR_FILEPATH_ID]; - AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_BIN_DIR, AFSDIR_BOSVR_FILE); + AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_BOSSERVER_DIR, AFSDIR_BOSVR_FILE); pathp = dirPathArray[AFSDIR_SERVER_VOLSERLOG_FILEPATH_ID]; AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_LOGS_DIR, AFSDIR_VOLSERLOG_FILE); pathp = dirPathArray[AFSDIR_SERVER_ROOTVOL_FILEPATH_ID]; - AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_ETC_DIR, AFSDIR_ROOTVOL_FILE); + AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_SERVER_ETC_DIR, AFSDIR_ROOTVOL_FILE); pathp = dirPathArray[AFSDIR_SERVER_HOSTDUMP_FILEPATH_ID]; AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_LOCAL_DIR, AFSDIR_HOSTDUMP_FILE); @@ -350,17 +354,17 @@ static void initDirPathArray(void) ntClientConfigDirShort, AFSDIR_CELLSERVDB_FILE_NTCLIENT); #else pathp = dirPathArray[AFSDIR_CLIENT_THISCELL_FILEPATH_ID]; - AFSDIR_CLIENT_FILEPATH(pathp, AFSDIR_ETC_DIR, AFSDIR_THISCELL_FILE); + AFSDIR_CLIENT_FILEPATH(pathp, AFSDIR_CLIENT_ETC_DIR, AFSDIR_THISCELL_FILE); pathp = dirPathArray[AFSDIR_CLIENT_CELLSERVDB_FILEPATH_ID]; - AFSDIR_CLIENT_FILEPATH(pathp, AFSDIR_ETC_DIR, AFSDIR_CELLSERVDB_FILE); + AFSDIR_CLIENT_FILEPATH(pathp, AFSDIR_CLIENT_ETC_DIR, AFSDIR_CELLSERVDB_FILE); #endif /* AFS_NT40_ENV */ pathp = dirPathArray[AFSDIR_CLIENT_NETINFO_FILEPATH_ID]; - AFSDIR_CLIENT_FILEPATH(pathp, AFSDIR_ETC_DIR, AFSDIR_NETINFO_FILE); + AFSDIR_CLIENT_FILEPATH(pathp, AFSDIR_CLIENT_ETC_DIR, AFSDIR_NETINFO_FILE); pathp = dirPathArray[AFSDIR_CLIENT_NETRESTRICT_FILEPATH_ID]; - AFSDIR_CLIENT_FILEPATH(pathp, AFSDIR_ETC_DIR, AFSDIR_NETRESTRICT_FILE); + AFSDIR_CLIENT_FILEPATH(pathp, AFSDIR_CLIENT_ETC_DIR, AFSDIR_NETRESTRICT_FILE); initFlag = 1; /* finished dirpath initialization */ return; @@ -382,6 +386,48 @@ const char *getDirPath(afsdir_id_t string_id) } return (const char *)dirPathArray[string_id]; } +/* + * LocalizePathHead() -- Make path relative to local part + * + * ConstructLocalPath takes a path and a directory that path should + * be considered relative to. This function checks the given path + * for a prefix that represents a canonical path. If such a prefix + * is found, the path is adjusted to remove the prefix and the path + * is considered relative to the local version of that path. + */ + +/* The following array maps cannonical parts to local parts. It + * might seem reasonable to simply construct an array in parallel to + * dirpatharray but it turns out you don't want translations for all + local paths. +*/ + +struct canonmapping { + const char * canonical; + const char * local; +}; +static struct canonmapping CanonicalTranslations[] = { + {AFSDIR_CANONICAL_SERVER_ETC_DIRPATH, AFSDIR_SERVER_ETC_DIR}, + { AFSDIR_CANONICAL_SERVER_LOGS_DIRPATH, AFSDIR_LOGS_DIR}, + { AFSDIR_CANONICAL_SERVER_LOCAL_DIRPATH, AFSDIR_LOCAL_DIR}, + {AFSDIR_CANONICAL_SERVER_BIN_DIRPATH, AFSDIR_SERVER_BIN_DIR }, + { NULL, NULL } +}; + +static void LocalizePathHead ( const char **path, const char **relativeTo) +{ + struct canonmapping *current; + for (current = CanonicalTranslations; current->local != NULL ; current++) { + int canonlength = strlen (current->canonical); + if (strncmp (*path, current->canonical, canonlength) == 0 ) { + (*path) += canonlength; + if (**path == '/') + (*path)++; + *relativeTo = current->local; + return; + } + } +} #ifdef AFS_NT40_ENV @@ -399,7 +445,7 @@ const char *getDirPath(afsdir_id_t string_id) * 2) If cpath begins with a drive letter but is not fully qualified, * i.e., it is drive relative, then the function fails with EINVAL. * 3) If cpath begins with '/' (or '\') then the path returned is the - * concatenation AFS-server-install-dir + cpath. + * concatenation AFS-server-install-dir + cpath after translating for localization. * 4) Otherwise the path returned is the concatenation * AFS-server-install-dir + relativeTo + cpath. * @@ -430,6 +476,7 @@ ConstructLocalPath(const char *cpath, cpath++; } + LocalizePathHead (&cpath,&relativeTo); if ((((*cpath >= 'a') && (*cpath <= 'z')) || ((*cpath >= 'A') && (*cpath <= 'Z'))) && (*(cpath+1) == ':')) { @@ -528,6 +575,7 @@ ConstructLocalPath(const char *cpath, cpath++; } + LocalizePathHead (&cpath, &relativeTo); if (*cpath == '/') { newPath = (char *)malloc(strlen(cpath) + 1); if (!newPath) { diff --git a/src/util/dirpath.h b/src/util/dirpath.h deleted file mode 100644 index 76249bd97..000000000 --- a/src/util/dirpath.h +++ /dev/null @@ -1,325 +0,0 @@ -/* - * Copyright 2000, International Business Machines Corporation and others. - * All Rights Reserved. - * - * This software has been released under the terms of the IBM Public - * License. For details, see the LICENSE file in the top-level source - * directory or online at http://www.openafs.org/dl/license10.html - */ - -#ifndef _DIRPATH_H -#define _DIRPATH_H - -/* Dirpath package: Rationale and Usage - * - * With the port of AFS to Windows NT, it becomes necessary to support - * storing AFS system files (binaries, logs, etc.) in a user-specified - * installation directory. This breaks from the traditional notion of - * all AFS system files being stored under /usr/afs or /usr/vice. - * - * The core concept is that there is a dynamically determined installation - * directory that is the prefix to a well-known AFS tree. The structure - * of this well-known AFS tree remains unchanged. For example, AFS server - * binaries reside in /usr/afs/bin, server configuration files - * reside in /usr/afs/etc, etcetera. This scheme allows the - * flexibility required by NT, without requiring file-location changes - * on Unix (for which can simply be null). - * - * Thus file paths can no longer be hard-coded; rather, all file paths are - * specified via the macros provided by this package. - * - * Utilizing a dynamically determined installation directory forces the - * notion of local versus canonical (wire-format) paths. A local path is - * fully qualified (with a syntax determined by the native filesystem type) - * whereas a canonical path specifies location only within the well-known AFS - * tree. Supporting the notion of canonical paths allows the same path to - * be sent to servers on different machines, having different installation - * directories, with the desired result. - * - * For example, 'bos create kaserver simple /usr/afs/bin/kasever' will - * work both on a Unix machine, where the kaserver executable actually resides - * in /usr/afs/bin, and on a NT machine, where the kaserver may reside in - * C:/Program Files/Transarc/AFS Server/usr/afs/bin. - * - * Conversion functions are provided that translate canonical (wire-format) - * paths to fully qualified local paths; see the documentation in dirpath.c - * for details. Note that these conversion functions also accomodate fully - * qualified paths on the wire, for exceptional cases where this feature - * may be required. Again, these conversion functions have been implemented - * such that no file-location changes are required on Unix. - * - * The path macros provided here are divided into local (AFSDIR_*) and - * canonical (AFSDIR_CANONICAL_*). The canonical macros MUST be used by - * commands that send a non-user-specified path to a server (i.e., over - * the wire). The local macros MUST be used in all other cases. - */ - - - -#include - -#ifdef AFS_NT40_ENV -#include -#endif -#include - -/* Max dir path size for afs install dirs */ -#ifdef AFS_NT40_ENV -#define AFSDIR_PATH_MAX MAX_PATH -#else /* unices */ -#define AFSDIR_PATH_MAX _POSIX_PATH_MAX -#endif - - -/* --------------------- Exported functions ---------------------- */ - - -#define AFSDIR_CLIENT_PATHS_OK 0x1 /* client paths initialized correctly */ -#define AFSDIR_SERVER_PATHS_OK 0x2 /* server paths initialized correctly */ -extern unsigned int initAFSDirPath(void); - -extern int -ConstructLocalPath(const char *cpath, - const char *relativeTo, - char **fullPathBufp); -extern int -ConstructLocalBinPath(const char *cpath, - char **fullPathBufp); -extern int -ConstructLocalLogPath(const char *cpath, - char **fullPathBufp); - - - -/* ----------------- Directory/file name macros ------------------ */ - -/* afs installation dir names */ -#define AFSDIR_ETC_DIR "etc" -#define AFSDIR_BIN_DIR "bin" -#define AFSDIR_CORES_DIR "cores" -#define AFSDIR_DB_DIR "db" -#define AFSDIR_LOGS_DIR "logs" -#define AFSDIR_LOCAL_DIR "local" -#define AFSDIR_BACKUP_DIR "backup" -#define AFSDIR_MIGR_DIR "local/migrate" -#define AFSDIR_BIN_FILE_DIR "local/migrate/bin_files" - -/* file names */ -#define AFSDIR_THISCELL_FILE "ThisCell" -#define AFSDIR_CELLSERVDB_FILE "CellServDB" -#define AFSDIR_KEY_FILE "KeyFile" -#define AFSDIR_ULIST_FILE "UserList" -#define AFSDIR_NOAUTH_FILE "NoAuth" -#define AFSDIR_BUDBLOG_FILE "BackupLog" -#define AFSDIR_TAPECONFIG_FILE "tapeconfig" -#define AFSDIR_KALOGDB_FILE "AuthLog" -#define AFSDIR_KALOG_FILE "AuthLog" -#define AFSDIR_KADB_FILE "kaserver" -#define AFSDIR_NTPD_FILE "ntpd" -#define AFSDIR_PRDB_FILE "prdb" -#define AFSDIR_PTLOG_FILE "PtLog" -#define AFSDIR_KCONF_FILE "krb.conf" -#define AFSDIR_VLDB_FILE "vldb" -#define AFSDIR_VLOG_FILE "VLLog" -#define AFSDIR_CORE_FILE "core" -#define AFSDIR_SLVGLOG_FILE "SalvageLog" -#define AFSDIR_SALVAGER_FILE "salvager" -#define AFSDIR_SLVGLOCK_FILE "salvage.lock" -#define AFSDIR_BOZCONF_FILE "BosConfig" -#define AFSDIR_BOZCONFNEW_FILE "BosConfig.new" -#define AFSDIR_BOZINIT_FILE "BozoInit" -#define AFSDIR_BOZLOG_FILE "BosLog" -#define AFSDIR_BOSVR_FILE "bosserver" -#define AFSDIR_VOLSERLOG_FILE "VolserLog" -#define AFSDIR_AUDIT_FILE "Audit" - -#define AFSDIR_ROOTVOL_FILE "RootVolume" -#define AFSDIR_HOSTDUMP_FILE "hosts.dump" -#define AFSDIR_CLNTDUMP_FILE "client.dump" -#define AFSDIR_CBKDUMP_FILE "callback.dump" -#define AFSDIR_OLDSYSID_FILE "sysid.old" -#define AFSDIR_SYSID_FILE "sysid" -#define AFSDIR_FILELOG_FILE "FileLog" -#define AFSDIR_MIGRATE_LOGNAME "wtlog." - -#define AFSDIR_CELLSERVDB_FILE_NTCLIENT "afsdcell.ini" - -#define AFSDIR_NETINFO_FILE "NetInfo" -#define AFSDIR_NETRESTRICT_FILE "NetRestrict" - -#define AFSDIR_LOCALRESIDENCY_FILE "LocalResidency" -#define AFSDIR_WEIGHTINGCONST_FILE "Weight.LocalConstants" -#define AFSDIR_THRESHOLDCONST_FILE "Thershold.LocalConstants" - -/* -------------- Canonical (wire-format) path macros -------------- */ - -/* Each of the following is a canonical form of the corresponding - * local (AFSDIR_*) path macro. - */ - -#define AFSDIR_CANONICAL_USR_DIRPATH "/usr" -#define AFSDIR_CANONICAL_SERVER_AFS_DIRPATH "/usr/afs" -#define AFSDIR_CANONICAL_CLIENT_VICE_DIRPATH "/usr/vice" -#ifdef AFS_DARWIN_ENV -#define AFSDIR_ALTERNATE_CLIENT_VICE_DIRPATH "/var/db/openafs" -#endif - -#define AFSDIR_CANONICAL_SERVER_BIN_DIRPATH \ -AFSDIR_CANONICAL_SERVER_AFS_DIRPATH "/" AFSDIR_BIN_DIR - -#define AFSDIR_CANONICAL_SERVER_ETC_DIRPATH \ -AFSDIR_CANONICAL_SERVER_AFS_DIRPATH "/" AFSDIR_ETC_DIR - -#define AFSDIR_CANONICAL_SERVER_LOGS_DIRPATH \ -AFSDIR_CANONICAL_SERVER_AFS_DIRPATH "/" AFSDIR_LOGS_DIR - -#define AFSDIR_CANONICAL_SERVER_LOCAL_DIRPATH \ -AFSDIR_CANONICAL_SERVER_AFS_DIRPATH "/" AFSDIR_LOCAL_DIR - - -#define AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH \ -AFSDIR_CANONICAL_SERVER_BIN_DIRPATH "/" AFSDIR_SALVAGER_FILE - -#define AFSDIR_CANONICAL_SERVER_SLVGLOG_FILEPATH \ -AFSDIR_CANONICAL_SERVER_LOGS_DIRPATH "/" AFSDIR_SLVGLOG_FILE - - -/* --------------------- Local path macros ---------------------- */ - -/* Note: On NT, these should be used only after calling initAFSDirPath(). - * On Unix, the paths are implicitly initialized. - */ - -/* enums for indexes into the pathname array */ -typedef enum afsdir_id { - AFSDIR_USR_DIRPATH_ID, - AFSDIR_SERVER_AFS_DIRPATH_ID, - AFSDIR_SERVER_ETC_DIRPATH_ID, - AFSDIR_SERVER_BIN_DIRPATH_ID, - AFSDIR_SERVER_CORES_DIRPATH_ID, - AFSDIR_SERVER_DB_DIRPATH_ID, - AFSDIR_SERVER_LOGS_DIRPATH_ID, - AFSDIR_SERVER_LOCAL_DIRPATH_ID, - AFSDIR_SERVER_BACKUP_DIRPATH_ID, - AFSDIR_CLIENT_VICE_DIRPATH_ID, - AFSDIR_CLIENT_ETC_DIRPATH_ID, - AFSDIR_SERVER_THISCELL_FILEPATH_ID, - AFSDIR_SERVER_CELLSERVDB_FILEPATH_ID, - AFSDIR_SERVER_NOAUTH_FILEPATH_ID, - AFSDIR_SERVER_KEY_FILEPATH_ID, - AFSDIR_SERVER_ULIST_FILEPATH_ID, - AFSDIR_SERVER_BUDBLOG_FILEPATH_ID, - AFSDIR_SERVER_TAPECONFIG_FILEPATH_ID, - AFSDIR_SERVER_KALOGDB_FILEPATH_ID, - AFSDIR_SERVER_KALOG_FILEPATH_ID, - AFSDIR_SERVER_KADB_FILEPATH_ID, - AFSDIR_SERVER_NTPD_FILEPATH_ID, - AFSDIR_SERVER_PRDB_FILEPATH_ID, - AFSDIR_SERVER_PTLOG_FILEPATH_ID, - AFSDIR_SERVER_KCONF_FILEPATH_ID, - AFSDIR_SERVER_VLDB_FILEPATH_ID, - AFSDIR_SERVER_VLOG_FILEPATH_ID, - AFSDIR_SERVER_CORELOG_FILEPATH_ID, - AFSDIR_SERVER_SLVGLOG_FILEPATH_ID, - AFSDIR_SERVER_SALVAGER_FILEPATH_ID, - AFSDIR_SERVER_BOZCONF_FILEPATH_ID, - AFSDIR_SERVER_BOZCONFNEW_FILEPATH_ID, - AFSDIR_SERVER_BOZINIT_FILEPATH_ID, - AFSDIR_SERVER_BOZLOG_FILEPATH_ID, - AFSDIR_SERVER_BOSVR_FILEPATH_ID, - AFSDIR_SERVER_SLVGLOCK_FILEPATH_ID, - AFSDIR_SERVER_VOLSERLOG_FILEPATH_ID, - AFSDIR_SERVER_ROOTVOL_FILEPATH_ID, - AFSDIR_SERVER_HOSTDUMP_FILEPATH_ID, - AFSDIR_SERVER_CLNTDUMP_FILEPATH_ID, - AFSDIR_SERVER_CBKDUMP_FILEPATH_ID, - AFSDIR_SERVER_OLDSYSID_FILEPATH_ID, - AFSDIR_SERVER_SYSID_FILEPATH_ID, - AFSDIR_SERVER_FILELOG_FILEPATH_ID, - AFSDIR_SERVER_AUDIT_FILEPATH_ID, - AFSDIR_CLIENT_THISCELL_FILEPATH_ID, - AFSDIR_CLIENT_CELLSERVDB_FILEPATH_ID, - AFSDIR_CLIENT_NETINFO_FILEPATH_ID, - AFSDIR_CLIENT_NETRESTRICT_FILEPATH_ID, - AFSDIR_SERVER_NETINFO_FILEPATH_ID, - AFSDIR_SERVER_NETRESTRICT_FILEPATH_ID, - AFSDIR_SERVER_WEIGHTING_CONSTANTS_FILEPATH_ID, - AFSDIR_SERVER_THRESHOLD_CONSTANTS_FILEPATH_ID, - AFSDIR_SERVER_MIGRATE_DIRPATH_ID, - AFSDIR_SERVER_MIGRATELOG_FILEPATH_ID, - AFSDIR_SERVER_BIN_FILE_DIRPATH_ID, - AFSDIR_PATHSTRING_MAX } afsdir_id_t; - -/* getDirPath() returns a pointer to a string from an internal array of path strings - */ -const char *getDirPath(afsdir_id_t string_id); - -/* Top level usr dir */ -#define AFSDIR_USR_DIRPATH getDirPath(AFSDIR_USR_DIRPATH_ID) - -/* server subdir paths */ -#define AFSDIR_SERVER_AFS_DIRPATH getDirPath(AFSDIR_SERVER_AFS_DIRPATH_ID) -#define AFSDIR_SERVER_ETC_DIRPATH getDirPath(AFSDIR_SERVER_ETC_DIRPATH_ID) -#define AFSDIR_SERVER_BIN_DIRPATH getDirPath(AFSDIR_SERVER_BIN_DIRPATH_ID) -#define AFSDIR_SERVER_CORES_DIRPATH getDirPath(AFSDIR_SERVER_CORES_DIRPATH_ID) -#define AFSDIR_SERVER_DB_DIRPATH getDirPath(AFSDIR_SERVER_DB_DIRPATH_ID) -#define AFSDIR_SERVER_LOGS_DIRPATH getDirPath(AFSDIR_SERVER_LOGS_DIRPATH_ID) -#define AFSDIR_SERVER_LOCAL_DIRPATH getDirPath(AFSDIR_SERVER_LOCAL_DIRPATH_ID) -#define AFSDIR_SERVER_BACKUP_DIRPATH getDirPath(AFSDIR_SERVER_BACKUP_DIRPATH_ID) -#define AFSDIR_SERVER_LOCAL_DIRPATH getDirPath(AFSDIR_SERVER_LOCAL_DIRPATH_ID) -#define AFSDIR_SERVER_MIGRATE_DIRPATH getDirPath(AFSDIR_SERVER_MIGRATE_DIRPATH_ID) -#define AFSDIR_SERVER_MIGRATE_DIRPATH getDirPath(AFSDIR_SERVER_MIGRATE_DIRPATH_ID) - -/* client subdir paths */ -#define AFSDIR_CLIENT_VICE_DIRPATH getDirPath(AFSDIR_CLIENT_VICE_DIRPATH_ID) -#define AFSDIR_CLIENT_ETC_DIRPATH getDirPath(AFSDIR_CLIENT_ETC_DIRPATH_ID) -#define AFSDIR_SERVER_BIN_FILE_DIRPATH getDirPath(AFSDIR_SERVER_BIN_FILE_DIRPATH_ID) - -/* server file paths */ -#define AFSDIR_SERVER_THISCELL_FILEPATH getDirPath(AFSDIR_SERVER_THISCELL_FILEPATH_ID) -#define AFSDIR_SERVER_CELLSERVDB_FILEPATH getDirPath(AFSDIR_SERVER_CELLSERVDB_FILEPATH_ID) -#define AFSDIR_SERVER_NOAUTH_FILEPATH getDirPath(AFSDIR_SERVER_NOAUTH_FILEPATH_ID) -#define AFSDIR_SERVER_KEY_FILEPATH getDirPath(AFSDIR_SERVER_KEY_FILEPATH_ID) -#define AFSDIR_SERVER_ULIST_FILEPATH getDirPath(AFSDIR_SERVER_ULIST_FILEPATH_ID) -#define AFSDIR_SERVER_BUDBLOG_FILEPATH getDirPath(AFSDIR_SERVER_BUDBLOG_FILEPATH_ID) -#define AFSDIR_SERVER_TAPECONFIG_FILEPATH getDirPath(AFSDIR_SERVER_TAPECONFIG_FILEPATH_ID) -#define AFSDIR_SERVER_KALOGDB_FILEPATH getDirPath(AFSDIR_SERVER_KALOGDB_FILEPATH_ID) -#define AFSDIR_SERVER_KALOG_FILEPATH getDirPath(AFSDIR_SERVER_KALOG_FILEPATH_ID) -#define AFSDIR_SERVER_KADB_FILEPATH getDirPath(AFSDIR_SERVER_KADB_FILEPATH_ID) -#define AFSDIR_SERVER_NTPD_FILEPATH getDirPath(AFSDIR_SERVER_NTPD_FILEPATH_ID) -#define AFSDIR_SERVER_PRDB_FILEPATH getDirPath(AFSDIR_SERVER_PRDB_FILEPATH_ID) -#define AFSDIR_SERVER_PTLOG_FILEPATH getDirPath(AFSDIR_SERVER_PTLOG_FILEPATH_ID) -#define AFSDIR_SERVER_KCONF_FILEPATH getDirPath(AFSDIR_SERVER_KCONF_FILEPATH_ID) -#define AFSDIR_SERVER_VLDB_FILEPATH getDirPath(AFSDIR_SERVER_VLDB_FILEPATH_ID) -#define AFSDIR_SERVER_VLOG_FILEPATH getDirPath(AFSDIR_SERVER_VLOG_FILEPATH_ID) -#define AFSDIR_SERVER_CORELOG_FILEPATH getDirPath(AFSDIR_SERVER_CORELOG_FILEPATH_ID) -#define AFSDIR_SERVER_SLVGLOG_FILEPATH getDirPath(AFSDIR_SERVER_SLVGLOG_FILEPATH_ID) -#define AFSDIR_SERVER_SALVAGER_FILEPATH getDirPath(AFSDIR_SERVER_SALVAGER_FILEPATH_ID) -#define AFSDIR_SERVER_BOZCONF_FILEPATH getDirPath(AFSDIR_SERVER_BOZCONF_FILEPATH_ID) -#define AFSDIR_SERVER_BOZCONFNEW_FILEPATH getDirPath(AFSDIR_SERVER_BOZCONFNEW_FILEPATH_ID) -#define AFSDIR_SERVER_BOZINIT_FILEPATH getDirPath(AFSDIR_SERVER_BOZINIT_FILEPATH_ID) -#define AFSDIR_SERVER_BOZLOG_FILEPATH getDirPath(AFSDIR_SERVER_BOZLOG_FILEPATH_ID) -#define AFSDIR_SERVER_BOSVR_FILEPATH getDirPath(AFSDIR_SERVER_BOSVR_FILEPATH_ID) -#define AFSDIR_SERVER_SLVGLOCK_FILEPATH getDirPath(AFSDIR_SERVER_SLVGLOCK_FILEPATH_ID) -#define AFSDIR_SERVER_VOLSERLOG_FILEPATH getDirPath(AFSDIR_SERVER_VOLSERLOG_FILEPATH_ID) -#define AFSDIR_SERVER_ROOTVOL_FILEPATH getDirPath(AFSDIR_SERVER_ROOTVOL_FILEPATH_ID) -#define AFSDIR_SERVER_HOSTDUMP_FILEPATH getDirPath(AFSDIR_SERVER_HOSTDUMP_FILEPATH_ID) -#define AFSDIR_SERVER_CLNTDUMP_FILEPATH getDirPath(AFSDIR_SERVER_CLNTDUMP_FILEPATH_ID) -#define AFSDIR_SERVER_CBKDUMP_FILEPATH getDirPath(AFSDIR_SERVER_CBKDUMP_FILEPATH_ID) -#define AFSDIR_SERVER_OLDSYSID_FILEPATH getDirPath(AFSDIR_SERVER_OLDSYSID_FILEPATH_ID) -#define AFSDIR_SERVER_SYSID_FILEPATH getDirPath(AFSDIR_SERVER_SYSID_FILEPATH_ID) -#define AFSDIR_SERVER_FILELOG_FILEPATH getDirPath(AFSDIR_SERVER_FILELOG_FILEPATH_ID) -#define AFSDIR_SERVER_AUDIT_FILEPATH getDirPath(AFSDIR_SERVER_AUDIT_FILEPATH_ID) -#define AFSDIR_SERVER_NETINFO_FILEPATH getDirPath(AFSDIR_SERVER_NETINFO_FILEPATH_ID) -#define AFSDIR_SERVER_NETRESTRICT_FILEPATH getDirPath(AFSDIR_SERVER_NETRESTRICT_FILEPATH_ID) -#define AFSDIR_SERVER_WEIGHTING_CONSTANTS_FILEPATH getDirPath(AFSDIR_SERVER_WEIGHTING_CONSTANTS_FILEPATH_ID) -#define AFSDIR_SERVER_THRESHOLD_CONSTANTS_FILEPATH getDirPath(AFSDIR_SERVER_THRESHOLD_CONSTANTS_FILEPATH_ID) -#define AFSDIR_SERVER_MIGRATELOG_FILEPATH getDirPath(AFSDIR_SERVER_MIGRATELOG_FILEPATH_ID) - -/* client file paths */ -#define AFSDIR_CLIENT_THISCELL_FILEPATH getDirPath(AFSDIR_CLIENT_THISCELL_FILEPATH_ID) -#define AFSDIR_CLIENT_CELLSERVDB_FILEPATH getDirPath(AFSDIR_CLIENT_CELLSERVDB_FILEPATH_ID) -#define AFSDIR_CLIENT_NETINFO_FILEPATH getDirPath(AFSDIR_CLIENT_NETINFO_FILEPATH_ID) -#define AFSDIR_CLIENT_NETRESTRICT_FILEPATH getDirPath(AFSDIR_CLIENT_NETRESTRICT_FILEPATH_ID) - -#endif /* _DIRPATH_H */ diff --git a/src/util/dirpath.hin b/src/util/dirpath.hin new file mode 100644 index 000000000..1a6380365 --- /dev/null +++ b/src/util/dirpath.hin @@ -0,0 +1,336 @@ +/* + * Copyright 2000, International Business Machines Corporation and others. + * All Rights Reserved. + * + * This software has been released under the terms of the IBM Public + * License. For details, see the LICENSE file in the top-level source + * directory or online at http://www.openafs.org/dl/license10.html + */ + +#ifndef _DIRPATH_H +#define _DIRPATH_H + +/* Dirpath package: Rationale and Usage + * + * With the port of AFS to Windows NT, it becomes necessary to support + * storing AFS system files (binaries, logs, etc.) in a user-specified + * installation directory. This breaks from the traditional notion of + * all AFS system files being stored under /usr/afs or /usr/vice. + * In addition, now that OpenAFs supports configure, it is desirable + * to support the configure options for manipulating directories and + * setting the compilation prefix. + * For NT, the core concept is that there is a dynamically determined installation + * directory that is the prefix to a well-known AFS tree. The structure + * of this well-known AFS tree remains unchanged. For example, AFS server + * binaries reside in /usr/afs/bin, server configuration files + * reside in /usr/afs/etc, etcetera. This scheme allows the + * flexibility required by NT. + * On UNIX, this header file is generated by configure. Directory + * paths are substituted in based on options passed to configure. + * While the server and client roots are maintained in the dirpath + * array, they should never be used by the code as they tend to be + * meaningless. + * Thus file paths can no longer be hard-coded; rather, all file paths are + * specified via the macros provided by this package. + * + * Utilizing a dynamically determined installation directory forces the + * notion of local versus canonical (wire-format) paths. A local path is + * fully qualified (with a syntax determined by the native filesystem type) + * whereas a canonical path specifies location only within the well-known AFS + * tree. Supporting the notion of canonical paths allows the same path to + * be sent to servers on different machines, having different installation + * directories, with the desired result. + * + * For example, 'bos create kaserver simple /usr/afs/bin/kasever' will + * work both on a Unix machine, where the kaserver executable actually resides + * in /usr/afs/bin, and on a NT machine, where the kaserver may reside in + * C:/Program Files/Transarc/AFS Server/usr/afs/bin. + * + * Conversion functions are provided that translate canonical (wire-format) + * paths to fully qualified local paths; see the documentation in dirpath.c + * for details. Note that these conversion functions also try to + * accomodate fully qualified paths on the wire, for exceptional + * cases where this feature may be required. Unfortunately there is + * no way to distinguish between canonical and fully qualified paths + * so if for example /usr/afs/bin is both a valid canonical and local + * path and they do not both map to the same place, then the canonical + * path is used. + * + * The path macros provided here are divided into local (AFSDIR_*) and + * canonical (AFSDIR_CANONICAL_*). The canonical macros MUST be used by + * commands that send a non-user-specified path to a server (i.e., over + * the wire). The local macros MUST be used in all other cases. + */ + + + +#include + +#ifdef AFS_NT40_ENV +#include +#endif +#include + +/* Max dir path size for afs install dirs */ +#ifdef AFS_NT40_ENV +#define AFSDIR_PATH_MAX MAX_PATH +#else /* unices */ +#define AFSDIR_PATH_MAX _POSIX_PATH_MAX +#endif + + +/* --------------------- Exported functions ---------------------- */ + + +#define AFSDIR_CLIENT_PATHS_OK 0x1 /* client paths initialized correctly */ +#define AFSDIR_SERVER_PATHS_OK 0x2 /* server paths initialized correctly */ +extern unsigned int initAFSDirPath(void); + +extern int +ConstructLocalPath(const char *cpath, + const char *relativeTo, + char **fullPathBufp); +extern int +ConstructLocalBinPath(const char *cpath, + char **fullPathBufp); +extern int +ConstructLocalLogPath(const char *cpath, + char **fullPathBufp); + + + +/* ----------------- Directory/file name macros ------------------ */ + +/* afs installation dir names */ +#define AFSDIR_SERVER_ETC_DIR "@afsconfdir" +#define AFSDIR_CLIENT_ETC_DIR "@viceetcdir" +#define AFSDIR_SERVER_BIN_DIR "@afssrvdir" +#define AFSDIR_CORES_DIR "cores" +#define AFSDIR_DB_DIR "@afsdbdir" +#define AFSDIR_LOGS_DIR "@afslogsdir" +#define AFSDIR_LOCAL_DIR "@afslocaldir" +#define AFSDIR_BACKUP_DIR "@afsbackupdir" +#define AFSDIR_MIGR_DIR "@afslocaldir/migrate" +#define AFSDIR_BIN_FILE_DIR "@afslocaldir/migrate/bin_files" +#define AFSDIR_BOSCONFIG_DIR "@afsbosconfigdir" +#define AFSDIR_BOSSERVER_DIR "@afsbosserverdir" + +/* file names */ +#define AFSDIR_THISCELL_FILE "ThisCell" +#define AFSDIR_CELLSERVDB_FILE "CellServDB" +#define AFSDIR_KEY_FILE "KeyFile" +#define AFSDIR_ULIST_FILE "UserList" +#define AFSDIR_NOAUTH_FILE "NoAuth" +#define AFSDIR_BUDBLOG_FILE "BackupLog" +#define AFSDIR_TAPECONFIG_FILE "tapeconfig" +#define AFSDIR_KALOGDB_FILE "AuthLog" +#define AFSDIR_KALOG_FILE "AuthLog" +#define AFSDIR_KADB_FILE "kaserver" +#define AFSDIR_NTPD_FILE "ntpd" +#define AFSDIR_PRDB_FILE "prdb" +#define AFSDIR_PTLOG_FILE "PtLog" +#define AFSDIR_KCONF_FILE "krb.conf" +#define AFSDIR_VLDB_FILE "vldb" +#define AFSDIR_VLOG_FILE "VLLog" +#define AFSDIR_CORE_FILE "core" +#define AFSDIR_SLVGLOG_FILE "SalvageLog" +#define AFSDIR_SALVAGER_FILE "salvager" +#define AFSDIR_SLVGLOCK_FILE "salvage.lock" +#define AFSDIR_BOZCONF_FILE "BosConfig" +#define AFSDIR_BOZCONFNEW_FILE "BosConfig.new" +#define AFSDIR_BOZINIT_FILE "BozoInit" +#define AFSDIR_BOZLOG_FILE "BosLog" +#define AFSDIR_BOSVR_FILE "bosserver" +#define AFSDIR_VOLSERLOG_FILE "VolserLog" +#define AFSDIR_AUDIT_FILE "Audit" + +#define AFSDIR_ROOTVOL_FILE "RootVolume" +#define AFSDIR_HOSTDUMP_FILE "hosts.dump" +#define AFSDIR_CLNTDUMP_FILE "client.dump" +#define AFSDIR_CBKDUMP_FILE "callback.dump" +#define AFSDIR_OLDSYSID_FILE "sysid.old" +#define AFSDIR_SYSID_FILE "sysid" +#define AFSDIR_FILELOG_FILE "FileLog" +#define AFSDIR_MIGRATE_LOGNAME "wtlog." + +#define AFSDIR_CELLSERVDB_FILE_NTCLIENT "afsdcell.ini" + +#define AFSDIR_NETINFO_FILE "NetInfo" +#define AFSDIR_NETRESTRICT_FILE "NetRestrict" + +#define AFSDIR_LOCALRESIDENCY_FILE "LocalResidency" +#define AFSDIR_WEIGHTINGCONST_FILE "Weight.LocalConstants" +#define AFSDIR_THRESHOLDCONST_FILE "Thershold.LocalConstants" + +/* -------------- Canonical (wire-format) path macros -------------- */ + +/* Each of the following is a canonical form of the corresponding + * local (AFSDIR_*) path macro. + */ + +#define AFSDIR_CANONICAL_USR_DIRPATH "/usr" +#define AFSDIR_CANONICAL_SERVER_AFS_DIRPATH "/usr/afs" +#define AFSDIR_CANONICAL_CLIENT_VICE_DIRPATH "/usr/vice" +#ifdef AFS_DARWIN_ENV +#define AFSDIR_ALTERNATE_CLIENT_VICE_DIRPATH "/var/db/openafs" +#endif + +#define AFSDIR_CANONICAL_SERVER_BIN_DIRPATH \ +AFSDIR_CANONICAL_SERVER_AFS_DIRPATH "/bin" + +#define AFSDIR_CANONICAL_SERVER_ETC_DIRPATH \ +AFSDIR_CANONICAL_SERVER_AFS_DIRPATH "/etc" + +#define AFSDIR_CANONICAL_SERVER_LOGS_DIRPATH \ +AFSDIR_CANONICAL_SERVER_AFS_DIRPATH "/logs" + +#define AFSDIR_CANONICAL_SERVER_LOCAL_DIRPATH \ +AFSDIR_CANONICAL_SERVER_AFS_DIRPATH "/local" + + +#define AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH \ +AFSDIR_CANONICAL_SERVER_BIN_DIRPATH "/" AFSDIR_SALVAGER_FILE + +#define AFSDIR_CANONICAL_SERVER_SLVGLOG_FILEPATH \ +AFSDIR_CANONICAL_SERVER_LOGS_DIRPATH "/" AFSDIR_SLVGLOG_FILE + + +/* --------------------- Local path macros ---------------------- */ + +/* Note: On NT, these should be used only after calling initAFSDirPath(). + * On Unix, the paths are implicitly initialized. + */ + +/* enums for indexes into the pathname array */ +typedef enum afsdir_id { + AFSDIR_USR_DIRPATH_ID, + AFSDIR_SERVER_AFS_DIRPATH_ID, + AFSDIR_SERVER_ETC_DIRPATH_ID, + AFSDIR_SERVER_BIN_DIRPATH_ID, + AFSDIR_SERVER_CORES_DIRPATH_ID, + AFSDIR_SERVER_DB_DIRPATH_ID, + AFSDIR_SERVER_LOGS_DIRPATH_ID, + AFSDIR_SERVER_LOCAL_DIRPATH_ID, + AFSDIR_SERVER_BACKUP_DIRPATH_ID, + AFSDIR_CLIENT_VICE_DIRPATH_ID, + AFSDIR_CLIENT_ETC_DIRPATH_ID, + AFSDIR_SERVER_THISCELL_FILEPATH_ID, + AFSDIR_SERVER_CELLSERVDB_FILEPATH_ID, + AFSDIR_SERVER_NOAUTH_FILEPATH_ID, + AFSDIR_SERVER_KEY_FILEPATH_ID, + AFSDIR_SERVER_ULIST_FILEPATH_ID, + AFSDIR_SERVER_BUDBLOG_FILEPATH_ID, + AFSDIR_SERVER_TAPECONFIG_FILEPATH_ID, + AFSDIR_SERVER_KALOGDB_FILEPATH_ID, + AFSDIR_SERVER_KALOG_FILEPATH_ID, + AFSDIR_SERVER_KADB_FILEPATH_ID, + AFSDIR_SERVER_NTPD_FILEPATH_ID, + AFSDIR_SERVER_PRDB_FILEPATH_ID, + AFSDIR_SERVER_PTLOG_FILEPATH_ID, + AFSDIR_SERVER_KCONF_FILEPATH_ID, + AFSDIR_SERVER_VLDB_FILEPATH_ID, + AFSDIR_SERVER_VLOG_FILEPATH_ID, + AFSDIR_SERVER_CORELOG_FILEPATH_ID, + AFSDIR_SERVER_SLVGLOG_FILEPATH_ID, + AFSDIR_SERVER_SALVAGER_FILEPATH_ID, + AFSDIR_SERVER_BOZCONF_FILEPATH_ID, + AFSDIR_SERVER_BOZCONFNEW_FILEPATH_ID, + AFSDIR_SERVER_BOZINIT_FILEPATH_ID, + AFSDIR_SERVER_BOZLOG_FILEPATH_ID, + AFSDIR_SERVER_BOSVR_FILEPATH_ID, + AFSDIR_SERVER_SLVGLOCK_FILEPATH_ID, + AFSDIR_SERVER_VOLSERLOG_FILEPATH_ID, + AFSDIR_SERVER_ROOTVOL_FILEPATH_ID, + AFSDIR_SERVER_HOSTDUMP_FILEPATH_ID, + AFSDIR_SERVER_CLNTDUMP_FILEPATH_ID, + AFSDIR_SERVER_CBKDUMP_FILEPATH_ID, + AFSDIR_SERVER_OLDSYSID_FILEPATH_ID, + AFSDIR_SERVER_SYSID_FILEPATH_ID, + AFSDIR_SERVER_FILELOG_FILEPATH_ID, + AFSDIR_SERVER_AUDIT_FILEPATH_ID, + AFSDIR_CLIENT_THISCELL_FILEPATH_ID, + AFSDIR_CLIENT_CELLSERVDB_FILEPATH_ID, + AFSDIR_CLIENT_NETINFO_FILEPATH_ID, + AFSDIR_CLIENT_NETRESTRICT_FILEPATH_ID, + AFSDIR_SERVER_NETINFO_FILEPATH_ID, + AFSDIR_SERVER_NETRESTRICT_FILEPATH_ID, + AFSDIR_SERVER_WEIGHTING_CONSTANTS_FILEPATH_ID, + AFSDIR_SERVER_THRESHOLD_CONSTANTS_FILEPATH_ID, + AFSDIR_SERVER_MIGRATE_DIRPATH_ID, + AFSDIR_SERVER_MIGRATELOG_FILEPATH_ID, + AFSDIR_SERVER_BIN_FILE_DIRPATH_ID, + AFSDIR_PATHSTRING_MAX } afsdir_id_t; + +/* getDirPath() returns a pointer to a string from an internal array of path strings + */ +const char *getDirPath(afsdir_id_t string_id); + +/* Top level usr dir */ +#define AFSDIR_USR_DIRPATH getDirPath(AFSDIR_USR_DIRPATH_ID) + +/* server subdir paths */ +#define AFSDIR_SERVER_AFS_DIRPATH getDirPath(AFSDIR_SERVER_AFS_DIRPATH_ID) +#define AFSDIR_SERVER_ETC_DIRPATH getDirPath(AFSDIR_SERVER_ETC_DIRPATH_ID) +#define AFSDIR_SERVER_BIN_DIRPATH getDirPath(AFSDIR_SERVER_BIN_DIRPATH_ID) +#define AFSDIR_SERVER_CORES_DIRPATH getDirPath(AFSDIR_SERVER_CORES_DIRPATH_ID) +#define AFSDIR_SERVER_DB_DIRPATH getDirPath(AFSDIR_SERVER_DB_DIRPATH_ID) +#define AFSDIR_SERVER_LOGS_DIRPATH getDirPath(AFSDIR_SERVER_LOGS_DIRPATH_ID) +#define AFSDIR_SERVER_LOCAL_DIRPATH getDirPath(AFSDIR_SERVER_LOCAL_DIRPATH_ID) +#define AFSDIR_SERVER_BACKUP_DIRPATH getDirPath(AFSDIR_SERVER_BACKUP_DIRPATH_ID) +#define AFSDIR_SERVER_LOCAL_DIRPATH getDirPath(AFSDIR_SERVER_LOCAL_DIRPATH_ID) +#define AFSDIR_SERVER_MIGRATE_DIRPATH getDirPath(AFSDIR_SERVER_MIGRATE_DIRPATH_ID) +#define AFSDIR_SERVER_MIGRATE_DIRPATH getDirPath(AFSDIR_SERVER_MIGRATE_DIRPATH_ID) + +/* client subdir paths */ +#define AFSDIR_CLIENT_VICE_DIRPATH getDirPath(AFSDIR_CLIENT_VICE_DIRPATH_ID) +#define AFSDIR_CLIENT_ETC_DIRPATH getDirPath(AFSDIR_CLIENT_ETC_DIRPATH_ID) +#define AFSDIR_SERVER_BIN_FILE_DIRPATH getDirPath(AFSDIR_SERVER_BIN_FILE_DIRPATH_ID) + +/* server file paths */ +#define AFSDIR_SERVER_THISCELL_FILEPATH getDirPath(AFSDIR_SERVER_THISCELL_FILEPATH_ID) +#define AFSDIR_SERVER_CELLSERVDB_FILEPATH getDirPath(AFSDIR_SERVER_CELLSERVDB_FILEPATH_ID) +#define AFSDIR_SERVER_NOAUTH_FILEPATH getDirPath(AFSDIR_SERVER_NOAUTH_FILEPATH_ID) +#define AFSDIR_SERVER_KEY_FILEPATH getDirPath(AFSDIR_SERVER_KEY_FILEPATH_ID) +#define AFSDIR_SERVER_ULIST_FILEPATH getDirPath(AFSDIR_SERVER_ULIST_FILEPATH_ID) +#define AFSDIR_SERVER_BUDBLOG_FILEPATH getDirPath(AFSDIR_SERVER_BUDBLOG_FILEPATH_ID) +#define AFSDIR_SERVER_TAPECONFIG_FILEPATH getDirPath(AFSDIR_SERVER_TAPECONFIG_FILEPATH_ID) +#define AFSDIR_SERVER_KALOGDB_FILEPATH getDirPath(AFSDIR_SERVER_KALOGDB_FILEPATH_ID) +#define AFSDIR_SERVER_KALOG_FILEPATH getDirPath(AFSDIR_SERVER_KALOG_FILEPATH_ID) +#define AFSDIR_SERVER_KADB_FILEPATH getDirPath(AFSDIR_SERVER_KADB_FILEPATH_ID) +#define AFSDIR_SERVER_NTPD_FILEPATH getDirPath(AFSDIR_SERVER_NTPD_FILEPATH_ID) +#define AFSDIR_SERVER_PRDB_FILEPATH getDirPath(AFSDIR_SERVER_PRDB_FILEPATH_ID) +#define AFSDIR_SERVER_PTLOG_FILEPATH getDirPath(AFSDIR_SERVER_PTLOG_FILEPATH_ID) +#define AFSDIR_SERVER_KCONF_FILEPATH getDirPath(AFSDIR_SERVER_KCONF_FILEPATH_ID) +#define AFSDIR_SERVER_VLDB_FILEPATH getDirPath(AFSDIR_SERVER_VLDB_FILEPATH_ID) +#define AFSDIR_SERVER_VLOG_FILEPATH getDirPath(AFSDIR_SERVER_VLOG_FILEPATH_ID) +#define AFSDIR_SERVER_CORELOG_FILEPATH getDirPath(AFSDIR_SERVER_CORELOG_FILEPATH_ID) +#define AFSDIR_SERVER_SLVGLOG_FILEPATH getDirPath(AFSDIR_SERVER_SLVGLOG_FILEPATH_ID) +#define AFSDIR_SERVER_SALVAGER_FILEPATH getDirPath(AFSDIR_SERVER_SALVAGER_FILEPATH_ID) +#define AFSDIR_SERVER_BOZCONF_FILEPATH getDirPath(AFSDIR_SERVER_BOZCONF_FILEPATH_ID) +#define AFSDIR_SERVER_BOZCONFNEW_FILEPATH getDirPath(AFSDIR_SERVER_BOZCONFNEW_FILEPATH_ID) +#define AFSDIR_SERVER_BOZINIT_FILEPATH getDirPath(AFSDIR_SERVER_BOZINIT_FILEPATH_ID) +#define AFSDIR_SERVER_BOZLOG_FILEPATH getDirPath(AFSDIR_SERVER_BOZLOG_FILEPATH_ID) +#define AFSDIR_SERVER_BOSVR_FILEPATH getDirPath(AFSDIR_SERVER_BOSVR_FILEPATH_ID) +#define AFSDIR_SERVER_SLVGLOCK_FILEPATH getDirPath(AFSDIR_SERVER_SLVGLOCK_FILEPATH_ID) +#define AFSDIR_SERVER_VOLSERLOG_FILEPATH getDirPath(AFSDIR_SERVER_VOLSERLOG_FILEPATH_ID) +#define AFSDIR_SERVER_ROOTVOL_FILEPATH getDirPath(AFSDIR_SERVER_ROOTVOL_FILEPATH_ID) +#define AFSDIR_SERVER_HOSTDUMP_FILEPATH getDirPath(AFSDIR_SERVER_HOSTDUMP_FILEPATH_ID) +#define AFSDIR_SERVER_CLNTDUMP_FILEPATH getDirPath(AFSDIR_SERVER_CLNTDUMP_FILEPATH_ID) +#define AFSDIR_SERVER_CBKDUMP_FILEPATH getDirPath(AFSDIR_SERVER_CBKDUMP_FILEPATH_ID) +#define AFSDIR_SERVER_OLDSYSID_FILEPATH getDirPath(AFSDIR_SERVER_OLDSYSID_FILEPATH_ID) +#define AFSDIR_SERVER_SYSID_FILEPATH getDirPath(AFSDIR_SERVER_SYSID_FILEPATH_ID) +#define AFSDIR_SERVER_FILELOG_FILEPATH getDirPath(AFSDIR_SERVER_FILELOG_FILEPATH_ID) +#define AFSDIR_SERVER_AUDIT_FILEPATH getDirPath(AFSDIR_SERVER_AUDIT_FILEPATH_ID) +#define AFSDIR_SERVER_NETINFO_FILEPATH getDirPath(AFSDIR_SERVER_NETINFO_FILEPATH_ID) +#define AFSDIR_SERVER_NETRESTRICT_FILEPATH getDirPath(AFSDIR_SERVER_NETRESTRICT_FILEPATH_ID) +#define AFSDIR_SERVER_WEIGHTING_CONSTANTS_FILEPATH getDirPath(AFSDIR_SERVER_WEIGHTING_CONSTANTS_FILEPATH_ID) +#define AFSDIR_SERVER_THRESHOLD_CONSTANTS_FILEPATH getDirPath(AFSDIR_SERVER_THRESHOLD_CONSTANTS_FILEPATH_ID) +#define AFSDIR_SERVER_MIGRATELOG_FILEPATH getDirPath(AFSDIR_SERVER_MIGRATELOG_FILEPATH_ID) + +/* client file paths */ +#define AFSDIR_CLIENT_THISCELL_FILEPATH getDirPath(AFSDIR_CLIENT_THISCELL_FILEPATH_ID) +#define AFSDIR_CLIENT_CELLSERVDB_FILEPATH getDirPath(AFSDIR_CLIENT_CELLSERVDB_FILEPATH_ID) +#define AFSDIR_CLIENT_NETINFO_FILEPATH getDirPath(AFSDIR_CLIENT_NETINFO_FILEPATH_ID) +#define AFSDIR_CLIENT_NETRESTRICT_FILEPATH getDirPath(AFSDIR_CLIENT_NETRESTRICT_FILEPATH_ID) + +#endif /* _DIRPATH_H */