]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE14-newuuid-20070612
authorDerrick Brashear <shadow@dementia.org>
Tue, 12 Jun 2007 20:20:10 +0000 (20:20 +0000)
committerDerrick Brashear <shadow@dementia.org>
Tue, 12 Jun 2007 20:20:10 +0000 (20:20 +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 848f4c136d611d1056a07d8b4a5956ced087977c..ed1b2844afe1750ba7c36af890cc509f63be444e 100644 (file)
@@ -90,7 +90,7 @@ DECL_PIOCTL(PRxStatPeer);
 DECL_PIOCTL(PPrefetchFromTape);
 DECL_PIOCTL(PResidencyCmd);
 DECL_PIOCTL(PCallBackAddr);
-
+DECL_PIOCTL(PNewUuid);
 /*
  * A macro that says whether we're going to need HandleClientContext().
  * This is currently used only by the nfs translator.
@@ -192,6 +192,12 @@ static int (*(CpioctlSw[])) () = {
        PNewAlias,              /* 1 -- create new cell alias */
        PListAliases,           /* 2 -- list cell aliases */
        PCallBackAddr,          /* 3 -- request addr for callback rxcon */
+    PBogus,                    /* 0 */
+    PBogus,                    /* 0 */
+    PBogus,                    /* 0 */
+    PBogus,                    /* 0 */
+    PBogus,                    /* 0 */
+    PNewUuid,                   /* 9 -- generate new uuid */
 };
 
 #define PSetClientContext 99   /*  Special pioctl to setup caller's creds  */
@@ -3830,6 +3836,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 3ae16ddfcb34aa16b3a641084e00f0e5d36b875e..9c837b74b0d84419ebbc1f3e4d41b0c0b782e4f3 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 eb5e5b880b2d72e422b4adfbb95f3b768c9fe9ed..055f29958d126c39e6de06a33b0c83461e970eae 100644 (file)
@@ -181,5 +181,6 @@ struct cm_initparams {
 #define VIOC_NEWALIAS          _CVICEIOCTL(1)  /* create new cell alias */
 #define VIOC_GETALIAS          _CVICEIOCTL(2)  /* get alias info */
 #define VIOC_CBADDR            _CVICEIOCTL(3)  /* push callback addr */
+#define VIOC_NEWUUID           _CVICEIOCTL(9)  /* new uuid */
 
 #endif /* AFS_VENUS_H */
index 2967f745051fe40541bfa1bb828bd675148bd83d..cd107c5187585b5c7708a19a060774e308e25071 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)
 {
@@ -3442,6 +3460,9 @@ defect 3069
                          "get fid for file(s)");
     cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
 
+    ts = cmd_CreateSyntax("newuuid", NewUuidCmd, 0,
+                         "force a new uuid");
+
     code = cmd_Dispatch(argc, argv);
     if (rxInitDone)
        rx_Finalize();