]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
DEVEL15-newuuid-20070612
authorDerrick Brashear <shadow@dementia.org>
Tue, 12 Jun 2007 20:14:07 +0000 (20:14 +0000)
committerDerrick Brashear <shadow@dementia.org>
Tue, 12 Jun 2007 20:14:07 +0000 (20:14 +0000)
add the newuuid command

(cherry picked from commit b1bbe33fdee32a3b3ec87a9d770d8684347f7c4b)

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

index 54dcfcc0f6aa2e1d1533ac5d974008e0a2857d34..39d37d3eedabe8247edc7457a7d20936176c8790 100644 (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
index edd6b2705fedc5c2a72d72221e8680c86422e200..90fbd118e9680ce9b3342640d3887ef86e738944 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 bf14ae30e7cd83960a02da4f53f2f6f71a360119..c940829331a07c324e11b21a36b5fe67e71c17a4 100644 (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 */
index 3e13e2579fe083e92313c57283ad47888e583ebe..1bd0bf4cc3fc8412f739c9ea6b5ccfc425382066 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();
@@ -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();