vos: convertROtoRW misc error reporting problems
[openafs.git] / src / volser / vos.c
index 4559f59..0010a1b 100644 (file)
@@ -1474,7 +1474,9 @@ static void
 VolumeStats_int(volintInfo *pntr, struct nvldbentry *entry, afs_uint32 server,
             afs_int32 part, int voltype)
 {
-    int totalOK, totalNotOK, totalBusy;
+    int totalOK = 0;
+    int totalNotOK = 0;
+    int totalBusy = 0;
 
     DisplayFormat(pntr, server, part, &totalOK, &totalNotOK, &totalBusy, 0, 1,
                  1);
@@ -1881,7 +1883,7 @@ volOffline(struct cmd_syndesc *as, void *arock)
 
     transflag = (as->parms[4].items ? ITBusy : ITOffline);
     sleeptime = (as->parms[3].items ? atol(as->parms[3].items->data) : 0);
-    transdone = (sleeptime ? 0 /*online */ : VTOutOfService);
+    transdone = ((sleeptime || as->parms[4].items) ? 0 /*online */ : VTOutOfService);
     if (as->parms[4].items && !as->parms[3].items) {
        fprintf(STDERR, "-sleep option must be used with -busy flag\n");
        return -1;
@@ -2733,7 +2735,12 @@ CloneVolume(struct cmd_syndesc *as, void *arock)
 
     flags = 0;
     if (as->parms[5].items) flags |= RV_OFFLINE;
+    if (as->parms[6].items && as->parms[7].items) {
+       fprintf(STDERR, "vos: cannot specify that a volume be -readwrite and -readonly\n");
+       return EINVAL;
+    }
     if (as->parms[6].items) flags |= RV_RDONLY;
+    if (as->parms[7].items) flags |= RV_RWONLY;
 
 
     code =
@@ -2832,9 +2839,12 @@ ReleaseVolume(struct cmd_syndesc *as, void *arock)
     afs_uint32 aserver;
     afs_int32 apart, vtype, code, err;
     int force = 0;
+    int stayUp = 0;
 
     if (as->parms[1].items)
        force = 1;
+    if (as->parms[2].items)
+       stayUp = 1;
     avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
     if (avolid == 0) {
        if (err)
@@ -2860,7 +2870,8 @@ ReleaseVolume(struct cmd_syndesc *as, void *arock)
        return E2BIG;
     }
 
-    code = UV_ReleaseVolume(avolid, aserver, apart, force);
+    code = UV_ReleaseVolume(avolid, aserver, apart, force, stayUp);
+
     if (code) {
        PrintDiagnostics("release", code);
        return code;
@@ -2885,8 +2896,8 @@ DumpVolumeCmd(struct cmd_syndesc *as, void *arock)
        if (rxConn == 0)
            break;
        rx_SetConnDeadTime(rxConn, rx_connDeadTime);
-       if (rxConn->service)
-           rxConn->service->connDeadTime = rx_connDeadTime;
+       if (rx_ServiceOf(rxConn))
+           rx_ServiceOf(rxConn)->connDeadTime = rx_connDeadTime;
     }
 
     avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
@@ -3449,7 +3460,7 @@ ChangeLocation(struct cmd_syndesc *as, void *arock)
     }
     code = UV_ChangeLocation(aserver, apart, avolid);
     if (code) {
-       PrintDiagnostics("addsite", code);
+       PrintDiagnostics("changeloc", code);
        exit(1);
     }
     MapPartIdIntoName(apart, apartName);
@@ -5439,13 +5450,13 @@ SetAddrs(struct cmd_syndesc *as, void *arock)
     if (vcode) {
        if (vcode == VL_MULTIPADDR) {
            fprintf(STDERR, "vos: VL_RegisterAddrs rpc failed; The IP address exists on a different server; repair it\n");
-           PrintError("", vcode);
-           return vcode;
        } else if (vcode == RXGEN_OPCODE) {
            fprintf(STDERR, "vlserver doesn't support VL_RegisterAddrs rpc; ignored\n");
-           PrintError("", vcode);
-           return vcode;
+       } else {
+           fprintf(STDERR, "vos: VL_RegisterAddrs rpc failed\n");
        }
+       PrintError("", vcode);
+       return vcode;
     }
     if (verbose) {
        fprintf(STDOUT, "vos: Changed UUID with addresses:\n");
@@ -5527,7 +5538,7 @@ ConvertRO(struct cmd_syndesc *as, void *arock)
            PrintError("", code);
        else
            fprintf(STDERR, "Unknown volume ID or name '%s'\n",
-                   as->parms[0].items->data);
+                   as->parms[2].items->data);
        return -1;
     }
     if (as->parms[3].items)
