newuuid-20070612
authorDerrick Brashear <shadow@dementia.org>
Tue, 12 Jun 2007 19:59:02 +0000 (19:59 +0000)
committerDerrick Brashear <shadow@dementia.org>
Tue, 12 Jun 2007 19:59:02 +0000 (19:59 +0000)
add the newuuid command

src/afs/afs_pioctl.c
src/afs/afs_server.c
src/config/vioc.h
src/venus/fs.c

index 133bded..3ddb35a 100644 (file)
@@ -92,6 +92,7 @@ DECL_PIOCTL(PResidencyCmd);
 DECL_PIOCTL(PCallBackAddr);
 DECL_PIOCTL(PDiscon);
 DECL_PIOCTL(PNFSNukeCreds);
+DECL_PIOCTL(PNewUuid);
 
 /*
  * A macro that says whether we're going to need HandleClientContext().
@@ -196,6 +197,10 @@ static int (*(CpioctlSw[])) () = {
        PCallBackAddr,          /* 3 -- request addr for callback rxcon */
        PBogus,                 /* 4 */
        PDiscon,                /* 5 -- get/set discon mode */
+        PBogus,                 /* 6 */
+        PBogus,                 /* 7 */
+        PBogus,                 /* 8 */
+        PNewUUID,               /* 9 */
 };
 
 static int (*(OpioctlSw[])) () = {
@@ -3812,6 +3817,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
index edd6b27..90fbd11 100644 (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)
index 1c930af..a66ec06 100644 (file)
@@ -97,6 +97,7 @@
 #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 */
index 8d9abfd..439bc78 100644 (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();
@@ -1245,6 +1245,24 @@ FlushVolumeCmd(struct cmd_syndesc *as, char *arock)
 }
 
 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)
 {
     afs_int32 code;
@@ -3623,6 +3641,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();