DEVEL15-newuuid-20070612

add the newuuid command


(cherry picked from commit b1bbe33fde)
This commit is contained in:
Derrick Brashear 2007-06-12 20:14:07 +00:00
parent 8c37b30cb1
commit 6da9229bb4
4 changed files with 81 additions and 1 deletions

View File

@ -91,6 +91,7 @@ DECL_PIOCTL(PPrefetchFromTape);
DECL_PIOCTL(PResidencyCmd);
DECL_PIOCTL(PCallBackAddr);
DECL_PIOCTL(PNFSNukeCreds);
DECL_PIOCTL(PNewUuid);
/*
* A macro that says whether we're going to need HandleClientContext().
@ -193,6 +194,12 @@ static int (*(CpioctlSw[])) () = {
PNewAlias, /* 1 -- create new cell alias */
PListAliases, /* 2 -- list cell aliases */
PCallBackAddr, /* 3 -- request addr for callback rxcon */
PBogus, /* 4 */
PBogus, /* 5 */
PBogus, /* 6 */
PBogus, /* 7 */
PBogus, /* 8 */
PNewUUID, /* 9 */
};
static int (*(OpioctlSw[])) () = {
@ -3809,6 +3816,21 @@ DECL_PIOCTL(PResidencyCmd)
return code;
}
DECL_PIOCTL(PNewUuid)
{
/*AFS_STATCNT(PNewUuid); */
if (!afs_resourceinit_flag) /* afs deamons havn't started yet */
return EIO; /* Inappropriate ioctl for device */
if (!afs_osi_suser(acred))
return EACCES;
ObtainWriteLock(&afs_xinterface, 555);
afs_uuid_create(&afs_cb_interface.uuid);
ReleaseWriteLock(&afs_xinterface);
ForceAllNewConnections();
}
DECL_PIOCTL(PCallBackAddr)
{
#ifndef UKERNEL

View File

@ -488,6 +488,42 @@ afs_CountServers(void)
} /*afs_CountServers */
void
ForceAllNewConnections()
{
int srvAddrCount;
struct srvAddr **addrs;
struct srvAddr *sa;
afs_int32 i, j;
ObtainReadLock(&afs_xserver); /* Necessary? */
ObtainReadLock(&afs_xsrvAddr);
srvAddrCount = 0;
for (i = 0; i < NSERVERS; i++) {
for (sa = afs_srvAddrs[i]; sa; sa = sa->next_bkt) {
srvAddrCount++;
}
}
addrs = afs_osi_Alloc(srvAddrCount * sizeof(*addrs));
j = 0;
for (i = 0; i < NSERVERS; i++) {
for (sa = afs_srvAddrs[i]; sa; sa = sa->next_bkt) {
if (j >= srvAddrCount)
break;
addrs[j++] = sa;
}
}
ReleaseReadLock(&afs_xsrvAddr);
ReleaseReadLock(&afs_xserver);
for (i = 0; i < j; i++) {
sa = addrs[i];
ForceNewConnections(sa);
}
}
/* check down servers (if adown), or running servers (if !adown) */
void
afs_CheckServers(int adown, struct cell *acellp)

View File

@ -182,6 +182,7 @@ struct cm_initparams {
#define VIOC_GETALIAS _CVICEIOCTL(2) /* get alias info */
#define VIOC_CBADDR _CVICEIOCTL(3) /* push callback addr */
#define VIOC_DISCON _CVICEIOCTL(5) /* set/get discon mode */
#define VIOC_NEWUUID _CVICEIOCTL(9) /* new uuid */
/* OpenAFS-specific 'O' pioctl's */
#define VIOC_NFS_NUKE_CREDS _OVICEIOCTL(1) /* nuke creds for all PAG's */

View File

@ -69,7 +69,7 @@ static char tspace[1024];
static struct ubik_client *uclient;
static int GetClientAddrsCmd(), SetClientAddrsCmd(), FlushMountCmd();
static int RxStatProcCmd(), RxStatPeerCmd(), GetFidCmd();
static int RxStatProcCmd(), RxStatPeerCmd(), GetFidCmd(), NewUuidCmd();
extern char *hostutil_GetNameByINet();
extern struct hostent *hostutil_GetHostByName();
@ -1244,6 +1244,24 @@ FlushVolumeCmd(struct cmd_syndesc *as, char *arock)
return error;
}
static int
NewUuidCmd(struct cmd_syndesc *as, char *arock)
{
afs_int32 code;
struct ViceIoctl blob;
blob.in_size = 0;
blob.out_size = 0;
code = pioctl(0, VIOC_NEWUUID, &blob, 1);
if (code) {
Die(errno, 0);
return 1;
}
printf("New uuid generated.\n");
return 0;
}
static int
FlushCmd(struct cmd_syndesc *as, char *arock)
{
@ -3620,6 +3638,9 @@ defect 3069
ts = cmd_CreateSyntax("nukenfscreds", NukeNFSCredsCmd, 0, "nuke credentials for NFS client");
cmd_AddParm(ts, "-addr", CMD_SINGLE, 0, "host name or address");
ts = cmd_CreateSyntax("newuuid", NewUuidCmd, 0,
"force a new uuid");
code = cmd_Dispatch(argc, argv);
if (rxInitDone)
rx_Finalize();