@@ -5538,7 +5549,7 @@ ConvertRO(struct cmd_syndesc *as, void *arock)
        fprintf(STDERR,
                "Could not fetch the entry for volume %lu from VLDB\n",
                (unsigned long)volid);
-       PrintError("convertROtoRW", code);
+       PrintError("convertROtoRW ", vcode);
        return vcode;
     }
 
@@ -5662,8 +5673,8 @@ Sizes(struct cmd_syndesc *as, void *arock)
        if (rxConn == 0)
            break;
        rx_SetConnDeadTime(rxConn, rx_connDeadTime);
-       if (rxConn->service)
-           rxConn->service->connDeadTime = rx_connDeadTime;
+       if (rx_ServiceOf(rxConn))
+           rx_ServiceOf(rxConn)->connDeadTime = rx_connDeadTime;
     }
 
     avolid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
@@ -5806,31 +5817,37 @@ MyBeforeProc(struct cmd_syndesc *as, void *arock)
 {
     char *tcell;
     afs_int32 code;
-    afs_int32 sauth;
+    int secFlags;
 
     /* Initialize the ubik_client connection */
     rx_SetRxDeadTime(90);
-    cstruct = (struct ubik_client *)0;
+    cstruct = NULL;
+    secFlags = AFSCONF_SECOPTS_FALLBACK_NULL;
 
-    sauth = 0;
     tcell = NULL;
     if (as->parms[12].items)   /* if -cell specified */
        tcell = as->parms[12].items->data;
-    if (as->parms[14].items)   /* -serverauth specified */
-       sauth = 1;
+
+    if (as->parms[13].items)
+       secFlags |= AFSCONF_SECOPTS_NOAUTH;
+
+    if (as->parms[14].items) { /* -localauth specified */
+       secFlags |= AFSCONF_SECOPTS_LOCALAUTH;
+       confdir = AFSDIR_SERVER_ETC_DIRPATH;
+    }
+
     if (as->parms[16].items     /* -encrypt specified */
 #ifdef AFS_NT40_ENV
         || win32_enableCrypt()
 #endif /* AFS_NT40_ENV */
          )
-       vsu_SetCrypt(1);
+       secFlags |= AFSCONF_SECOPTS_ALWAYSENCRYPT;
 
     if (as->parms[18].items)   /* -config flag set */
        confdir = as->parms[18].items->data;
 
-    if ((code =
-        vsu_ClientInit((as->parms[13].items != 0), confdir, tcell, sauth,
-                       &cstruct, UV_SetSecurity))) {
+    if ((code = vsu_ClientInit(confdir, tcell, secFlags, UV_SetSecurity,
+                              &cstruct))) {
        fprintf(STDERR, "could not initialize VLDB library (code=%lu) \n",
                (unsigned long)code);
        exit(1);
@@ -5977,12 +5994,16 @@ main(int argc, char **argv)
                "leave clone volume offline");
     cmd_AddParm(ts, "-readonly", CMD_FLAG, CMD_OPTIONAL,
                "make clone volume read-only, not readwrite");
+    cmd_AddParm(ts, "-readwrite", CMD_FLAG, CMD_OPTIONAL,
+               "make clone volume readwrite, not read-only");
     COMMONPARMS;
 
     ts = cmd_CreateSyntax("release", ReleaseVolume, NULL, "release a volume");
     cmd_AddParm(ts, "-id", CMD_SINGLE, 0, "volume name or ID");
     cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
                "force a complete release");
+    cmd_AddParm(ts, "-stayonline", CMD_FLAG, CMD_OPTIONAL,
+               "release to cloned temp vol, then clone back to repsite RO");
     COMMONPARMS;
 
     ts = cmd_CreateSyntax("dump", DumpVolumeCmd, NULL, "dump a volume");