--- NEWS 2001/10/13 05:27:19 1.9 +++ NEWS 2001/10/19 07:33:05 @@ -1,4 +1,10 @@ -OpenAFS News -- history of user-visible changes. October 13, 2001 +OpenAFS News -- history of user-visible changes. October 19, 2001 + +* Changes incorporated in OpenAFS 1.2.3 + +** Cell aliases for dynroot can be specified in the CellAlias file in + /usr/vice/etc or /usr/local/etc/openafs, in format "realname alias", + one per line. * Changes incorporated in OpenAFS 1.2.2 --- src/afs/afs.h 2001/10/10 00:10:32 1.12 +++ src/afs/afs.h 2001/10/19 07:33:06 @@ -202,7 +203,7 @@ short states; /* state flags */ short cellIndex; /* relative index number per cell */ time_t timeout; /* data expire time, if non-zero */ - struct cell *alias; /* what this cell is an alias for */ + char *realName; /* who this cell is an alias for */ }; #define afs_PutCell(cellp, locktype) --- src/afs/afs_call.c 2001/10/10 00:10:32 1.18 +++ src/afs/afs_call.c 2001/10/19 07:33:06 @@ -326,6 +326,33 @@ osi_FreeSmallSpace(tbuffer); osi_FreeSmallSpace(tbuffer1); } + else if (parm == AFSOP_ADDCELLALIAS) { + /* + * Call arguments: + * parm2 is the alias name + * parm3 is the real cell name + */ +#if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV) + size_t bufferSize; +#else /* AFS_SGI61_ENV */ + u_int bufferSize; +#endif /* AFS_SGI61_ENV */ + char *aliasName = osi_AllocSmallSpace(AFS_SMALLOCSIZ); + char *cellName = osi_AllocSmallSpace(AFS_SMALLOCSIZ); + + AFS_COPYINSTR((char *)parm2, aliasName, AFS_SMALLOCSIZ, &bufferSize, code); + if (!code) AFS_COPYINSTR((char *)parm3, cellName, AFS_SMALLOCSIZ, &bufferSize, code); + if (!code) afs_NewCell(aliasName, /* new entry name */ + 0, /* host list */ + CAlias, /* flags */ + (char *) 0, /* linked cell */ + 0, 0, /* fs & vl ports */ + 0, /* timeout */ + cellName); /* real cell name */ + + osi_FreeSmallSpace(aliasName); + osi_FreeSmallSpace(cellName); + } else if (parm == AFSOP_CACHEINIT) { struct afs_cacheParams cparms; --- src/afs/afs_cell.c 2001/10/10 19:32:21 1.10 +++ src/afs/afs_cell.c 2001/10/19 07:33:06 @@ -287,8 +287,10 @@ { register struct cell *tc; register struct afs_q *cq, *tq; + int didAlias = 0; AFS_STATCNT(afs_GetCellByName); +retry: ObtainWriteLock(&afs_xcell,100); for (cq = CellLRU.next; cq != &CellLRU; cq = tq) { tc = QTOC(cq); tq = QNext(cq); @@ -297,9 +299,11 @@ QAdd(&CellLRU, &tc->lruq); ReleaseWriteLock(&afs_xcell); afs_RefreshCell(tc); - if (tc->states & CAlias) { - tc = tc->alias; - afs_RefreshCell(tc); + if ((tc->states & CAlias) && (didAlias == 0)) { + acellName = tc->realName; + if (!acellName) return (struct cell *) 0; + didAlias = 1; + goto retry; } return tc; } @@ -346,9 +350,10 @@ } /*afs_GetCell*/ -struct cell *afs_GetCellByIndex(cellindex, locktype) +struct cell *afs_GetCellByIndex(cellindex, locktype, refresh) register afs_int32 cellindex; afs_int32 locktype; + afs_int32 refresh; { register struct cell *tc; register struct afs_q *cq, *tq; @@ -361,7 +366,7 @@ QRemove(&tc->lruq); QAdd(&CellLRU, &tc->lruq); ReleaseWriteLock(&afs_xcell); - afs_RefreshCell(tc); + if (refresh) afs_RefreshCell(tc); return tc; } } @@ -419,6 +424,7 @@ } else { tc = (struct cell *) afs_osi_Alloc(sizeof(struct cell)); + memset((char *)tc, 0, sizeof(*tc)); QAdd(&CellLRU, &tc->lruq); /* put in lruq */ tc->cellName = (char *) afs_osi_Alloc(strlen(acellName)+1); strcpy(tc->cellName, acellName); @@ -464,25 +470,19 @@ } tc->states |= aflags; tc->timeout = timeout; + + /* Allow converting an alias into a real cell */ + if (!(aflags & CAlias)) tc->states &= ~CAlias; memset((char *)tc->cellHosts, 0, sizeof(tc->cellHosts)); if (aflags & CAlias) { - struct cell *tca = NULL; - if (!aliasFor) { code = EINVAL; goto bad; - } - for (cq = CellLRU.next; cq != &CellLRU; cq = tq) { - tca = QTOC(cq); tq = QNext(cq); - if (!afs_strcasecmp(tca->cellName, aliasFor)) - break; - } - if (!tca) { - code = ENOENT; - goto bad; } - tc->alias = tca; + if (tc->realName) afs_osi_Free(tc->realName, strlen(tc->realName)+1); + tc->realName = (char *) afs_osi_Alloc(strlen(aliasFor)+1); + strcpy(tc->realName, aliasFor); goto done; } --- src/afs/afs_dynroot.c 2001/10/10 00:10:32 1.1 +++ src/afs/afs_dynroot.c 2001/10/19 07:33:06 @@ -201,7 +203,7 @@ for (cellidx = 0; cellidx < maxcellidx; cellidx++) { int sizeOfCurEntry; - c = afs_GetCellByIndex(cellidx, READ_LOCK); + c = afs_GetCellByIndex(cellidx, READ_LOCK, 0 /* don't refresh */); if (!c) continue; sizeOfCurEntry = afs_dir_NameBlobs(c->cellName); @@ -254,7 +256,7 @@ linkCount += 2; for (cellidx = 0; cellidx < maxcellidx; cellidx++) { - c = afs_GetCellByIndex(cellidx, READ_LOCK); + c = afs_GetCellByIndex(cellidx, READ_LOCK, 0 /* don't refresh */); afs_dynroot_addDirEnt(dirHeader, &curPage, &curChunk, c->cellName, CIDXRW2VNUM(cellidx, 0)); @@ -379,7 +381,7 @@ cellidx = VNUM2CIDX(avc->fid.Fid.Vnode); rw = VNUM2RW(avc->fid.Fid.Vnode); - c = afs_GetCellByIndex(cellidx, READ_LOCK); + c = afs_GetCellByIndex(cellidx, READ_LOCK, 1 /* refresh */); if (!c) { afs_warn("dynroot vnode inconsistency, can't find cell %d\n", cellidx); @@ -393,20 +395,20 @@ * linkData needs to contain the name of the cell * we're aliasing for. */ - struct cell *tca = c->alias; + char *realName = c->realName; - if (!tca) { - afs_warn("dynroot: alias %s missing cell alias pointer\n", + if (!realName) { + afs_warn("dynroot: alias %s missing real cell name\n", c->cellName); linklen = 7; avc->linkData = afs_osi_Alloc(linklen + 1); strcpy(avc->linkData, "unknown"); } else { - int namelen = strlen(tca->cellName); + int namelen = strlen(realName); linklen = rw + namelen; avc->linkData = afs_osi_Alloc(linklen + 1); strcpy(avc->linkData, rw ? "." : ""); - strcat(avc->linkData, tca->cellName); + strcat(avc->linkData, realName); } status->UnixModeBits = 0755; --- src/afs/afs_osi_vget.c 2001/08/08 00:03:28 1.5 +++ src/afs/afs_osi_vget.c 2001/10/19 07:33:06 @@ -55,7 +55,7 @@ */ struct cell *tcell; cellindex = (Sfid.CellAndUnique >> 24) & 0xff; - tcell = afs_GetCellByIndex(cellindex, READ_LOCK); + tcell = afs_GetCellByIndex(cellindex, READ_LOCK, 0 /* don't refresh */); if (!tcell) { return ENOENT; } --- src/afs/afs_pioctl.c 2001/10/10 00:05:27 1.24 +++ src/afs/afs_pioctl.c 2001/10/19 07:33:07 @@ -66,6 +66,7 @@ static int PGetInitParams(), PFlushMount(), PRxStatProc(), PRxStatPeer(); static int PGetRxkcrypt(), PSetRxkcrypt(); static int PPrefetchFromTape(), PResidencyCmd(); +static int PNewAlias(), PListAliases(); int PExportAfs(); static int HandleClientContext(struct afs_ioctl *ablob, int *com, struct AFS_UCRED **acred, struct AFS_UCRED *credp); @@ -141,6 +142,9 @@ PNoop, /* 65 -- arla: break callback */ PPrefetchFromTape, /* 66 -- MR-AFS: prefetch file from tape */ PResidencyCmd, /* 67 -- MR-AFS: generic commnd interface */ + PNoop, /* 68 -- arla: fetch stats */ + PListAliases, /* 69 -- list cell aliases */ + PNewAlias, /* 70 -- create new cell alias */ }; #define PSetClientContext 99 /* Special pioctl to setup caller's creds */ @@ -2299,6 +2303,53 @@ return code; } +static PNewAlias(avc, afun, areq, ain, aout, ainSize, aoutSize, acred) + struct vcache *avc; + int afun; + struct vrequest *areq; + register char *ain; + char *aout; + afs_int32 ainSize; + struct AFS_UCRED *acred; + afs_int32 *aoutSize; /* set this */ +{ + /* create a new cell alias */ + register struct cell *tcell; + char *tp = ain; + register afs_int32 code; + char *realName, *aliasName; + register struct afs_q *cq, *tq; + + if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */ + return EIO; /* Inappropriate ioctl for device */ + + if (!afs_osi_suser(acred)) + return EACCES; + + aliasName = tp; + tp += strlen(aliasName) + 1; + realName = tp; + + /* + * Prevent user from shooting themselves in the foot -- don't allow + * creation of aliases when a real cell already exists with that name. + */ + ObtainReadLock(&afs_xcell); + for (cq = CellLRU.next; cq != &CellLRU; cq = tq) { + tcell = QTOC(cq); tq = QNext(cq); + if ((afs_strcasecmp(tcell->cellName, aliasName) == 0) && + !(tcell->states & CAlias)) { + ReleaseReadLock(&afs_xcell); + return EEXIST; + } + } + ReleaseReadLock(&afs_xcell); + + code = afs_NewCell(aliasName, 0, CAlias, 0, 0, 0, 0, realName); + *aoutSize = 0; + return code; +} + static PListCells(avc, afun, areq, ain, aout, ainSize, aoutSize) struct vcache *avc; int afun; @@ -2321,8 +2372,12 @@ ObtainReadLock(&afs_xcell); for (cq = CellLRU.next; cq != &CellLRU; cq = tq) { tcell = QTOC(cq); tq = QNext(cq); + if (tcell->states & CAlias) { + tcell = 0; + continue; + } if (whichCell == 0) break; - if (tq == &CellLRU) tcell = 0; + tcell = 0; whichCell--; } if (tcell) { @@ -2336,6 +2391,51 @@ cp = aout + MAXCELLHOSTS * sizeof(afs_int32); strcpy(cp, tcell->cellName); cp += strlen(tcell->cellName)+1; + *aoutSize = cp - aout; + } + ReleaseReadLock(&afs_xcell); + if (tcell) return 0; + else return EDOM; +} + +static PListAliases(avc, afun, areq, ain, aout, ainSize, aoutSize) + struct vcache *avc; + int afun; + struct vrequest *areq; + char *ain, *aout; + afs_int32 ainSize; + afs_int32 *aoutSize; /* set this */ +{ + afs_int32 whichAlias; + register struct cell *tcell=0; + register char *cp, *tp = ain; + register struct afs_q *cq, *tq; + + if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */ + return EIO; /* Inappropriate ioctl for device */ + if (ainSize < sizeof(afs_int32)) + return EINVAL; + + memcpy((char *)&whichAlias, tp, sizeof(afs_int32)); + tp += sizeof(afs_int32); + + ObtainReadLock(&afs_xcell); + for (cq = CellLRU.next; cq != &CellLRU; cq = tq) { + tcell = QTOC(cq); tq = QNext(cq); + if (!(tcell->states & CAlias)) { + tcell = 0; + continue; + } + if (whichAlias == 0) break; + tcell = 0; + whichAlias--; + } + if (tcell) { + cp = aout; + strcpy(cp, tcell->cellName); + cp += strlen(tcell->cellName)+1; + strcpy(cp, tcell->realName); + cp += strlen(tcell->realName)+1; *aoutSize = cp - aout; } ReleaseReadLock(&afs_xcell); --- src/afs/IRIX/osi_vfsops.c 2001/07/12 19:58:20 1.4 +++ src/afs/IRIX/osi_vfsops.c 2001/10/19 07:33:07 @@ -537,7 +537,7 @@ afid2 = (afs_fid2_t*)fidp; if (afid2->af_len == sizeof(afs_fid2_t) - sizeof(afid2->af_len)) { /* It's a checkpoint restart fid. */ - tcell = afs_GetCellByIndex(afid2->af_cell, READ_LOCK); + tcell = afs_GetCellByIndex(afid2->af_cell, READ_LOCK, 0 /* !refresh */); if (!tcell) { code = ENOENT; goto out; --- src/afsd/afsd.c 2001/10/10 00:10:40 1.19 +++ src/afsd/afsd.c 2001/10/19 07:33:07 @@ -1058,6 +1058,16 @@ return 0; } +static ConfigCellAlias(aca, arock, adir) + register struct afsconf_cellalias *aca; + char *arock; + struct afsconf_dir *adir; +{ + /* push the alias into the kernel */ + call_syscall(AFSOP_ADDCELLALIAS, aca->aliasName, aca->realName); + return 0; +} + #ifdef AFS_AFSDB_ENV static AfsdbLookupHandler() { @@ -1612,6 +1622,7 @@ lookingForHomeCell = 1; afsconf_CellApply(cdir, ConfigCell, (char *) 0); + afsconf_CellAliasApply(cdir, ConfigCellAlias, (char *) 0); /* * If we're still looking for the home cell after the whole cell configuration database --- src/auth/cellconfig.c 2001/10/10 00:05:30 1.20 +++ src/auth/cellconfig.c 2001/10/19 07:33:07 @@ -357,6 +357,7 @@ FILE *tf; register char *tp, *bp; register struct afsconf_entry *curEntry; + struct afsconf_aliasentry *curAlias; register afs_int32 code; afs_int32 i; char tbuffer[256], tbuf1[256]; @@ -469,7 +470,44 @@ curEntry->next = adir->entries; adir->entries = curEntry; } - + + /* Read in the alias list */ + strcompose(tbuffer, 256, adir->name, "/", AFSDIR_CELLALIAS_FILE, NULL); + + tf = fopen(tbuffer, "r"); + while (tf) { + char *aliasPtr; + + tp = fgets(tbuffer, sizeof(tbuffer), tf); + if (!tp) break; + TrimLine(tbuffer); /* remove white space */ + + if (tbuffer[0] == '\0' || + tbuffer[0] == '\n' || + tbuffer[0] == '#') continue; /* empty line */ + + tp = tbuffer; + while (tp[0] != '\0' && tp[0] != ' ' && tp[0] != '\t') tp++; + if (tp[0] == '\0') continue; /* invalid line */ + + while (tp[0] != '\0' && (tp[0] == ' ' || tp[0] == '\t')) 0[tp++] = '\0'; + if (tp[0] == '\0') continue; /* invalid line */ + + aliasPtr = tp; + while (tp[0] != '\0' && tp[0] != ' ' && tp[0] != '\t' && + tp[0] != '\r' && tp[0] != '\n') tp++; + tp[0] = '\0'; + + curAlias = malloc(sizeof(*curAlias)); + memset(curAlias, 0, sizeof(*curAlias)); + + strcpy(curAlias->aliasInfo.aliasName, aliasPtr); + strcpy(curAlias->aliasInfo.realName, tbuffer); + + curAlias->next = adir->alias_entries; + adir->alias_entries = curAlias; + } + /* now read the fs keys, if possible */ adir->keystr = (struct afsconf_keys *) 0; afsconf_IntGetKeys(adir); @@ -545,6 +583,28 @@ return 0; } +/* call aproc(entry, arock, adir) for all cell aliases. + * Proc must return 0, or we'll stop early and return the code it returns + */ +afsconf_CellAliasApply(adir, aproc, arock) + struct afsconf_dir *adir; + int (*aproc)(); + char *arock; +{ + register struct afsconf_aliasentry *tde; + register afs_int32 code; + LOCK_GLOBAL_MUTEX + for(tde=adir->alias_entries; tde; tde=tde->next) { + code = (*aproc)(&tde->aliasInfo, arock, adir); + if (code) { + UNLOCK_GLOBAL_MUTEX + return code; + } + } + UNLOCK_GLOBAL_MUTEX + return 0; +} + afs_int32 afsconf_SawCell = 0; afsconf_GetExtendedCellInfo(adir, acellName, aservice, acellInfo, clones) @@ -734,6 +794,7 @@ char *acellName; struct afsconf_cell *acellInfo; { register struct afsconf_entry *tce; + struct afsconf_aliasentry *tcae; struct afsconf_entry *bestce; register afs_int32 i; int tservice; @@ -765,6 +826,15 @@ UNLOCK_GLOBAL_MUTEX return 0; } + + /* Look through the list of aliases */ + for (tcae = adir->alias_entries; tcae; tcae = tcae->next) { + if (strcasecmp(tcae->aliasInfo.aliasName, tcell) == 0) { + tcell = tcae->aliasInfo.realName; + break; + } + } + for(tce=adir->entries;tce;tce=tce->next) { if (strcasecmp(tce->cellInfo.name, tcell) == 0) { /* found our cell */ @@ -797,7 +867,7 @@ else { UNLOCK_GLOBAL_MUTEX #ifdef AFS_AFSDB_ENV - return afsconf_GetAfsdbInfo(acellName, aservice, acellInfo); + return afsconf_GetAfsdbInfo(tcell, aservice, acellInfo); #else return AFSCONF_NOTFOUND; #endif /* AFS_AFSDB_ENV */ --- src/auth/cellconfig.p.h 2001/07/05 15:39:03 1.5 +++ src/auth/cellconfig.p.h 2001/10/19 07:33:07 @@ -69,17 +69,28 @@ int timeout; /* Data timeout, if non-zero */ }; +struct afsconf_cellalias { + char aliasName[MAXCELLCHARS]; + char realName[MAXCELLCHARS]; +}; + struct afsconf_entry { struct afsconf_entry *next; /* next guy in afsconf_dir */ struct afsconf_cell cellInfo; /* info for this cell */ }; +struct afsconf_aliasentry { + struct afsconf_aliasentry *next; + struct afsconf_cellalias aliasInfo; +}; + struct afsconf_dir { char *name; /* pointer to dir prefix */ char *cellName; /* cell name, if any, we're in */ struct afsconf_entry *entries; /* list of cell entries */ struct afsconf_keys *keystr; /* structure containing keys */ afs_int32 timeRead; /* time stamp of file last read */ + struct afsconf_aliasentry *alias_entries; /* cell aliases */ }; extern struct afsconf_dir *afsconf_Open(); --- src/config/afs_args.h 2001/10/10 00:10:43 1.5 +++ src/config/afs_args.h 2001/10/19 07:33:08 @@ -40,6 +40,7 @@ #define AFSOP_ADDCELL2 29 /* 2nd add cell protocol interface */ #define AFSOP_AFSDB_HANDLER 30 /* userspace AFSDB lookup handler */ #define AFSOP_SET_DYNROOT 31 /* enable/disable dynroot support */ +#define AFSOP_ADDCELLALIAS 32 /* create alias for existing cell */ /* The range 20-30 is reserved for AFS system offsets in the afs_syscall */ #define AFSCALL_PIOCTL 20 --- src/config/venus.h 2001/07/10 17:31:07 1.6 +++ src/config/venus.h 2001/10/19 07:33:08 @@ -177,4 +177,6 @@ #define VIOC_PREFETCHTAPE _VICEIOCTL(66) /* MR-AFS prefetch from tape */ #define VIOC_RESIDENCY_CMD _VICEIOCTL(67) /* generic MR-AFS cmds */ #define VIOC_STATISTICS _VICEIOCTL(68) /* arla: fetch statistics */ +#define VIOC_GETALIAS _VICEIOCTL(69) /* get alias info */ +#define VIOC_NEWALIAS _VICEIOCTL(70) /* create new cell alias */ #endif /* AFS_VENUS_H */ --- src/util/dirpath.c 2001/09/20 20:10:09 1.11 +++ src/util/dirpath.c 2001/10/19 07:33:08 @@ -357,12 +357,17 @@ "/NoUsrViceEtcThisCellFileOnWindows"); sprintf(dirPathArray[AFSDIR_CLIENT_CELLSERVDB_FILEPATH_ID], "%s/%s", ntClientConfigDirShort, AFSDIR_CELLSERVDB_FILE_NTCLIENT); + strcpy(dirPathArray[AFSDIR_CLIENT_CELLALIAS_FILEPATH_ID], + "/NoCellAliasOnWindows"); #else pathp = dirPathArray[AFSDIR_CLIENT_THISCELL_FILEPATH_ID]; AFSDIR_CLIENT_FILEPATH(pathp, AFSDIR_CLIENT_ETC_DIR, AFSDIR_THISCELL_FILE); pathp = dirPathArray[AFSDIR_CLIENT_CELLSERVDB_FILEPATH_ID]; AFSDIR_CLIENT_FILEPATH(pathp, AFSDIR_CLIENT_ETC_DIR, AFSDIR_CELLSERVDB_FILE); + + pathp = dirPathArray[AFSDIR_CLIENT_CELLALIAS_FILEPATH_ID]; + AFSDIR_CLIENT_FILEPATH(pathp, AFSDIR_CLIENT_ETC_DIR, AFSDIR_CELLALIAS_FILE); #endif /* AFS_NT40_ENV */ pathp = dirPathArray[AFSDIR_CLIENT_NETINFO_FILEPATH_ID]; --- src/util/dirpath.hin 2001/09/20 20:10:09 1.3 +++ src/util/dirpath.hin 2001/10/19 07:33:08 @@ -118,6 +118,7 @@ /* file names */ #define AFSDIR_THISCELL_FILE "ThisCell" #define AFSDIR_CELLSERVDB_FILE "CellServDB" +#define AFSDIR_CELLALIAS_FILE "CellAlias" #define AFSDIR_KEY_FILE "KeyFile" #define AFSDIR_ULIST_FILE "UserList" #define AFSDIR_NOAUTH_FILE "NoAuth" @@ -260,6 +261,7 @@ AFSDIR_SERVER_MIGRATE_DIRPATH_ID, AFSDIR_SERVER_MIGRATELOG_FILEPATH_ID, AFSDIR_SERVER_BIN_FILE_DIRPATH_ID, + AFSDIR_CLIENT_CELLALIAS_FILEPATH_ID, AFSDIR_PATHSTRING_MAX } afsdir_id_t; /* getDirPath() returns a pointer to a string from an internal array of path strings @@ -331,6 +333,7 @@ /* 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_CELLALIAS_FILEPATH getDirPath(AFSDIR_CLIENT_CELLALIAS_FILEPATH_ID) #define AFSDIR_CLIENT_NETINFO_FILEPATH getDirPath(AFSDIR_CLIENT_NETINFO_FILEPATH_ID) #define AFSDIR_CLIENT_NETRESTRICT_FILEPATH getDirPath(AFSDIR_CLIENT_NETRESTRICT_FILEPATH_ID) --- src/venus/fs.c 2001/08/08 00:04:18 1.12 +++ src/venus/fs.c 2001/10/19 07:33:09 @@ -1863,6 +1863,35 @@ return 0; } +static ListAliasesCmd(as) + struct cmd_syndesc *as; +{ + afs_int32 code, i; + char *tp, *aliasName, *realName; + struct ViceIoctl blob; + + for(i=0;;i++) { + tp = space; + memcpy(tp, &i, sizeof(afs_int32)); + blob.out_size = MAXSIZE; + blob.in_size = sizeof(afs_int32); + blob.in = space; + blob.out = space; + code = pioctl(0, VIOC_GETALIAS, &blob, 1); + if (code < 0) { + if (errno == EDOM) break; /* done with the list */ + Die(errno, 0); + return 1; + } + tp = space; + aliasName = tp; + tp += strlen(aliasName) + 1; + realName = tp; + printf("Alias %s for cell %s\n", aliasName, realName); + } + return 0; +} + static NewCellCmd(as) struct cmd_syndesc *as; { @@ -1964,6 +1993,40 @@ return 0; } +static NewAliasCmd(as) + struct cmd_syndesc *as; +{ + afs_int32 code; + struct ViceIoctl blob; + char *tp; + char *aliasName, *realName; + + /* Now setup and do the NEWCELL pioctl call */ + aliasName = as->parms[0].items->data; + realName = as->parms[1].items->data; + tp = space; + strcpy(tp, aliasName); + tp += strlen(aliasName) + 1; + strcpy(tp, realName); + tp += strlen(realName) + 1; + + blob.in_size = tp - space; + blob.in = space; + blob.out_size = 0; + blob.out = space; + code = pioctl(0, VIOC_NEWALIAS, &blob, 1); + if (code < 0) { + if (errno == EEXIST) { + fprintf(stderr, "%s: cell name `%s' in use by an existing cell.\n", + pn, aliasName); + } else { + Die(errno, 0); + } + return 1; + } + return 0; +} + static WhichCellCmd(as) struct cmd_syndesc *as; { @@ -2984,6 +3047,8 @@ ts = cmd_CreateSyntax("listcells", ListCellsCmd, 0, "list configured cells"); cmd_AddParm(ts, "-numeric", CMD_FLAG, CMD_OPTIONAL, "addresses only"); + ts = cmd_CreateSyntax("listaliases", ListAliasesCmd, 0, "list configured cell aliases"); + ts = cmd_CreateSyntax("setquota", SetQuotaCmd, 0, "set volume quota"); cmd_AddParm(ts, "-path", CMD_SINGLE, CMD_OPTIONAL, "dir/file path"); cmd_AddParm(ts, "-max", CMD_SINGLE, 0, "max quota in kbytes"); @@ -2996,6 +3061,10 @@ cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "cell name"); cmd_AddParm(ts, "-servers", CMD_LIST, CMD_REQUIRED, "primary servers"); cmd_AddParm(ts, "-linkedcell", CMD_SINGLE, CMD_OPTIONAL, "linked cell name"); + + ts = cmd_CreateSyntax("newalias", NewAliasCmd, 0, "configure new cell alias"); + cmd_AddParm(ts, "-alias", CMD_SINGLE, 0, "alias name"); + cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "real name of cell"); #ifdef FS_ENABLE_SERVER_DEBUG_PORTS /*