X-Git-Url: https://git.openafs.org/?p=openafs.git;a=blobdiff_plain;f=src%2Fauth%2Fcellconfig.c;h=81f78dd8f159133240e310fff7da1aa1325283a0;hp=e6d1b8b6373a1f7121d08af298639a7f450a530d;hb=c4a127d0578e521b97131c5dedf9da58f71b0242;hpb=87c10e8d7f05dbbdf12ee9e8651dcec07e08af3f diff --git a/src/auth/cellconfig.c b/src/auth/cellconfig.c index e6d1b8b..81f78dd 100644 --- a/src/auth/cellconfig.c +++ b/src/auth/cellconfig.c @@ -1,7 +1,12 @@ /* - * (C) COPYRIGHT IBM CORPORATION 1987 - * LICENSED MATERIALS - PROPERTY OF IBM + * 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 */ + #include #include #include @@ -35,6 +40,9 @@ static ParseHostLine(); static ParseCellLine(); +static afsconf_OpenInternal(); +static afsconf_CloseInternal(); +static afsconf_Reopen(); static struct afsconf_servPair serviceTable [] = { "afs", 7000, @@ -47,6 +55,8 @@ static struct afsconf_servPair serviceTable [] = { "afsnanny", 7007, "afsupdate",7008, "afsrmtsys",7009, + "afsres", 7010, /* residency database for MR-AFS */ + "afsremio", 7011, /* remote I/O interface for MR-AFS */ 0, 0 /* insert new services before this spot */ }; @@ -190,7 +200,7 @@ register struct afsconf_dir *adir; { #ifdef AFS_NT40_ENV return _utime(tbuffer, NULL); #else - gettimeofday(&tvp[0], (char *) 0); + gettimeofday(&tvp[0], NULL); tvp[1] = tvp[0]; return utimes(tbuffer, tvp); #endif /* AFS_NT40_ENV */ @@ -208,7 +218,7 @@ register char *adir; { tdir->name = (char *) malloc(strlen(adir)+1); strcpy(tdir->name, adir); - code = afsconf_OpenInternal(tdir); + code = afsconf_OpenInternal(tdir, 0, 0); if (code) { char *afsconf_path, *getenv(), afs_confdir[128]; @@ -262,7 +272,7 @@ register char *adir; { } tdir->name = (char *) malloc(strlen(afsconf_path)+1); strcpy(tdir->name, afsconf_path); - code = afsconf_OpenInternal(tdir); + code = afsconf_OpenInternal(tdir, 0, 0); if (code) { free(tdir->name); free(tdir); @@ -312,8 +322,11 @@ static int GetCellNT(struct afsconf_dir *adir) #endif /* AFS_NT40_ENV */ -static int afsconf_OpenInternal(adir) -register struct afsconf_dir *adir; { +static int afsconf_OpenInternal(adir, cell, clones) +register struct afsconf_dir *adir; +char *cell; +char clones[]; +{ FILE *tf; register char *tp, *bp; register struct afsconf_entry *curEntry; @@ -399,7 +412,10 @@ register struct afsconf_dir *adir; { return -1; } i = curEntry->cellInfo.numServers; - code = ParseHostLine(tbuffer, (char *) &curEntry->cellInfo.hostAddr[i], curEntry->cellInfo.hostName[i]); + if (cell && !strcmp(cell, curEntry->cellInfo.name)) + code = ParseHostLine(tbuffer, (char *) &curEntry->cellInfo.hostAddr[i], curEntry->cellInfo.hostName[i], &clones[i]); + else + code = ParseHostLine(tbuffer, (char *) &curEntry->cellInfo.hostAddr[i], curEntry->cellInfo.hostName[i], 0); if (code) { if (code == AFSCONF_SYNTAX) { for (bp=tbuffer; *bp != '\n'; bp++) { /* Take out the from the buffer */ @@ -432,17 +448,26 @@ register struct afsconf_dir *adir; { } /* parse a line of the form - *"128.2.1.3 #hostname" + *"128.2.1.3 #hostname" or + *"[128.2.1.3] #hostname" for clones * into the appropriate pieces. */ -static ParseHostLine(aline, addr, aname) -register struct sockaddr_in *addr; -char *aline, *aname; { +static ParseHostLine(aline, addr, aname, aclone) + char *aclone; + register struct sockaddr_in *addr; + char *aline, *aname; +{ int c1, c2, c3, c4; register afs_int32 code; register char *tp; - code = sscanf(aline, "%d.%d.%d.%d #%s", &c1, &c2, &c3, &c4, aname); + if (*aline == '[') { + if (aclone) *aclone = 1; + code = sscanf(aline, "[%d.%d.%d.%d] #%s", &c1, &c2, &c3, &c4, aname); + } else { + if (aclone) *aclone = 0; + code = sscanf(aline, "%d.%d.%d.%d #%s", &c1, &c2, &c3, &c4, aname); + } if (code != 5) return AFSCONF_SYNTAX; addr->sin_family = AF_INET; addr->sin_port = 0; @@ -491,6 +516,30 @@ char *arock; { } afs_int32 afsconf_SawCell = 0; + +afsconf_GetExtendedCellInfo(adir, acellName, aservice, acellInfo, clones) + struct afsconf_dir *adir; + char *aservice; + char *acellName; + struct afsconf_cell *acellInfo; + char clones[]; +{ + afs_int32 code; + char *cell; + + code = afsconf_GetCellInfo(adir, acellName, aservice, acellInfo); + if (code) + return code; + + if (acellName) + cell = acellName; + else + cell = (char *) &acellInfo->name; + + code = afsconf_OpenInternal(adir, cell, clones); + return code; +} + afsconf_GetCellInfo(adir, acellName, aservice, acellInfo) struct afsconf_dir *adir; char *aservice; @@ -510,8 +559,8 @@ struct afsconf_cell *acellInfo; { tcell = acellName; cnLen = strlen(tcell)+1; lcstring (tcell, tcell, cnLen); - afsconf_SawCell = 1; /* will ignore the AFSCELL switch on future */ - /* call to afsconf_GetLocalCell: like klog */ + afsconf_SawCell = 1; /* will ignore the AFSCELL switch on future */ + /* call to afsconf_GetLocalCell: like klog */ } else { i = afsconf_GetLocalCell(adir, tbuffer, sizeof(tbuffer)); if (i) { @@ -633,7 +682,7 @@ register struct afsconf_dir *adir; { register afs_int32 code; code = afsconf_CloseInternal(adir); if (code) return code; - code = afsconf_OpenInternal(adir); + code = afsconf_OpenInternal(adir, 0, 0); return code; }