From 026fcc6f975dbc13ac39d3276d28a48a9b56ee7d Mon Sep 17 00:00:00 2001 From: Christof Hanke Date: Thu, 5 Feb 2015 12:07:50 +0100 Subject: [PATCH] bos, pts: emit error messages on stderr as one expects. Change-Id: Icb67a05b61ddcef8def826768491b9a1952862e9 Reviewed-on: http://gerrit.openafs.org/11605 Reviewed-by: Chas Williams - CONTRACTOR Reviewed-by: Benjamin Kaduk Tested-by: BuildBot Reviewed-by: Jeffrey Altman --- src/bozo/bos.c | 178 ++++++++++++++++++++++----------------------- src/ptserver/pts.c | 12 +-- 2 files changed, 95 insertions(+), 95 deletions(-) diff --git a/src/bozo/bos.c b/src/bozo/bos.c index e37ea2fab..9ebdb2f24 100644 --- a/src/bozo/bos.c +++ b/src/bozo/bos.c @@ -99,7 +99,7 @@ GetConn(struct cmd_syndesc *as, int aencrypt) hostname = as->parms[0].items->data; th = hostutil_GetHostByName(hostname); if (!th) { - printf("bos: can't find address for host '%s'\n", hostname); + fprintf(stderr, "bos: can't find address for host '%s'\n", hostname); exit(1); } memcpy(&addr, th->h_addr, sizeof(afs_int32)); @@ -124,7 +124,7 @@ GetConn(struct cmd_syndesc *as, int aencrypt) * directory */ tdir = afsconf_Open(confdir); if (tdir == NULL) { - printf("bos: can't open cell database (%s)\n", confdir); + fprintf(stderr, "bos: can't open cell database (%s)\n", confdir); exit(1); } } @@ -168,8 +168,8 @@ SetAuth(struct cmd_syndesc *as, void *arock) else if (strcmp(tp, "off") == 0) flag = 1; else { - printf - ("bos: illegal authentication specifier '%s', must be 'off' or 'on'.\n", + fprintf + (stderr, "bos: illegal authentication specifier '%s', must be 'off' or 'on'.\n", tp); return 1; } @@ -251,7 +251,7 @@ Exec(struct cmd_syndesc *as, void *arock) tconn = GetConn(as, 0); code = BOZO_Exec(tconn, as->parms[1].items->data); if (code) - printf("bos: failed to execute command (%s)\n", em(code)); + fprintf(stderr, "bos: failed to execute command (%s)\n", em(code)); return code; } @@ -267,7 +267,7 @@ GetDate(struct cmd_syndesc *as, void *arock) tconn = GetConn(as, 0); if (!as->parms[1].items) { - printf("bos: no files to check\n"); + fprintf(stderr, "bos: no files to check\n"); return 1; } @@ -282,7 +282,7 @@ GetDate(struct cmd_syndesc *as, void *arock) ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer)); code = BOZO_GetDates(tconn, tbuffer, &time, &bakTime, &oldTime); if (code) { - printf("bos: failed to check date on %s (%s)\n", ti->data, + fprintf(stderr, "bos: failed to check date on %s (%s)\n", ti->data, em(code)); return 1; } else { @@ -316,7 +316,7 @@ UnInstall(struct cmd_syndesc *as, void *arock) tconn = GetConn(as, 0); if (!as->parms[1].items) { - printf("bos: no files to uninstall\n"); + fprintf(stderr, "bos: no files to uninstall\n"); return 1; } @@ -331,7 +331,7 @@ UnInstall(struct cmd_syndesc *as, void *arock) ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer)); code = BOZO_UnInstall(tconn, tbuffer); if (code) { - printf("bos: failed to uninstall %s (%s)\n", ti->data, em(code)); + fprintf(stderr, "bos: failed to uninstall %s (%s)\n", ti->data, em(code)); return 1; } else printf("bos: uninstalled file %s\n", ti->data); @@ -350,7 +350,7 @@ GetServerGoal(struct rx_connection *aconn, char *aname) tp = buffer; code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus); if (code) { - printf("bos: failed to get instance info for '%s' (%s)\n", aname, + fprintf(stderr, "bos: failed to get instance info for '%s' (%s)\n", aname, em(code)); /* if we can't get the answer, assume its running */ return BSTAT_NORMAL; @@ -375,7 +375,7 @@ Install(struct cmd_syndesc *as, void *arock) tconn = GetConn(as, 0); if (!as->parms[1].items) { - printf("bos: no files to install\n"); + fprintf(stderr, "bos: no files to install\n"); return 1; } @@ -390,12 +390,12 @@ Install(struct cmd_syndesc *as, void *arock) fd = open(ti->data, O_RDONLY); if (fd < 0) { /* better to quit on error than continue for install command */ - printf("bos: can't find file '%s', quitting\n", ti->data); + fprintf(stderr, "bos: can't find file '%s', quitting\n", ti->data); return 1; } code = fstat(fd, &tstat); if (code) { - printf("bos: failed to stat file %s, errno is %d\n", ti->data, + fprintf(stderr, "bos: failed to stat file %s, errno is %d\n", ti->data, errno); return 1; } @@ -410,7 +410,7 @@ Install(struct cmd_syndesc *as, void *arock) } code = rx_EndCall(tcall, code); if (code) { - printf("bos: failed to install %s (%s)\n", ti->data, em(code)); + fprintf(stderr, "bos: failed to install %s (%s)\n", ti->data, em(code)); return 1; } else printf("bos: installed file %s\n", ti->data); @@ -429,19 +429,19 @@ Shutdown(struct cmd_syndesc *as, void *arock) if (as->parms[1].items == 0) { code = BOZO_ShutdownAll(tconn); if (code) - printf("bos: failed to shutdown servers (%s)\n", em(code)); + fprintf(stderr, "bos: failed to shutdown servers (%s)\n", em(code)); } else { for (ti = as->parms[1].items; ti; ti = ti->next) { code = BOZO_SetTStatus(tconn, ti->data, BSTAT_SHUTDOWN); if (code) - printf("bos: failed to shutdown instance %s (%s)\n", ti->data, + fprintf(stderr, "bos: failed to shutdown instance %s (%s)\n", ti->data, em(code)); } } if (as->parms[8].items) { code = BOZO_WaitAll(tconn); if (code) - printf("bos: can't wait for processes to shutdown (%s)\n", + fprintf(stderr, "bos: can't wait for processes to shutdown (%s)\n", em(code)); } return 0; @@ -461,27 +461,27 @@ GetRestartCmd(struct cmd_syndesc *as, void *arock) code = BOZO_GetRestartTime(tconn, 1, (struct bozo_netKTime *) &generalTime); if (code) { - printf("bos: failed to retrieve restart information (%s)\n", + fprintf(stderr, "bos: failed to retrieve restart information (%s)\n", em(code)); return code; } code = BOZO_GetRestartTime(tconn, 2, (struct bozo_netKTime *) &newBinaryTime); if (code) { - printf("bos: failed to retrieve restart information (%s)\n", + fprintf(stderr, "bos: failed to retrieve restart information (%s)\n", em(code)); return code; } code = ktime_DisplayString(&generalTime, messageBuffer); if (code) { - printf("bos: failed to decode restart time (%s)\n", em(code)); + fprintf(stderr, "bos: failed to decode restart time (%s)\n", em(code)); return code; } printf("Server %s restarts %s\n", hostp, messageBuffer); code = ktime_DisplayString(&newBinaryTime, messageBuffer); if (code) { - printf("bos: failed to decode restart time (%s)\n", em(code)); + fprintf(stderr, "bos: failed to decode restart time (%s)\n", em(code)); return code; } printf("Server %s restarts for new binaries %s\n", hostp, messageBuffer); @@ -510,21 +510,21 @@ SetRestartCmd(struct cmd_syndesc *as, void *arock) type = 2; } if (count > 1) { - printf("bos: can't specify more than one restart time at a time\n"); + fprintf(stderr, "bos: can't specify more than one restart time at a time\n"); return -1; } if (count == 0) type = 1; /* by default set general restart time */ if ((code = ktime_ParsePeriodic(as->parms[1].items->data, &restartTime))) { - printf("bos: failed to parse '%s' as periodic restart time(%s)\n", + fprintf(stderr, "bos: failed to parse '%s' as periodic restart time(%s)\n", as->parms[1].items->data, em(code)); return code; } code = BOZO_SetRestartTime(tconn, type, (struct bozo_netKTime *) &restartTime); if (code) { - printf("bos: failed to set restart time at server (%s)\n", em(code)); + fprintf(stderr, "bos: failed to set restart time at server (%s)\n", em(code)); return code; } return 0; @@ -541,12 +541,12 @@ Startup(struct cmd_syndesc *as, void *arock) if (as->parms[1].items == 0) { code = BOZO_StartupAll(tconn); if (code) - printf("bos: failed to startup servers (%s)\n", em(code)); + fprintf(stderr, "bos: failed to startup servers (%s)\n", em(code)); } else { for (ti = as->parms[1].items; ti; ti = ti->next) { code = BOZO_SetTStatus(tconn, ti->data, BSTAT_NORMAL); if (code) - printf("bos: failed to start instance %s (%s)\n", ti->data, + fprintf(stderr, "bos: failed to start instance %s (%s)\n", ti->data, em(code)); } } @@ -566,31 +566,31 @@ Restart(struct cmd_syndesc *as, void *arock) if (as->parms[1].items) { /* specified specific things to restart, can't do this at the same * time */ - printf - ("bos: can't specify both '-bos' and specific servers to restart.\n"); + fprintf + (stderr, "bos: can't specify both '-bos' and specific servers to restart.\n"); return 1; } /* otherwise do a rebozo */ code = BOZO_ReBozo(tconn); if (code) - printf("bos: failed to restart bosserver (%s)\n", em(code)); + fprintf(stderr, "bos: failed to restart bosserver (%s)\n", em(code)); return code; } if (as->parms[1].items == 0) { if (as->parms[3].items) { /* '-all' */ code = BOZO_RestartAll(tconn); if (code) - printf("bos: failed to restart servers (%s)\n", em(code)); + fprintf(stderr, "bos: failed to restart servers (%s)\n", em(code)); } else - printf("bos: To restart all processes please specify '-all'\n"); + fprintf(stderr, "bos: To restart all processes please specify '-all'\n"); } else { if (as->parms[3].items) { - printf("bos: Can't use '-all' along with individual instances\n"); + fprintf(stderr, "bos: Can't use '-all' along with individual instances\n"); } else { for (ti = as->parms[1].items; ti; ti = ti->next) { code = BOZO_Restart(tconn, ti->data); if (code) - printf("bos: failed to restart instance %s (%s)\n", + fprintf(stderr, "bos: failed to restart instance %s (%s)\n", ti->data, em(code)); } } @@ -607,7 +607,7 @@ SetCellName(struct cmd_syndesc *as, void *arock) tconn = GetConn(as, 0); code = BOZO_SetCellName(tconn, as->parms[1].items->data); if (code) - printf("bos: failed to set cell (%s)\n", em(code)); + fprintf(stderr, "bos: failed to set cell (%s)\n", em(code)); return 0; } @@ -633,7 +633,7 @@ AddHost(struct cmd_syndesc *as, void *arock) } else code = BOZO_AddCellHost(tconn, ti->data); if (code) - printf("bos: failed to add host %s (%s)\n", ti->data, em(code)); + fprintf(stderr, "bos: failed to add host %s (%s)\n", ti->data, em(code)); } return 0; } @@ -649,7 +649,7 @@ RemoveHost(struct cmd_syndesc *as, void *arock) for (ti = as->parms[1].items; ti; ti = ti->next) { code = BOZO_DeleteCellHost(tconn, ti->data); if (code) - printf("bos: failed to delete host %s (%s)\n", ti->data, + fprintf(stderr, "bos: failed to delete host %s (%s)\n", ti->data, em(code)); } return 0; @@ -668,7 +668,7 @@ ListHosts(struct cmd_syndesc *as, void *arock) tconn = GetConn(as, 0); code = BOZO_GetCellName(tconn, &tp); if (code) { - printf("bos: failed to get cell name (%s)\n", em(code)); + fprintf(stderr, "bos: failed to get cell name (%s)\n", em(code)); exit(1); } printf("Cell name is %s\n", tbuffer); @@ -677,7 +677,7 @@ ListHosts(struct cmd_syndesc *as, void *arock) if (code == BZDOM) break; if (code != 0) { - printf("bos: failed to get cell host %d (%s)\n", i, em(code)); + fprintf(stderr, "bos: failed to get cell host %d (%s)\n", i, em(code)); exit(1); } printf(" Host %d is %s\n", i + 1, tbuffer); @@ -755,7 +755,7 @@ AddKey(struct cmd_syndesc *as, void *arock) } code = BOZO_AddKey(tconn, temp, ktc_to_bozoptr(&tkey)); if (code) { - printf("bos: failed to set key %d (%s)\n", temp, em(code)); + fprintf(stderr, "bos: failed to set key %d (%s)\n", temp, em(code)); exit(1); } return 0; @@ -774,7 +774,7 @@ RemoveKey(struct cmd_syndesc *as, void *arock) temp = atoi(ti->data); code = BOZO_DeleteKey(tconn, temp); if (code) { - printf("bos: failed to delete key %d (%s)\n", temp, em(code)); + fprintf(stderr, "bos: failed to delete key %d (%s)\n", temp, em(code)); exit(1); } } @@ -816,7 +816,7 @@ ListKeys(struct cmd_syndesc *as, void *arock) printf("Keys last changed on %s.\n", DateOf(keyInfo.mod_sec)); } if (code != BZDOM) - printf("bos: %s error encountered while listing keys\n", em(code)); + fprintf(stderr, "bos: %s error encountered while listing keys\n", em(code)); else printf("All done.\n"); return 0; @@ -835,7 +835,7 @@ AddSUser(struct cmd_syndesc *as, void *arock) for (ti = as->parms[1].items; ti; ti = ti->next) { code = BOZO_AddSUser(tconn, ti->data); if (code) { - printf("bos: failed to add user '%s' (%s)\n", ti->data, em(code)); + fprintf(stderr, "bos: failed to add user '%s' (%s)\n", ti->data, em(code)); failed = 1; } } @@ -855,11 +855,11 @@ RemoveSUser(struct cmd_syndesc *as, void *arock) for (ti = as->parms[1].items; ti; ti = ti->next) { code = BOZO_DeleteSUser(tconn, ti->data); if (code) { - printf("bos: failed to delete user '%s', ", ti->data); + fprintf(stderr, "bos: failed to delete user '%s', ", ti->data); if (code == ENOENT) - printf("(no such user)\n"); + fprintf(stderr, "(no such user)\n"); else - printf("(%s)\n", em(code)); + fprintf(stderr, "(%s)\n", em(code)); failed = 1; } } @@ -898,7 +898,7 @@ ListSUsers(struct cmd_syndesc *as, void *arock) } if (code != 1) { /* a real error code, instead of scanned past end */ - printf("bos: failed to retrieve super-user list (%s)\n", em(code)); + fprintf(stderr, "bos: failed to retrieve super-user list (%s)\n", em(code)); return code; } if (lastNL == 0) @@ -931,7 +931,7 @@ StatServer(struct cmd_syndesc *as, void *arock) if (code == BZDOM) break; if (code) { - printf("bos: failed to contact host's bosserver (%s).\n", + fprintf(stderr, "bos: failed to contact host's bosserver (%s).\n", em(code)); break; } @@ -965,8 +965,8 @@ CreateServer(struct cmd_syndesc *as, void *arock) BOZO_CreateBnode(tconn, type, name, parms[0], parms[1], parms[2], parms[3], parms[4], notifier); if (code) { - printf - ("bos: failed to create new server instance %s of type '%s' (%s)\n", + fprintf + (stderr, "bos: failed to create new server instance %s of type '%s' (%s)\n", name, type, em(code)); } return code; @@ -985,9 +985,9 @@ DeleteServer(struct cmd_syndesc *as, void *arock) code = BOZO_DeleteBnode(tconn, ti->data); if (code) { if (code == BZBUSY) - printf("bos: can't delete running instance '%s'\n", ti->data); + fprintf(stderr, "bos: can't delete running instance '%s'\n", ti->data); else - printf("bos: failed to delete instance '%s' (%s)\n", ti->data, + fprintf(stderr, "bos: failed to delete instance '%s' (%s)\n", ti->data, em(code)); } } @@ -1006,8 +1006,8 @@ StartServer(struct cmd_syndesc *as, void *arock) for (ti = as->parms[1].items; ti; ti = ti->next) { code = BOZO_SetStatus(tconn, ti->data, BSTAT_NORMAL); if (code) - printf("bos: failed to start instance '%s' (%s)\n", ti->data, - em(code)); + fprintf(stderr, "bos: failed to start instance '%s' (%s)\n", + ti->data, em(code)); } return code; } @@ -1024,13 +1024,13 @@ StopServer(struct cmd_syndesc *as, void *arock) for (ti = as->parms[1].items; ti; ti = ti->next) { code = BOZO_SetStatus(tconn, ti->data, BSTAT_SHUTDOWN); if (code) - printf("bos: failed to change stop instance '%s' (%s)\n", + fprintf(stderr, "bos: failed to change stop instance '%s' (%s)\n", ti->data, em(code)); } if (as->parms[8].items) { code = BOZO_WaitAll(tconn); if (code) - printf("bos: can't wait for processes to shutdown (%s)\n", + fprintf(stderr, "bos: can't wait for processes to shutdown (%s)\n", em(code)); } return code; @@ -1060,12 +1060,12 @@ DoSalvage(struct rx_connection * aconn, char * aparm1, char * aparm2, if (aparm1) { partNumber = volutil_GetPartitionID(aparm1); if (partNumber < 0) { - printf("bos: could not parse partition ID '%s'\n", aparm1); + fprintf(stderr, "bos: could not parse partition ID '%s'\n", aparm1); return EINVAL; } tp = volutil_PartitionName(partNumber); if (!tp) { - printf("bos: internal error parsing partition ID '%s'\n", aparm1); + fprintf(stderr, "bos: internal error parsing partition ID '%s'\n", aparm1); return EINVAL; } strcpy(partName, tp); @@ -1076,7 +1076,7 @@ DoSalvage(struct rx_connection * aconn, char * aparm1, char * aparm2, if (aoutName) { outFile = fopen(aoutName, "w"); if (!outFile) { - printf("bos: can't open specified SalvageLog file '%s'\n", + fprintf(stderr, "bos: can't open specified SalvageLog file '%s'\n", aoutName); return ENOENT; } @@ -1102,7 +1102,7 @@ DoSalvage(struct rx_connection * aconn, char * aparm1, char * aparm2, if ((strlen(tbuffer) + 9 + strlen(partName) + 1 + strlen(aparm2) + 1) > BOZO_BSSIZE) { - printf("bos: command line too big\n"); + fprintf(stderr, "bos: command line too big\n"); return (E2BIG); } @@ -1115,7 +1115,7 @@ DoSalvage(struct rx_connection * aconn, char * aparm1, char * aparm2, if ((strlen(tbuffer) + 1 + strlen(partName) + 1 + strlen(aparm2) + 1) > BOZO_BSSIZE) { - printf("bos: command line too big\n"); + fprintf(stderr, "bos: command line too big\n"); return (E2BIG); } @@ -1128,7 +1128,7 @@ DoSalvage(struct rx_connection * aconn, char * aparm1, char * aparm2, /* partition salvage */ strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH, BOZO_BSSIZE); if ((strlen(tbuffer) + 4 + strlen(partName) + 1) > BOZO_BSSIZE) { - printf("bos: command line too big\n"); + fprintf(stderr, "bos: command line too big\n"); return (E2BIG); } strcat(tbuffer, " -force "); @@ -1144,7 +1144,7 @@ DoSalvage(struct rx_connection * aconn, char * aparm1, char * aparm2, /* add the parallel option if given */ if (parallel != NULL) { if ((strlen(tbuffer) + 11 + strlen(parallel) + 1) > BOZO_BSSIZE) { - printf("bos: command line too big\n"); + fprintf(stderr, "bos: command line too big\n"); return (E2BIG); } strcat(tbuffer, " -parallel "); @@ -1154,7 +1154,7 @@ DoSalvage(struct rx_connection * aconn, char * aparm1, char * aparm2, /* add the tmpdir option if given */ if (atmpDir != NULL) { if ((strlen(tbuffer) + 9 + strlen(atmpDir) + 1) > BOZO_BSSIZE) { - printf("bos: command line too big\n"); + fprintf(stderr, "bos: command line too big\n"); return (E2BIG); } strcat(tbuffer, " -tmpdir "); @@ -1164,7 +1164,7 @@ DoSalvage(struct rx_connection * aconn, char * aparm1, char * aparm2, /* add the orphans option if given */ if (orphans != NULL) { if ((strlen(tbuffer) + 10 + strlen(orphans) + 1) > BOZO_BSSIZE) { - printf("bos: command line too big\n"); + fprintf(stderr, "bos: command line too big\n"); return (E2BIG); } strcat(tbuffer, " -orphans "); @@ -1178,7 +1178,7 @@ DoSalvage(struct rx_connection * aconn, char * aparm1, char * aparm2, BOZO_CreateBnode(aconn, "cron", "salvage-tmp", parms[0], parms[1], parms[2], parms[3], parms[4], notifier); if (code) { - printf("bos: failed to start 'salvager' (%s)\n", em(code)); + fprintf(stderr, "bos: failed to start 'salvager' (%s)\n", em(code)); goto done; } /* now wait for bnode to disappear */ @@ -1193,7 +1193,7 @@ DoSalvage(struct rx_connection * aconn, char * aparm1, char * aparm2, printf("bos: waiting for salvage to complete.\n"); } if (code != BZNOENT) { - printf("bos: salvage failed (%s)\n", em(code)); + fprintf(stderr, "bos: salvage failed (%s)\n", em(code)); goto done; } code = 0; @@ -1326,7 +1326,7 @@ SalvageCmd(struct cmd_syndesc *as, void *arock) /* we can do a volume, a partition or the whole thing, but not mixtures * thereof */ if (!as->parms[1].items && as->parms[2].items) { - printf("bos: must specify partition to salvage individual volume.\n"); + fprintf(stderr, "bos: must specify partition to salvage individual volume.\n"); return -1; } if (as->parms[5].items && as->parms[3].items) { @@ -1334,7 +1334,7 @@ SalvageCmd(struct cmd_syndesc *as, void *arock) return -1; } if (as->parms[4].items && (as->parms[1].items || as->parms[2].items)) { - printf("bos: can not specify -all with other flags.\n"); + fprintf(stderr, "bos: can not specify -all with other flags.\n"); return -1; } @@ -1365,8 +1365,8 @@ SalvageCmd(struct cmd_syndesc *as, void *arock) if (dafs) { if (!as->parms[9].items) { /* -forceDAFS flag */ - printf("This is a demand attach fileserver. Are you sure you want to proceed with a manual salvage?\n"); - printf("must specify -forceDAFS flag in order to proceed.\n"); + fprintf(stderr, "This is a demand attach fileserver. Are you sure you want to proceed with a manual salvage?\n"); + fprintf(stderr, "must specify -forceDAFS flag in order to proceed.\n"); return EINVAL; } } @@ -1378,13 +1378,13 @@ SalvageCmd(struct cmd_syndesc *as, void *arock) printf("bos: shutting down '%s'.\n", serviceName); code = BOZO_SetTStatus(tconn, serviceName, BSTAT_SHUTDOWN); if (code) { - printf("bos: failed to stop '%s' (%s)\n", serviceName, em(code)); + fprintf(stderr, "bos: failed to stop '%s' (%s)\n", serviceName, em(code)); return code; } code = BOZO_WaitAll(tconn); /* wait for shutdown to complete */ if (code) - printf - ("bos: failed to wait for file server shutdown, continuing.\n"); + fprintf + (stderr, "bos: failed to wait for file server shutdown, continuing.\n"); } /* now do the salvage operation */ printf("Starting salvage.\n"); @@ -1394,7 +1394,7 @@ SalvageCmd(struct cmd_syndesc *as, void *arock) printf("bos: restarting %s.\n", serviceName); code = BOZO_SetTStatus(tconn, serviceName, BSTAT_NORMAL); if (code) { - printf("bos: failed to restart '%s' (%s)\n", serviceName, em(code)); + fprintf(stderr, "bos: failed to restart '%s' (%s)\n", serviceName, em(code)); return code; } } @@ -1402,15 +1402,15 @@ SalvageCmd(struct cmd_syndesc *as, void *arock) return rc; } else if (!as->parms[2].items) { if (!as->parms[1].items) { - printf - ("bos: must specify -all switch to salvage all partitions.\n"); + fprintf + (stderr, "bos: must specify -all switch to salvage all partitions.\n"); return -1; } if (volutil_GetPartitionID(as->parms[1].items->data) < 0) { /* can't parse volume ID, so complain before shutting down * file server. */ - printf("bos: can't interpret %s as partition ID.\n", + fprintf(stderr, "bos: can't interpret %s as partition ID.\n", as->parms[1].items->data); return -1; } @@ -1420,13 +1420,13 @@ SalvageCmd(struct cmd_syndesc *as, void *arock) printf("bos: shutting down '%s'.\n", serviceName); code = BOZO_SetTStatus(tconn, serviceName, BSTAT_SHUTDOWN); if (code) { - printf("bos: can't stop '%s' (%s)\n", serviceName, em(code)); + fprintf(stderr, "bos: can't stop '%s' (%s)\n", serviceName, em(code)); return code; } code = BOZO_WaitAll(tconn); /* wait for shutdown to complete */ if (code) - printf - ("bos: failed to wait for file server shutdown, continuing.\n"); + fprintf + (stderr, "bos: failed to wait for file server shutdown, continuing.\n"); } /* now do the salvage operation */ printf("Starting salvage.\n"); @@ -1469,14 +1469,14 @@ SalvageCmd(struct cmd_syndesc *as, void *arock) if (code == 0) { newID = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); if (newID == 0) { - printf("bos: can't interpret %s as volume name or ID\n", + fprintf(stderr, "bos: can't interpret %s as volume name or ID\n", as->parms[2].items->data); return -1; } sprintf(tname, "%u", newID); } else { - printf - ("bos: can't initialize volume system client (code %d), trying anyway.\n", + fprintf + (stderr, "bos: can't initialize volume system client (code %d), trying anyway.\n", code); strncpy(tname, as->parms[2].items->data, sizeof(tname)); } @@ -1484,7 +1484,7 @@ SalvageCmd(struct cmd_syndesc *as, void *arock) /* can't parse volume ID, so complain before shutting down * file server. */ - printf("bos: can't interpret %s as partition ID.\n", + fprintf(stderr, "bos: can't interpret %s as partition ID.\n", as->parms[1].items->data); return -1; } @@ -1529,7 +1529,7 @@ DoStat(IN char *aname, tp = buffer; code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus); if (code) { - printf("bos: failed to get instance info for '%s' (%s)\n", aname, + fprintf(stderr, "bos: failed to get instance info for '%s' (%s)\n", aname, em(code)); return -1; } @@ -1557,7 +1557,7 @@ DoStat(IN char *aname, tp = buffer; code = BOZO_GetStatus(aconn, aname, &temp, &tp); if (code) - printf("bos: failed to get status for instance '%s' (%s)\n", aname, + fprintf(stderr, "bos: failed to get status for instance '%s' (%s)\n", aname, em(code)); else { printf("currently "); @@ -1639,7 +1639,7 @@ GetRestrict(struct cmd_syndesc *as, void *arock) tconn = GetConn(as, 0); code = BOZO_GetRestrictedMode(tconn, &val); if (code) - printf("bos: failed to get restricted mode (%s)\n", em(code)); + fprintf(stderr, "bos: failed to get restricted mode (%s)\n", em(code)); else printf("Restricted mode is %s\n", val ? "on" : "off"); @@ -1656,7 +1656,7 @@ SetRestrict(struct cmd_syndesc *as, void *arock) util_GetInt32(as->parms[1].items->data, &val); code = BOZO_SetRestrictedMode(tconn, val); if (code) - printf("bos: failed to set restricted mode (%s)\n", em(code)); + fprintf(stderr, "bos: failed to set restricted mode (%s)\n", em(code)); return 0; } @@ -1702,7 +1702,7 @@ main(int argc, char **argv) /* start up rx */ code = rx_Init(0); if (code) { - printf("bos: could not initialize rx (%s)\n", em(code)); + fprintf(stderr, "bos: could not initialize rx (%s)\n", em(code)); exit(1); } diff --git a/src/ptserver/pts.c b/src/ptserver/pts.c index f495a973d..bed6516ad 100644 --- a/src/ptserver/pts.c +++ b/src/ptserver/pts.c @@ -281,7 +281,7 @@ CreateGroup(struct cmd_syndesc *as, void *arock) return code; } if (id == 0) { - printf("0 isn't a valid group id; aborting\n"); + fprintf(stderr, "0 isn't a valid group id; aborting\n"); return EINVAL; } if (id > 0) { @@ -334,7 +334,7 @@ CreateUser(struct cmd_syndesc *as, void *arock) return code; } if (id == 0) { - printf("0 isn't a valid user id; aborting\n"); + fprintf(stderr, "0 isn't a valid user id; aborting\n"); return EINVAL; } if (id < 0) { @@ -929,7 +929,7 @@ SetMaxCommand(struct cmd_syndesc *as, void *arock) } if (!as->parms[0].items && !as->parms[1].items) { code = PRBADARG; - printf("Must specify at least one of group or user.\n"); + fprintf(stderr, "Must specify at least one of group or user.\n"); } return code; } @@ -959,7 +959,7 @@ SetFields(struct cmd_syndesc *as, void *arock) } else { /* interpret flag bit names */ if (strlen(access) != 5) { form_error: - printf("Access bits must be of the form 'somar', not %s\n", + fprintf(stderr, "Access bits must be of the form 'somar', not %s\n", access); return PRBADARG; } @@ -974,8 +974,8 @@ SetFields(struct cmd_syndesc *as, void *arock) else if (access[i] == '-') new = 0; else { - printf - ("Access bits out of order or illegal:\n must be a combination of letters from '%s' or '%s' or hyphen, not %s\n", + fprintf(stderr, + "Access bits out of order or illegal:\n must be a combination of letters from '%s' or '%s' or hyphen, not %s\n", flags_upcase, flags_dncase, access); return PRBADARG; } -- 2.39.5