| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | #include <afsconfig.h> |
| 11 | #include <afs/param.h> |
| 12 | #include <afs/stds.h> |
| 13 | |
| 14 | #include <afs/procmgmt.h> |
| 15 | #include <roken.h> |
| 16 | |
| 17 | #include <hcrypto/ui.h> |
| 18 | |
| 19 | #include "bnode.h" |
| 20 | #include <afs/afsutil.h> |
| 21 | #include <afs/cellconfig.h> |
| 22 | #include <rx/rx.h> |
| 23 | #include <sys/stat.h> |
| 24 | #include <rx/xdr.h> |
| 25 | #include <afs/auth.h> |
| 26 | #include <afs/cellconfig.h> |
| 27 | #include <afs/cmd.h> |
| 28 | #include <afs/com_err.h> |
| 29 | #include <ubik.h> |
| 30 | #include <afs/ktime.h> |
| 31 | #include <afs/kautils.h> |
| 32 | #include <afs/volser.h> |
| 33 | |
| 34 | static int IStatServer(struct cmd_syndesc *as, int int32p); |
| 35 | static int DoStat(char *aname, struct rx_connection *aconn, |
| 36 | int aint32p, int firstTime); |
| 37 | |
| 38 | #include "bosint.h" |
| 39 | #include "bosprototypes.h" |
| 40 | |
| 41 | |
| 42 | #define MRAFS_OFFSET10 10 |
| 43 | #define ADDPARMOFFSET27 27 |
| 44 | |
| 45 | |
| 46 | struct MRAFSSalvageParms { |
| 47 | afs_int32 Optdebug; |
| 48 | afs_int32 Optnowrite; |
| 49 | afs_int32 Optforce; |
| 50 | afs_int32 Optoktozap; |
| 51 | afs_int32 Optrootfiles; |
| 52 | afs_int32 Optsalvagedirs; |
| 53 | afs_int32 Optblockreads; |
| 54 | afs_int32 OptListResidencies; |
| 55 | afs_int32 OptSalvageRemote; |
| 56 | afs_int32 OptSalvageArchival; |
| 57 | afs_int32 OptIgnoreCheck; |
| 58 | afs_int32 OptForceOnLine; |
| 59 | afs_int32 OptUseRootDirACL; |
| 60 | afs_int32 OptTraceBadLinkCounts; |
| 61 | afs_int32 OptDontAskFS; |
| 62 | afs_int32 OptLogLevel; |
| 63 | afs_int32 OptRxDebug; |
| 64 | afs_uint32 OptResidencies; |
| 65 | }; |
| 66 | |
| 67 | |
| 68 | |
| 69 | int osi_audit(void ) |
| 70 | { |
| 71 | return 0; |
| 72 | } |
| 73 | |
| 74 | |
| 75 | static char * |
| 76 | em(afs_int32 acode) |
| 77 | { |
| 78 | if (acode == -1) |
| 79 | return "communications failure (-1)"; |
| 80 | else if (acode == -3) |
| 81 | return "communications timeout (-3)"; |
| 82 | else |
| 83 | return (char *)afs_error_message(acode); |
| 84 | } |
| 85 | |
| 86 | |
| 87 | |
| 88 | #if 0 |
| 89 | static afs_int32 |
| 90 | GetPartitionID(char *aname) |
| 91 | { |
| 92 | char tc; |
| 93 | char ascii[3]; |
| 94 | |
| 95 | tc = *aname; |
| 96 | if (tc == 0) |
| 97 | return -1; |
| 98 | |
| 99 | if (tc >= '0' && tc <= '9') { |
| 100 | return atoi(aname); |
| 101 | } |
| 102 | |
| 103 | ascii[2] = 0; |
| 104 | if (strlen(aname) <= 2) { |
| 105 | strcpy(ascii, aname); |
| 106 | } else if (!strncmp(aname, "/vicep", 6)) { |
| 107 | strncpy(ascii, aname + 6, 2); |
| 108 | } else if (!strncmp(aname, "vicep", 5)) { |
| 109 | strncpy(ascii, aname + 5, 2); |
| 110 | } else |
| 111 | return -1; |
| 112 | |
| 113 | |
| 114 | if (ascii[1] == 0) { |
| 115 | |
| 116 | if (ascii[0] < 'a' || ascii[0] > 'z') |
| 117 | return -1; |
| 118 | return ascii[0] - 'a'; |
| 119 | } else { |
| 120 | |
| 121 | if (ascii[0] < 'a' || ascii[0] > 'z') |
| 122 | return -1; |
| 123 | if (ascii[1] < 'a' || ascii[1] > 'z') |
| 124 | return -1; |
| 125 | return (ascii[0] - 'a') * 26 + (ascii[1] - 'a') + 26; |
| 126 | } |
| 127 | } |
| 128 | #endif |
| 129 | |
| 130 | |
| 131 | static char * |
| 132 | DateOf(afs_int32 atime) |
| 133 | { |
| 134 | static char tbuffer[30]; |
| 135 | char *tp; |
| 136 | time_t t = (time_t) atime; |
| 137 | tp = ctime(&t); |
| 138 | if (tp) { |
| 139 | strcpy(tbuffer, tp); |
| 140 | tbuffer[24] = 0; |
| 141 | } else |
| 142 | strcpy(tbuffer, "BAD TIME"); |
| 143 | return tbuffer; |
| 144 | } |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | static struct rx_connection * |
| 151 | GetConn(struct cmd_syndesc *as, int aencrypt) |
| 152 | { |
| 153 | struct hostent *th; |
| 154 | char *hostname; |
| 155 | char *cellname = NULL((void *)0); |
| 156 | const char *confdir; |
| 157 | afs_int32 code; |
| 158 | struct rx_connection *tconn; |
| 159 | afs_int32 addr; |
| 160 | struct afsconf_dir *tdir = NULL((void *)0); |
| 161 | afsconf_secflags secFlags; |
| 162 | struct rx_securityClass *sc; |
| 163 | afs_int32 scIndex; |
| 164 | |
| 165 | hostname = as->parms[0].items->data; |
| 166 | th = hostutil_GetHostByName(hostname); |
| 167 | if (!th) { |
| 168 | printf("bos: can't find address for host '%s'\n", hostname); |
| 169 | exit(1); |
| 170 | } |
| 171 | memcpy(&addr, th->h_addrh_addr_list[0], sizeof(afs_int32)); |
| 172 | |
| 173 | secFlags = AFSCONF_SECOPTS_FALLBACK_NULL0x8; |
| 174 | |
| 175 | if (as->parms[ADDPARMOFFSET27 + 2].items) { |
| 176 | secFlags |= AFSCONF_SECOPTS_LOCALAUTH0x2; |
| 177 | confdir = AFSDIR_SERVER_ETC_DIRPATHgetDirPath(AFSDIR_SERVER_ETC_DIRPATH_ID); |
| 178 | } else { |
| 179 | confdir = AFSDIR_CLIENT_ETC_DIRPATHgetDirPath(AFSDIR_CLIENT_ETC_DIRPATH_ID); |
| 180 | } |
| 181 | |
| 182 | if (as->parms[ADDPARMOFFSET27 + 1].items) { |
| 183 | secFlags |= AFSCONF_SECOPTS_NOAUTH0x1; |
| 184 | } else { |
| 185 | |
| 186 | |
| 187 | tdir = afsconf_Open(confdir); |
| 188 | if (tdir == NULL((void *)0)) { |
| 189 | printf("bos: can't open cell database (%s)\n", confdir); |
| 190 | exit(1); |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | if (as->parms[ADDPARMOFFSET27].items) |
| 195 | cellname = as->parms[ADDPARMOFFSET27].items->data; |
| 196 | |
| 197 | code = afsconf_PickClientSecObj(tdir, secFlags, NULL((void *)0), cellname, |
| 198 | &sc, &scIndex, NULL((void *)0)); |
| 199 | if (code) { |
| 200 | afs_com_err("bos", code, "(configuring connection security)"); |
| 201 | exit(1); |
| 202 | } |
| 203 | |
| 204 | if (scIndex == RX_SECIDX_NULL) |
| 205 | fprintf(stderr__stderrp, "bos: running unauthenticated\n"); |
| 206 | |
| 207 | tconn = |
| 208 | rx_NewConnection(addr, htons(AFSCONF_NANNYPORT)(__builtin_constant_p(7007) ? (__uint16_t)(((__uint16_t)(7007 )) << 8 | ((__uint16_t)(7007)) >> 8) : __bswap16_var (7007)), 1, sc, scIndex); |
| 209 | if (!tconn) { |
| 210 | fprintf(stderr__stderrp, "bos: could not create rx connection\n"); |
| 211 | exit(1); |
| 212 | } |
| 213 | rxs_Release(sc); |
| 214 | |
| 215 | return tconn; |
| 216 | } |
| 217 | |
| 218 | static int |
| 219 | SetAuth(struct cmd_syndesc *as, void *arock) |
| 220 | { |
| 221 | afs_int32 code; |
| 222 | struct rx_connection *tconn; |
| 223 | afs_int32 flag; |
| 224 | char *tp; |
| 225 | |
| 226 | tconn = GetConn(as, 0); |
| 227 | tp = as->parms[1].items->data; |
| 228 | if (strcmp(tp, "on") == 0) |
| 229 | flag = 0; |
| 230 | else if (strcmp(tp, "off") == 0) |
| 231 | flag = 1; |
| 232 | else { |
| 233 | printf |
| 234 | ("bos: illegal authentication specifier '%s', must be 'off' or 'on'.\n", |
| 235 | tp); |
| 236 | return 1; |
| 237 | } |
| 238 | code = BOZO_SetNoAuthFlag(tconn, flag); |
| 239 | if (code) |
| 240 | afs_com_err("bos", code, "(failed to set authentication flag)"); |
| 241 | return 0; |
| 242 | } |
| 243 | |
| 244 | |
| 245 | |
| 246 | static int |
| 247 | ComputeDestDir(char *aname, char *adir, char *aresult, afs_int32 alen) |
| 248 | { |
| 249 | char *tp; |
| 250 | |
| 251 | strcpy(aresult, adir); |
| 252 | tp = strrchr(aname, '/'); |
| 253 | if (!tp) { |
| 254 | |
| 255 | strcat(aresult, "/"); |
| 256 | strcat(aresult, aname); |
| 257 | } else { |
| 258 | |
| 259 | strcat(aresult, tp); |
| 260 | } |
| 261 | return 0; |
| 262 | } |
| 263 | |
| 264 | |
| 265 | static int |
| 266 | CopyBytes(int afd, struct rx_call *acall) |
| 267 | { |
| 268 | afs_int32 code; |
| 269 | afs_int32 len; |
| 270 | char tbuffer[256]; |
| 271 | |
| 272 | while (1) { |
| 273 | len = read(afd, tbuffer, sizeof(tbuffer)); |
| 274 | if (len < 0) |
| 275 | return errno(* __error()); |
| 276 | if (len == 0) |
| 277 | return 0; |
| 278 | code = rx_Write(acall, tbuffer, len)rx_WriteProc(acall, tbuffer, len); |
| 279 | if (code != len) |
| 280 | return -1; |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | static int |
| 285 | Prune(struct cmd_syndesc *as, void *arock) |
| 286 | { |
| 287 | afs_int32 code; |
| 288 | struct rx_connection *tconn; |
| 289 | afs_int32 flags; |
| 290 | |
| 291 | tconn = GetConn(as, 0); |
| 292 | flags = 0; |
| 293 | if (as->parms[1].items) |
| 294 | flags |= BOZO_PRUNEBAK2; |
| 295 | if (as->parms[2].items) |
| 296 | flags |= BOZO_PRUNEOLD1; |
| 297 | if (as->parms[3].items) |
| 298 | flags |= BOZO_PRUNECORE4; |
| 299 | if (as->parms[4].items) |
| 300 | flags |= 0xff; |
| 301 | code = BOZO_Prune(tconn, flags); |
| 302 | if (code) |
| 303 | afs_com_err("bos", code, "(failed to prune server files)"); |
| 304 | return code; |
| 305 | } |
| 306 | |
| 307 | static int |
| 308 | Exec(struct cmd_syndesc *as, void *arock) |
| 309 | { |
| 310 | struct rx_connection *tconn; |
| 311 | afs_int32 code; |
| 312 | |
| 313 | tconn = GetConn(as, 0); |
| 314 | code = BOZO_Exec(tconn, as->parms[1].items->data); |
| 315 | if (code) |
| 316 | printf("bos: failed to execute command (%s)\n", em(code)); |
| 317 | return code; |
| 318 | } |
| 319 | |
| 320 | static int |
| 321 | GetDate(struct cmd_syndesc *as, void *arock) |
| 322 | { |
| 323 | afs_int32 code; |
| 324 | char tbuffer[256]; |
| 325 | char destDir[256]; |
| 326 | afs_int32 time, bakTime, oldTime; |
| 327 | struct rx_connection *tconn; |
| 328 | struct cmd_item *ti; |
| 329 | |
| 330 | tconn = GetConn(as, 0); |
| 331 | if (!as->parms[1].items) { |
| 332 | printf("bos: no files to check\n"); |
| 333 | return 1; |
| 334 | } |
| 335 | |
| 336 | |
| 337 | if (as->parms[2].items) |
| 338 | strcpy(destDir, as->parms[2].items->data); |
| 339 | else |
| 340 | strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH"/usr/afs" "/bin"); |
| 341 | |
| 342 | for (ti = as->parms[1].items; ti; ti = ti->next) { |
| 343 | |
| 344 | ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer)); |
| 345 | code = BOZO_GetDates(tconn, tbuffer, &time, &bakTime, &oldTime); |
| 346 | if (code) { |
| 347 | printf("bos: failed to check date on %s (%s)\n", ti->data, |
| 348 | em(code)); |
| 349 | return 1; |
| 350 | } else { |
| 351 | printf("File %s ", tbuffer); |
| 352 | if (time == 0) |
| 353 | printf("does not exist, "); |
| 354 | else |
| 355 | printf("dated %s, ", DateOf(time)); |
| 356 | if (bakTime == 0) |
| 357 | printf("no .BAK file, "); |
| 358 | else |
| 359 | printf(".BAK file dated %s, ", DateOf(bakTime)); |
| 360 | if (oldTime == 0) |
| 361 | printf("no .OLD file."); |
| 362 | else |
| 363 | printf(".OLD file dated %s.", DateOf(oldTime)); |
| 364 | printf("\n"); |
| 365 | } |
| 366 | } |
| 367 | return 0; |
| 368 | } |
| 369 | |
| 370 | static int |
| 371 | UnInstall(struct cmd_syndesc *as, void *arock) |
| 372 | { |
| 373 | afs_int32 code; |
| 374 | char tbuffer[256]; |
| 375 | char destDir[256]; |
| 376 | struct cmd_item *ti; |
| 377 | struct rx_connection *tconn; |
| 378 | |
| 379 | tconn = GetConn(as, 0); |
| 380 | if (!as->parms[1].items) { |
| 381 | printf("bos: no files to uninstall\n"); |
| 382 | return 1; |
| 383 | } |
| 384 | |
| 385 | |
| 386 | if (as->parms[2].items) |
| 387 | strcpy(destDir, as->parms[2].items->data); |
| 388 | else |
| 389 | strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH"/usr/afs" "/bin"); |
| 390 | |
| 391 | for (ti = as->parms[1].items; ti; ti = ti->next) { |
| 392 | |
| 393 | ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer)); |
| 394 | code = BOZO_UnInstall(tconn, tbuffer); |
| 395 | if (code) { |
| 396 | printf("bos: failed to uninstall %s (%s)\n", ti->data, em(code)); |
| 397 | return 1; |
| 398 | } else |
| 399 | printf("bos: uninstalled file %s\n", ti->data); |
| 400 | } |
| 401 | return 0; |
| 402 | } |
| 403 | |
| 404 | static afs_int32 |
| 405 | GetServerGoal(struct rx_connection *aconn, char *aname) |
| 406 | { |
| 407 | char buffer[500]; |
| 408 | char *tp; |
| 409 | afs_int32 code; |
| 410 | struct bozo_status istatus; |
| 411 | |
| 412 | tp = buffer; |
| 413 | code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus); |
| 414 | if (code) { |
| 415 | printf("bos: failed to get instance info for '%s' (%s)\n", aname, |
| 416 | em(code)); |
| 417 | |
| 418 | return BSTAT_NORMAL1; |
| 419 | } |
| 420 | if (istatus.goal == 0) |
| 421 | return BSTAT_SHUTDOWN0; |
| 422 | else |
| 423 | return BSTAT_NORMAL1; |
| 424 | } |
| 425 | |
| 426 | static int |
| 427 | Install(struct cmd_syndesc *as, void *arock) |
| 428 | { |
| 429 | struct rx_connection *tconn; |
| 430 | afs_int32 code; |
| 431 | struct cmd_item *ti; |
| 432 | struct stat tstat; |
| 433 | char tbuffer[256]; |
| 434 | int fd; |
| 435 | struct rx_call *tcall; |
| 436 | char destDir[256]; |
| 437 | |
| 438 | tconn = GetConn(as, 0); |
| 439 | if (!as->parms[1].items) { |
| 440 | printf("bos: no files to install\n"); |
| 441 | return 1; |
| 442 | } |
| 443 | |
| 444 | |
| 445 | if (as->parms[2].items) |
| 446 | strcpy(destDir, as->parms[2].items->data); |
| 447 | else |
| 448 | strcpy(destDir, AFSDIR_CANONICAL_SERVER_BIN_DIRPATH"/usr/afs" "/bin"); |
| 449 | |
| 450 | for (ti = as->parms[1].items; ti; ti = ti->next) { |
| 451 | |
| 452 | fd = open(ti->data, O_RDONLY0x0000); |
| 453 | if (fd < 0) { |
| 454 | |
| 455 | printf("bos: can't find file '%s', quitting\n", ti->data); |
| 456 | return 1; |
| 457 | } |
| 458 | code = fstat(fd, &tstat); |
| 459 | if (code) { |
| 460 | printf("bos: failed to stat file %s, errno is %d\n", ti->data, |
| 461 | errno(* __error())); |
| 462 | return 1; |
| 463 | } |
| 464 | |
| 465 | ComputeDestDir(ti->data, destDir, tbuffer, sizeof(tbuffer)); |
| 466 | tcall = rx_NewCall(tconn); |
| 467 | code = |
| 468 | StartBOZO_Install(tcall, tbuffer, tstat.st_size, |
| 469 | (afs_int32) tstat.st_mode, tstat.st_mtimest_mtim.tv_sec); |
| 470 | if (code == 0) { |
| 471 | code = CopyBytes(fd, tcall); |
| 472 | } |
| 473 | code = rx_EndCall(tcall, code); |
| 474 | if (code) { |
| 475 | printf("bos: failed to install %s (%s)\n", ti->data, em(code)); |
| 476 | return 1; |
| 477 | } else |
| 478 | printf("bos: installed file %s\n", ti->data); |
| 479 | } |
| 480 | return 0; |
| 481 | } |
| 482 | |
| 483 | static int |
| 484 | Shutdown(struct cmd_syndesc *as, void *arock) |
| 485 | { |
| 486 | struct rx_connection *tconn; |
| 487 | afs_int32 code; |
| 488 | struct cmd_item *ti; |
| 489 | |
| 490 | tconn = GetConn(as, 0); |
| 491 | if (as->parms[1].items == 0) { |
| 492 | code = BOZO_ShutdownAll(tconn); |
| 493 | if (code) |
| 494 | printf("bos: failed to shutdown servers (%s)\n", em(code)); |
| 495 | } else { |
| 496 | for (ti = as->parms[1].items; ti; ti = ti->next) { |
| 497 | code = BOZO_SetTStatus(tconn, ti->data, BSTAT_SHUTDOWN0); |
| 498 | if (code) |
| 499 | printf("bos: failed to shutdown instance %s (%s)\n", ti->data, |
| 500 | em(code)); |
| 501 | } |
| 502 | } |
| 503 | if (as->parms[8].items) { |
| 504 | code = BOZO_WaitAll(tconn); |
| 505 | if (code) |
| 506 | printf("bos: can't wait for processes to shutdown (%s)\n", |
| 507 | em(code)); |
| 508 | } |
| 509 | return 0; |
| 510 | } |
| 511 | |
| 512 | static int |
| 513 | BlockScannerCmd(struct cmd_syndesc *as, void *arock) |
| 514 | { |
| 515 | afs_int32 code; |
| 516 | struct rx_connection *tconn; |
| 517 | char BlockCommand[] = "/usr/afs/bin/scanner -block"; |
| 518 | |
| 519 | tconn = GetConn(as, 0); |
| 520 | code = BOZO_Exec(tconn, BlockCommand); |
| 521 | if (code) |
| 522 | printf |
| 523 | ("bos: failed to block scanner from making migration requests (%s)\n", |
| 524 | em(code)); |
| 525 | return 0; |
| 526 | } |
| 527 | |
| 528 | static int |
| 529 | UnBlockScannerCmd(struct cmd_syndesc *as, void *arock) |
| 530 | { |
| 531 | afs_int32 code; |
| 532 | struct rx_connection *tconn; |
| 533 | char UnBlockCommand[] = "/usr/afs/bin/scanner -unblock"; |
| 534 | |
| 535 | tconn = GetConn(as, 0); |
| 536 | code = BOZO_Exec(tconn, UnBlockCommand); |
| 537 | if (code) |
| 538 | printf |
| 539 | ("bos: failed to allow scanner daemon to make migration requests again (%s)\n", |
| 540 | em(code)); |
| 541 | return 0; |
| 542 | } |
| 543 | |
| 544 | static int |
| 545 | GetRestartCmd(struct cmd_syndesc *as, void *arock) |
| 546 | { |
| 547 | afs_int32 code; |
| 548 | struct ktime generalTime, newBinaryTime; |
| 549 | char messageBuffer[256]; |
| 550 | struct rx_connection *tconn; |
| 551 | char *hostp; |
| 552 | |
| 553 | hostp = as->parms[0].items->data; |
| 554 | tconn = GetConn(as, 0); |
| 555 | |
| 556 | code = BOZO_GetRestartTime(tconn, 1, (struct bozo_netKTime *) &generalTime); |
| 557 | if (code) { |
| 558 | printf("bos: failed to retrieve restart information (%s)\n", |
| 559 | em(code)); |
| 560 | return code; |
| 561 | } |
| 562 | code = BOZO_GetRestartTime(tconn, 2, (struct bozo_netKTime *) &newBinaryTime); |
| 563 | if (code) { |
| 564 | printf("bos: failed to retrieve restart information (%s)\n", |
| 565 | em(code)); |
| 566 | return code; |
| 567 | } |
| 568 | |
| 569 | code = ktime_DisplayString(&generalTime, messageBuffer); |
| 570 | if (code) { |
| 571 | printf("bos: failed to decode restart time (%s)\n", em(code)); |
| 572 | return code; |
| 573 | } |
| 574 | printf("Server %s restarts %s\n", hostp, messageBuffer); |
| 575 | |
| 576 | code = ktime_DisplayString(&newBinaryTime, messageBuffer); |
| 577 | if (code) { |
| 578 | printf("bos: failed to decode restart time (%s)\n", em(code)); |
| 579 | return code; |
| 580 | } |
| 581 | printf("Server %s restarts for new binaries %s\n", hostp, messageBuffer); |
| 582 | |
| 583 | |
| 584 | return 0; |
| 585 | } |
| 586 | |
| 587 | static int |
| 588 | SetRestartCmd(struct cmd_syndesc *as, void *arock) |
| 589 | { |
| 590 | afs_int32 count = 0; |
| 591 | afs_int32 code; |
| 592 | struct ktime restartTime; |
| 593 | afs_int32 type = 0 ; |
| 594 | struct rx_connection *tconn; |
| 595 | |
| 596 | count = 0; |
| 597 | tconn = GetConn(as, 0); |
| 598 | if (as->parms[2].items) { |
| 599 | count++; |
| 600 | type = 1; |
| 601 | } |
| 602 | if (as->parms[3].items) { |
| 603 | count++; |
| 604 | type = 2; |
| 605 | } |
| 606 | if (count > 1) { |
| 607 | printf("bos: can't specify more than one restart time at a time\n"); |
| 608 | return -1; |
| 609 | } |
| 610 | if (count == 0) |
| 611 | type = 1; |
| 612 | |
| 613 | if ((code = ktime_ParsePeriodic(as->parms[1].items->data, &restartTime))) { |
| 614 | printf("bos: failed to parse '%s' as periodic restart time(%s)\n", |
| 615 | as->parms[1].items->data, em(code)); |
| 616 | return code; |
| 617 | } |
| 618 | |
| 619 | code = BOZO_SetRestartTime(tconn, type, (struct bozo_netKTime *) &restartTime); |
| 620 | if (code) { |
| 621 | printf("bos: failed to set restart time at server (%s)\n", em(code)); |
| 622 | return code; |
| 623 | } |
| 624 | return 0; |
| 625 | } |
| 626 | |
| 627 | static int |
| 628 | Startup(struct cmd_syndesc *as, void *arock) |
| 629 | { |
| 630 | struct rx_connection *tconn; |
| 631 | afs_int32 code; |
| 632 | struct cmd_item *ti; |
| 633 | |
| 634 | tconn = GetConn(as, 0); |
| 635 | if (as->parms[1].items == 0) { |
| 636 | code = BOZO_StartupAll(tconn); |
| 637 | if (code) |
| 638 | printf("bos: failed to startup servers (%s)\n", em(code)); |
| 639 | } else { |
| 640 | for (ti = as->parms[1].items; ti; ti = ti->next) { |
| 641 | code = BOZO_SetTStatus(tconn, ti->data, BSTAT_NORMAL1); |
| 642 | if (code) |
| 643 | printf("bos: failed to start instance %s (%s)\n", ti->data, |
| 644 | em(code)); |
| 645 | } |
| 646 | } |
| 647 | return 0; |
| 648 | } |
| 649 | |
| 650 | static int |
| 651 | Restart(struct cmd_syndesc *as, void *arock) |
| 652 | { |
| 653 | struct rx_connection *tconn; |
| 654 | afs_int32 code; |
| 655 | struct cmd_item *ti; |
| 656 | |
| 657 | tconn = GetConn(as, 0); |
| 658 | if (as->parms[2].items) { |
| 659 | |
| 660 | if (as->parms[1].items) { |
| 661 | |
| 662 | |
| 663 | printf |
| 664 | ("bos: can't specify both '-bos' and specific servers to restart.\n"); |
| 665 | return 1; |
| 666 | } |
| 667 | |
| 668 | code = BOZO_ReBozo(tconn); |
| 669 | if (code) |
| 670 | printf("bos: failed to restart bosserver (%s)\n", em(code)); |
| 671 | return code; |
| 672 | } |
| 673 | if (as->parms[1].items == 0) { |
| 674 | if (as->parms[3].items) { |
| 675 | code = BOZO_RestartAll(tconn); |
| 676 | if (code) |
| 677 | printf("bos: failed to restart servers (%s)\n", em(code)); |
| 678 | } else |
| 679 | printf("bos: To restart all processes please specify '-all'\n"); |
| 680 | } else { |
| 681 | if (as->parms[3].items) { |
| 682 | printf("bos: Can't use '-all' along with individual instances\n"); |
| 683 | } else { |
| 684 | for (ti = as->parms[1].items; ti; ti = ti->next) { |
| 685 | code = BOZO_Restart(tconn, ti->data); |
| 686 | if (code) |
| 687 | printf("bos: failed to restart instance %s (%s)\n", |
| 688 | ti->data, em(code)); |
| 689 | } |
| 690 | } |
| 691 | } |
| 692 | return 0; |
| 693 | } |
| 694 | |
| 695 | static int |
| 696 | SetCellName(struct cmd_syndesc *as, void *arock) |
| 697 | { |
| 698 | struct rx_connection *tconn; |
| 699 | afs_int32 code; |
| 700 | |
| 701 | tconn = GetConn(as, 0); |
| 702 | code = BOZO_SetCellName(tconn, as->parms[1].items->data); |
| 703 | if (code) |
| 704 | printf("bos: failed to set cell (%s)\n", em(code)); |
| 705 | return 0; |
| 706 | } |
| 707 | |
| 708 | static int |
| 709 | AddHost(struct cmd_syndesc *as, void *arock) |
| 710 | { |
| 711 | struct rx_connection *tconn; |
| 712 | afs_int32 code; |
| 713 | struct cmd_item *ti; |
| 714 | char name[MAXHOSTCHARS64]; |
| 715 | |
| 716 | tconn = GetConn(as, 0); |
| 717 | for (ti = as->parms[1].items; ti; ti = ti->next) { |
| 718 | if (as->parms[2].items) { |
| 719 | if (strlen(ti->data) > MAXHOSTCHARS64 - 3) { |
| 720 | fprintf(stderr__stderrp, "bos: host name too long\n"); |
| 721 | return E2BIG7; |
| 722 | } |
| 723 | name[0] = '['; |
| 724 | strcpy(&name[1], ti->data); |
| 725 | strcat((char *)&name, "]"); |
| 726 | code = BOZO_AddCellHost(tconn, name); |
| 727 | } else |
| 728 | code = BOZO_AddCellHost(tconn, ti->data); |
| 729 | if (code) |
| 730 | printf("bos: failed to add host %s (%s)\n", ti->data, em(code)); |
| 731 | } |
| 732 | return 0; |
| 733 | } |
| 734 | |
| 735 | static int |
| 736 | RemoveHost(struct cmd_syndesc *as, void *arock) |
| 737 | { |
| 738 | struct rx_connection *tconn; |
| 739 | afs_int32 code; |
| 740 | struct cmd_item *ti; |
| 741 | |
| 742 | tconn = GetConn(as, 0); |
| 743 | for (ti = as->parms[1].items; ti; ti = ti->next) { |
| 744 | code = BOZO_DeleteCellHost(tconn, ti->data); |
| 745 | if (code) |
| 746 | printf("bos: failed to delete host %s (%s)\n", ti->data, |
| 747 | em(code)); |
| 748 | } |
| 749 | return 0; |
| 750 | } |
| 751 | |
| 752 | static int |
| 753 | ListHosts(struct cmd_syndesc *as, void *arock) |
| 754 | { |
| 755 | struct rx_connection *tconn; |
| 756 | afs_int32 code; |
| 757 | char tbuffer[256]; |
| 758 | char *tp; |
| 759 | afs_int32 i; |
| 760 | |
| 761 | tp = tbuffer; |
| 762 | tconn = GetConn(as, 0); |
| 763 | code = BOZO_GetCellName(tconn, &tp); |
| 764 | if (code) { |
| 765 | printf("bos: failed to get cell name (%s)\n", em(code)); |
| 766 | exit(1); |
| 767 | } |
| 768 | printf("Cell name is %s\n", tbuffer); |
| 769 | for (i = 0;; i++) { |
| 770 | code = BOZO_GetCellHost(tconn, i, &tp); |
| 771 | if (code == BZDOM(39429L)) |
| 772 | break; |
| 773 | if (code != 0) { |
| 774 | printf("bos: failed to get cell host %d (%s)\n", i, em(code)); |
| 775 | exit(1); |
| 776 | } |
| 777 | printf(" Host %d is %s\n", i + 1, tbuffer); |
| 778 | } |
| 779 | return 0; |
| 780 | } |
| 781 | |
| 782 | static int |
| 783 | AddKey(struct cmd_syndesc *as, void *arock) |
| 784 | { |
| 785 | struct rx_connection *tconn; |
| 786 | afs_int32 code; |
| 787 | struct ktc_encryptionKey tkey; |
| 788 | afs_int32 temp; |
| 789 | char *tcell; |
| 790 | char cellBuffer[256]; |
| 791 | char buf[BUFSIZ1024], ver[BUFSIZ1024]; |
| 792 | |
| 793 | tconn = GetConn(as, 1); |
| 794 | memset(&tkey, 0, sizeof(struct ktc_encryptionKey)); |
| 795 | |
| 796 | if (as->parms[1].items) |
| 797 | strcpy(buf, as->parms[1].items->data); |
| 798 | else { |
| 799 | |
| 800 | code = UI_UTIL_read_pw_stringhc_UI_UTIL_read_pw_string(buf, sizeof(buf), "input key: ", 0); |
| 801 | if (code || strlen(buf) == 0) { |
| 802 | fprintf(stderr__stderrp, "Bad key: \n"); |
| 803 | exit(1); |
| 804 | } |
| 805 | code = UI_UTIL_read_pw_stringhc_UI_UTIL_read_pw_string(ver, sizeof(ver), "Retype input key: ", 0); |
| 806 | if (code || strlen(ver) == 0) { |
| 807 | fprintf(stderr__stderrp, "Bad key: \n"); |
| 808 | exit(1); |
| 809 | } |
| 810 | if (strcmp(ver, buf) != 0) { |
| 811 | fprintf(stderr__stderrp, "\nInput key mismatch\n"); |
| 812 | exit(1); |
| 813 | } |
| 814 | |
| 815 | } |
| 816 | |
| 817 | temp = atoi(as->parms[2].items->data); |
| 818 | if (temp == 999) { |
| 819 | |
| 820 | |
| 821 | |
| 822 | |
| 823 | strcpy((char *)&tkey, buf); |
| 824 | } else { |
| 825 | if (as->parms[ADDPARMOFFSET27].items) { |
| 826 | strcpy(cellBuffer, as->parms[ADDPARMOFFSET27].items->data); |
| 827 | |
| 828 | |
| 829 | |
| 830 | |
| 831 | |
| 832 | |
| 833 | ucstring(cellBuffer, cellBuffer, strlen(cellBuffer)); |
| 834 | tcell = cellBuffer; |
| 835 | } else |
| 836 | tcell = NULL((void *)0); |
| 837 | |
| 838 | |
| 839 | |
| 840 | ka_StringToKey(buf, tcell, &tkey); |
| 841 | } |
| 842 | tconn = GetConn(as, 1); |
| 843 | code = BOZO_AddKey(tconn, temp, ktc_to_bozoptr(&tkey)); |
| 844 | if (code) { |
| 845 | printf("bos: failed to set key %d (%s)\n", temp, em(code)); |
| 846 | exit(1); |
| 847 | } |
| 848 | return 0; |
| 849 | } |
| 850 | |
| 851 | static int |
| 852 | RemoveKey(struct cmd_syndesc *as, void *arock) |
| 853 | { |
| 854 | struct rx_connection *tconn; |
| 855 | afs_int32 code; |
| 856 | afs_int32 temp; |
| 857 | struct cmd_item *ti; |
| 858 | |
| 859 | tconn = GetConn(as, 0); |
| 860 | for (ti = as->parms[1].items; ti; ti = ti->next) { |
| 861 | temp = atoi(ti->data); |
| 862 | code = BOZO_DeleteKey(tconn, temp); |
| 863 | if (code) { |
| 864 | printf("bos: failed to delete key %d (%s)\n", temp, em(code)); |
| 865 | exit(1); |
| 866 | } |
| 867 | } |
| 868 | return 0; |
| 869 | } |
| 870 | |
| 871 | static int |
| 872 | ListKeys(struct cmd_syndesc *as, void *arock) |
| 873 | { |
| 874 | struct rx_connection *tconn; |
| 875 | afs_int32 code; |
| 876 | struct ktc_encryptionKey tkey; |
| 877 | afs_int32 kvno; |
| 878 | struct bozo_keyInfo keyInfo; |
| 879 | int everWorked; |
| 880 | afs_int32 i; |
| 881 | |
| 882 | tconn = GetConn(as, 1); |
| 883 | everWorked = 0; |
| 884 | for (i = 0;; i++) { |
| 885 | code = BOZO_ListKeys(tconn, i, &kvno, ktc_to_bozoptr(&tkey), &keyInfo); |
| 886 | if (code) |
| 887 | break; |
| 888 | everWorked = 1; |
| 889 | |
| 890 | if ((!ka_KeyIsZero(ktc_to_charptr(&tkey), sizeof(tkey))) && (as->parms[1].items)) { |
| 891 | printf("key %d is '", kvno); |
| 892 | ka_PrintBytes(ktc_to_charptr(&tkey), sizeof(tkey)); |
| 893 | printf("'\n"); |
| 894 | } else { |
| 895 | if (keyInfo.keyCheckSum == 0) |
| 896 | printf("key version is %d\n", kvno); |
| 897 | else |
| 898 | printf("key %d has cksum %u\n", kvno, keyInfo.keyCheckSum); |
| 899 | } |
| 900 | } |
| 901 | if (everWorked) { |
| 902 | printf("Keys last changed on %s.\n", DateOf(keyInfo.mod_sec)); |
| 903 | } |
| 904 | if (code != BZDOM(39429L)) |
| 905 | printf("bos: %s error encountered while listing keys\n", em(code)); |
| 906 | else |
| 907 | printf("All done.\n"); |
| 908 | return 0; |
| 909 | } |
| 910 | |
| 911 | static int |
| 912 | AddSUser(struct cmd_syndesc *as, void *arock) |
| 913 | { |
| 914 | struct rx_connection *tconn; |
| 915 | afs_int32 code; |
| 916 | int failed; |
| 917 | struct cmd_item *ti; |
| 918 | |
| 919 | failed = 0; |
| 920 | tconn = GetConn(as, 0); |
| 921 | for (ti = as->parms[1].items; ti; ti = ti->next) { |
| 922 | code = BOZO_AddSUser(tconn, ti->data); |
| 923 | if (code) { |
| 924 | printf("bos: failed to add user '%s' (%s)\n", ti->data, em(code)); |
| 925 | failed = 1; |
| 926 | } |
| 927 | } |
| 928 | return failed; |
| 929 | } |
| 930 | |
| 931 | static int |
| 932 | RemoveSUser(struct cmd_syndesc *as, void *arock) |
| 933 | { |
| 934 | struct rx_connection *tconn; |
| 935 | struct cmd_item *ti; |
| 936 | afs_int32 code; |
| 937 | int failed; |
| 938 | |
| 939 | failed = 0; |
| 940 | tconn = GetConn(as, 0); |
| 941 | for (ti = as->parms[1].items; ti; ti = ti->next) { |
| 942 | code = BOZO_DeleteSUser(tconn, ti->data); |
| 943 | if (code) { |
| 944 | printf("bos: failed to delete user '%s', ", ti->data); |
| 945 | if (code == ENOENT2) |
| 946 | printf("(no such user)\n"); |
| 947 | else |
| 948 | printf("(%s)\n", em(code)); |
| 949 | failed = 1; |
| 950 | } |
| 951 | } |
| 952 | return failed; |
| 953 | } |
| 954 | |
| 955 | #define NPERLINE10 10 /* dudes to print per line */ |
| 956 | static int |
| 957 | ListSUsers(struct cmd_syndesc *as, void *arock) |
| 958 | { |
| 959 | struct rx_connection *tconn; |
| 960 | int i; |
| 961 | afs_int32 code; |
| 962 | char tbuffer[256]; |
| 963 | char *tp; |
| 964 | int lastNL, printGreeting; |
| 965 | |
| 966 | tconn = GetConn(as, 0); |
| 967 | lastNL = 0; |
| 968 | printGreeting = 1; |
| 969 | for (i = 0;; i++) { |
| 970 | tp = tbuffer; |
| 971 | code = BOZO_ListSUsers(tconn, i, &tp); |
| 972 | if (code) |
| 973 | break; |
| 974 | if (printGreeting) { |
| 975 | printGreeting = 0; |
| 976 | printf("SUsers are: "); |
| 977 | } |
| 978 | printf("%s ", tbuffer); |
| 979 | if ((i % NPERLINE10) == NPERLINE10 - 1) { |
| 980 | printf("\n"); |
| 981 | lastNL = 1; |
| 982 | } else |
| 983 | lastNL = 0; |
| 984 | } |
| 985 | if (code != 1) { |
| 986 | |
| 987 | printf("bos: failed to retrieve super-user list (%s)\n", em(code)); |
| 988 | return code; |
| 989 | } |
| 990 | if (lastNL == 0) |
| 991 | printf("\n"); |
| 992 | return 0; |
| 993 | } |
| 994 | |
| 995 | static int |
| 996 | StatServer(struct cmd_syndesc *as, void *arock) |
| 997 | { |
| 998 | struct rx_connection *tconn; |
| 999 | afs_int32 code; |
| 1000 | int i; |
| 1001 | char ibuffer[BOZO_BSSIZE256]; |
| 1002 | char *tp; |
| 1003 | int int32p; |
| 1004 | |
| 1005 | |
| 1006 | int32p = (as->parms[2].items != 0 ? 2 : 0); |
| 1007 | |
| 1008 | |
| 1009 | if (as->parms[1].items) |
| 1010 | return IStatServer(as, int32p); |
| 1011 | |
| 1012 | tconn = GetConn(as, 0); |
| 1013 | for (i = 0;; i++) { |
| 1014 | |
| 1015 | tp = ibuffer; |
| 1016 | code = BOZO_EnumerateInstance(tconn, i, &tp); |
| 1017 | if (code == BZDOM(39429L)) |
| 1018 | break; |
| 1019 | if (code) { |
| 1020 | printf("bos: failed to contact host's bosserver (%s).\n", |
| 1021 | em(code)); |
| 1022 | break; |
| 1023 | } |
| 1024 | DoStat(ibuffer, tconn, int32p, (i == 0)); |
| 1025 | } |
| 1026 | return 0; |
| 1027 | } |
| 1028 | |
| 1029 | static int |
| 1030 | CreateServer(struct cmd_syndesc *as, void *arock) |
| 1031 | { |
| 1032 | struct rx_connection *tconn; |
| 1033 | afs_int32 code; |
| 1034 | char *parms[6]; |
| 1035 | struct cmd_item *ti; |
| 1036 | int i; |
| 1037 | char *type, *name, *notifier = NONOTIFIER"__NONOTIFIER__"; |
| 1038 | |
| 1039 | tconn = GetConn(as, 0); |
| 1040 | for (i = 0; i < 6; i++) |
| 1041 | parms[i] = ""; |
| 1042 | for (i = 0, ti = as->parms[3].items; (ti && i < 6); ti = ti->next, i++) { |
| 1043 | parms[i] = ti->data; |
| 1044 | } |
| 1045 | name = as->parms[1].items->data; |
| 1046 | type = as->parms[2].items->data; |
| 1047 | if ((ti = as->parms[4].items)) { |
| 1048 | notifier = ti->data; |
| 1049 | } |
| 1050 | code = |
| 1051 | BOZO_CreateBnode(tconn, type, name, parms[0], parms[1], parms[2], |
| 1052 | parms[3], parms[4], notifier); |
| 1053 | if (code) { |
| 1054 | printf |
| 1055 | ("bos: failed to create new server instance %s of type '%s' (%s)\n", |
| 1056 | name, type, em(code)); |
| 1057 | } |
| 1058 | return code; |
| 1059 | } |
| 1060 | |
| 1061 | static int |
| 1062 | DeleteServer(struct cmd_syndesc *as, void *arock) |
| 1063 | { |
| 1064 | struct rx_connection *tconn; |
| 1065 | afs_int32 code; |
| 1066 | struct cmd_item *ti; |
| 1067 | |
| 1068 | code = 0; |
| 1069 | tconn = GetConn(as, 0); |
| 1070 | for (ti = as->parms[1].items; ti; ti = ti->next) { |
| 1071 | code = BOZO_DeleteBnode(tconn, ti->data); |
| 1072 | if (code) { |
| 1073 | if (code == BZBUSY(39426L)) |
| 1074 | printf("bos: can't delete running instance '%s'\n", ti->data); |
| 1075 | else |
| 1076 | printf("bos: failed to delete instance '%s' (%s)\n", ti->data, |
| 1077 | em(code)); |
| 1078 | } |
| 1079 | } |
| 1080 | return code; |
| 1081 | } |
| 1082 | |
| 1083 | static int |
| 1084 | StartServer(struct cmd_syndesc *as, void *arock) |
| 1085 | { |
| 1086 | struct rx_connection *tconn; |
| 1087 | afs_int32 code; |
| 1088 | struct cmd_item *ti; |
| 1089 | |
| 1090 | code = 0; |
| 1091 | tconn = GetConn(as, 0); |
| 1092 | for (ti = as->parms[1].items; ti; ti = ti->next) { |
| 1093 | code = BOZO_SetStatus(tconn, ti->data, BSTAT_NORMAL1); |
| 1094 | if (code) |
| 1095 | printf("bos: failed to start instance '%s' (%s)\n", ti->data, |
| 1096 | em(code)); |
| 1097 | } |
| 1098 | return code; |
| 1099 | } |
| 1100 | |
| 1101 | static int |
| 1102 | StopServer(struct cmd_syndesc *as, void *arock) |
| 1103 | { |
| 1104 | struct rx_connection *tconn; |
| 1105 | afs_int32 code; |
| 1106 | struct cmd_item *ti; |
| 1107 | |
| 1108 | code = 0; |
| 1109 | tconn = GetConn(as, 0); |
| 1110 | for (ti = as->parms[1].items; ti; ti = ti->next) { |
| 1111 | code = BOZO_SetStatus(tconn, ti->data, BSTAT_SHUTDOWN0); |
| 1112 | if (code) |
| 1113 | printf("bos: failed to change stop instance '%s' (%s)\n", |
| 1114 | ti->data, em(code)); |
| 1115 | } |
| 1116 | if (as->parms[8].items) { |
| 1117 | code = BOZO_WaitAll(tconn); |
| 1118 | if (code) |
| 1119 | printf("bos: can't wait for processes to shutdown (%s)\n", |
| 1120 | em(code)); |
| 1121 | } |
| 1122 | return code; |
| 1123 | } |
| 1124 | |
| 1125 | #define PARMBUFFERSSIZE32 32 |
| 1126 | |
| 1127 | static afs_int32 |
| 1128 | DoSalvage(struct rx_connection * aconn, char * aparm1, char * aparm2, |
| 1129 | char * aoutName, afs_int32 showlog, char * parallel, |
| 1130 | char * atmpDir, char * orphans, int dafs, |
| 1131 | struct MRAFSSalvageParms * mrafsParm) |
| 1132 | { |
| 1133 | afs_int32 code; |
| 1134 | char *parms[6]; |
| 1135 | char buffer; |
| 1136 | char tbuffer[BOZO_BSSIZE256]; |
| 1137 | struct bozo_status istatus; |
| 1138 | struct rx_call *tcall; |
| 1139 | char *tp; |
| 1140 | FILE *outFile; |
| 1141 | int closeIt; |
| 1142 | char partName[20]; |
| 1143 | char pbuffer[PARMBUFFERSSIZE32]; |
| 1144 | afs_int32 partNumber; |
| 1145 | char *notifier = NONOTIFIER"__NONOTIFIER__"; |
| 1146 | |
| 1147 | |
| 1148 | |
| 1149 | if (aparm1) { |
| 1150 | partNumber = volutil_GetPartitionID(aparm1); |
| 1151 | if (partNumber < 0) { |
| 1152 | printf("bos: could not parse partition ID '%s'\n", aparm1); |
| 1153 | return EINVAL22; |
| 1154 | } |
| 1155 | tp = volutil_PartitionName(partNumber); |
| 1156 | if (!tp) { |
| 1157 | printf("bos: internal error parsing partition ID '%s'\n", aparm1); |
| 1158 | return EINVAL22; |
| 1159 | } |
| 1160 | strcpy(partName, tp); |
| 1161 | } else |
| 1162 | partName[0] = 0; |
| 1163 | |
| 1164 | |
| 1165 | if (aoutName) { |
| 1166 | outFile = fopen(aoutName, "w"); |
| 1167 | if (!outFile) { |
| 1168 | printf("bos: can't open specified SalvageLog file '%s'\n", |
| 1169 | aoutName); |
| 1170 | return ENOENT2; |
| 1171 | } |
| 1172 | closeIt = 1; |
| 1173 | } else { |
| 1174 | outFile = stdout__stdoutp; |
| 1175 | closeIt = 0; |
| 1176 | } |
| 1177 | |
| 1178 | for (code = 2; code < 6; code++) |
| 1179 | parms[code] = ""; |
| 1180 | if (!aparm2) |
| 1181 | aparm2 = ""; |
| 1182 | |
| 1183 | |
| 1184 | if (*aparm2 != 0) { |
| 1185 | |
| 1186 | if (dafs) { |
| 1187 | |
| 1188 | |
| 1189 | |
| 1190 | strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALSRV_FILEPATH"/usr/afs" "/bin" "/" "salvageserver", BOZO_BSSIZE256); |
| 1191 | |
| 1192 | if ((strlen(tbuffer) + 9 + strlen(partName) + 1 + strlen(aparm2) + |
| 1193 | 1) > BOZO_BSSIZE256) { |
| 1194 | printf("bos: command line too big\n"); |
| 1195 | return (E2BIG7); |
| 1196 | } |
| 1197 | |
| 1198 | strcat(tbuffer, " -client "); |
| 1199 | strcat(tbuffer, partName); |
| 1200 | strcat(tbuffer, " "); |
| 1201 | strcat(tbuffer, aparm2); |
| 1202 | } else { |
| 1203 | strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH"/usr/afs" "/bin" "/" "salvager", BOZO_BSSIZE256); |
| 1204 | |
| 1205 | if ((strlen(tbuffer) + 1 + strlen(partName) + 1 + strlen(aparm2) + |
| 1206 | 1) > BOZO_BSSIZE256) { |
| 1207 | printf("bos: command line too big\n"); |
| 1208 | return (E2BIG7); |
| 1209 | } |
| 1210 | |
| 1211 | strcat(tbuffer, " "); |
| 1212 | strcat(tbuffer, partName); |
| 1213 | strcat(tbuffer, " "); |
| 1214 | strcat(tbuffer, aparm2); |
| 1215 | } |
| 1216 | } else { |
| 1217 | |
| 1218 | strncpy(tbuffer, AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH"/usr/afs" "/bin" "/" "salvager", BOZO_BSSIZE256); |
| 1219 | if ((strlen(tbuffer) + 4 + strlen(partName) + 1) > BOZO_BSSIZE256) { |
| 1220 | printf("bos: command line too big\n"); |
| 1221 | return (E2BIG7); |
| 1222 | } |
| 1223 | strcat(tbuffer, " -force "); |
| 1224 | strcat(tbuffer, partName); |
| 1225 | } |
| 1226 | |
| 1227 | |
| 1228 | |
| 1229 | |
| 1230 | |
| 1231 | |
| 1232 | if (!dafs || (*aparm2 == 0)) { |
| 1233 | |
| 1234 | if (parallel != NULL((void *)0)) { |
| 1235 | if ((strlen(tbuffer) + 11 + strlen(parallel) + 1) > BOZO_BSSIZE256) { |
| 1236 | printf("bos: command line too big\n"); |
| 1237 | return (E2BIG7); |
| 1238 | } |
| 1239 | strcat(tbuffer, " -parallel "); |
| 1240 | strcat(tbuffer, parallel); |
| 1241 | } |
| 1242 | |
| 1243 | |
| 1244 | if (atmpDir != NULL((void *)0)) { |
| 1245 | if ((strlen(tbuffer) + 9 + strlen(atmpDir) + 1) > BOZO_BSSIZE256) { |
| 1246 | printf("bos: command line too big\n"); |
| 1247 | return (E2BIG7); |
| 1248 | } |
| 1249 | strcat(tbuffer, " -tmpdir "); |
| 1250 | strcat(tbuffer, atmpDir); |
| 1251 | } |
| 1252 | |
| 1253 | |
| 1254 | if (orphans != NULL((void *)0)) { |
| 1255 | if ((strlen(tbuffer) + 10 + strlen(orphans) + 1) > BOZO_BSSIZE256) { |
| 1256 | printf("bos: command line too big\n"); |
| 1257 | return (E2BIG7); |
| 1258 | } |
| 1259 | strcat(tbuffer, " -orphans "); |
| 1260 | strcat(tbuffer, orphans); |
| 1261 | } |
| 1262 | |
| 1263 | if (mrafsParm->Optdebug) |
| 1264 | strcat(tbuffer, " -debug"); |
| 1265 | if (mrafsParm->Optnowrite) |
| 1266 | strcat(tbuffer, " -nowrite"); |
| 1267 | if (mrafsParm->Optforce) |
| 1268 | strcat(tbuffer, " -force"); |
| 1269 | if (mrafsParm->Optoktozap) |
| 1270 | strcat(tbuffer, " -oktozap"); |
| 1271 | if (mrafsParm->Optrootfiles) |
| 1272 | strcat(tbuffer, " -rootfiles"); |
| 1273 | if (mrafsParm->Optsalvagedirs) |
| 1274 | strcat(tbuffer, " -salvagedirs"); |
| 1275 | if (mrafsParm->Optblockreads) |
| 1276 | strcat(tbuffer, " -blockreads"); |
| 1277 | if (mrafsParm->OptListResidencies) |
| 1278 | strcat(tbuffer, " -ListResidencies"); |
| 1279 | if (mrafsParm->OptSalvageRemote) |
| 1280 | strcat(tbuffer, " -SalvageRemote"); |
| 1281 | if (mrafsParm->OptSalvageArchival) |
| 1282 | strcat(tbuffer, " -SalvageArchival"); |
| 1283 | if (mrafsParm->OptIgnoreCheck) |
| 1284 | strcat(tbuffer, " -IgnoreCheck"); |
| 1285 | if (mrafsParm->OptForceOnLine) |
| 1286 | strcat(tbuffer, " -ForceOnLine"); |
| 1287 | if (mrafsParm->OptUseRootDirACL) |
| 1288 | strcat(tbuffer, " -UseRootDirACL"); |
| 1289 | if (mrafsParm->OptTraceBadLinkCounts) |
| 1290 | strcat(tbuffer, " -TraceBadLinkCounts"); |
| 1291 | if (mrafsParm->OptDontAskFS) |
| 1292 | strcat(tbuffer, " -DontAskFS"); |
| 1293 | if (mrafsParm->OptLogLevel) { |
| 1294 | sprintf(pbuffer, " -LogLevel %ld", afs_printable_int32_ld(mrafsParm->OptLogLevel)); |
| 1295 | strcat(tbuffer, pbuffer); |
| 1296 | } |
| 1297 | if (mrafsParm->OptRxDebug) |
| 1298 | strcat(tbuffer, " -rxdebug"); |
| 1299 | if (mrafsParm->OptResidencies) { |
| 1300 | sprintf(pbuffer, " -Residencies %lu", |
| 1301 | afs_printable_uint32_lu(mrafsParm->OptResidencies)); |
| 1302 | strcat(tbuffer, pbuffer); |
| 1303 | } |
| 1304 | } |
| 1305 | |
| 1306 | parms[0] = tbuffer; |
| 1307 | parms[1] = "now"; |
| 1308 | code = |
| 1309 | BOZO_CreateBnode(aconn, "cron", "salvage-tmp", parms[0], parms[1], |
| 1310 | parms[2], parms[3], parms[4], notifier); |
| 1311 | if (code) { |
| 1312 | printf("bos: failed to start 'salvager' (%s)\n", em(code)); |
| 1313 | goto done; |
| 1314 | } |
| 1315 | |
| 1316 | while (1) { |
| 1317 | IOMGR_Sleep(5); |
| 1318 | tp = tbuffer; |
| 1319 | code = BOZO_GetInstanceInfo(aconn, "salvage-tmp", &tp, &istatus); |
| 1320 | if (code) |
| 1321 | break; |
| 1322 | printf("bos: waiting for salvage to complete.\n"); |
| 1323 | } |
| 1324 | if (code != BZNOENT(39425L)) { |
| 1325 | printf("bos: salvage failed (%s)\n", em(code)); |
| 1326 | goto done; |
| 1327 | } |
| 1328 | code = 0; |
| 1329 | |
| 1330 | |
| 1331 | printf("bos: salvage completed\n"); |
| 1332 | if (aoutName || showlog) { |
| 1333 | fprintf(outFile, "SalvageLog:\n"); |
| 1334 | tcall = rx_NewCall(aconn); |
| 1335 | |
| 1336 | code = |
| 1337 | StartBOZO_GetLog(tcall, AFSDIR_CANONICAL_SERVER_SLVGLOG_FILEPATH"/usr/afs" "/logs" "/" "SalvageLog"); |
| 1338 | if (code) { |
| 1339 | rx_EndCall(tcall, code); |
| 1340 | goto done; |
| 1341 | } |
| 1342 | |
| 1343 | while (1) { |
| 1344 | code = rx_Read(tcall, &buffer, 1)rx_ReadProc(tcall, &buffer, 1); |
| 1345 | if (code != 1) |
| 1346 | break; |
| 1347 | putc(buffer, outFile)(!__isthreaded ? __sputc(buffer, outFile) : (putc)(buffer, outFile )); |
| 1348 | if (buffer == 0) |
| 1349 | break; |
| 1350 | } |
| 1351 | code = rx_EndCall(tcall, 0); |
| 1352 | |
| 1353 | } |
| 1354 | |
| 1355 | done: |
| 1356 | if (closeIt && outFile) |
| 1357 | fclose(outFile); |
| 1358 | return code; |
| 1359 | } |
| 1360 | |
| 1361 | static int |
| 1362 | GetLogCmd(struct cmd_syndesc *as, void *arock) |
| 1363 | { |
| 1364 | struct rx_connection *tconn; |
| 1365 | struct rx_call *tcall; |
| 1366 | afs_int32 code; |
| 1367 | char buffer; |
| 1368 | int error; |
| 1369 | |
| 1370 | printf("Fetching log file '%s'...\n", as->parms[1].items->data); |
| 1371 | tconn = GetConn(as, 0); |
| 1372 | tcall = rx_NewCall(tconn); |
| 1373 | code = StartBOZO_GetLog(tcall, as->parms[1].items->data); |
| 1374 | if (code) { |
| 1375 | rx_EndCall(tcall, code); |
| 1376 | goto done; |
| 1377 | } |
| 1378 | |
| 1379 | error = 0; |
| 1380 | while (1) { |
| 1381 | code = rx_Read(tcall, &buffer, 1)rx_ReadProc(tcall, &buffer, 1); |
| 1382 | if (code != 1) { |
| 1383 | error = EIO5; |
| 1384 | break; |
| 1385 | } |
| 1386 | if (buffer == 0) |
| 1387 | break; |
| 1388 | putchar(buffer)(!__isthreaded ? __sputc(buffer, __stdoutp) : (putc)(buffer, __stdoutp )); |
| 1389 | } |
| 1390 | code = rx_EndCall(tcall, error); |
| 1391 | |
| 1392 | |
| 1393 | done: |
| 1394 | if (code) |
| 1395 | afs_com_err("bos", code, "(while reading log)"); |
| 1396 | return code; |
| 1397 | } |
| 1398 | |
| 1399 | static int |
| 1400 | IsDAFS(struct rx_connection *aconn) |
| 1401 | { |
| 1402 | char buffer[BOZO_BSSIZE256]; |
| 1403 | char *tp; |
| 1404 | struct bozo_status istatus; |
| 1405 | afs_int32 code; |
| 1406 | |
| 1407 | tp = &buffer[0]; |
| 1408 | |
| 1409 | code = BOZO_GetInstanceInfo(aconn, "dafs", &tp, &istatus); |
| 1410 | if (code) { |
| 1411 | |
| 1412 | return 0; |
| 1413 | } |
| 1414 | if (istatus.goal) { |
| 1415 | |
| 1416 | return 1; |
| 1417 | } |
| 1418 | |
| 1419 | |
| 1420 | |
| 1421 | |
| 1422 | |
| 1423 | |
| 1424 | |
| 1425 | |
| 1426 | return 0; |
| 1427 | } |
| 1428 | |
| 1429 | static int |
| 1430 | SalvageCmd(struct cmd_syndesc *as, void *arock) |
| 1431 | { |
| 1432 | struct rx_connection *tconn; |
| 1433 | afs_int32 code, rc, i; |
| 1434 | char *outName; |
| 1435 | char tname[BOZO_BSSIZE256]; |
| 1436 | afs_int32 newID; |
| 1437 | extern struct ubik_client *cstruct; |
| 1438 | afs_int32 curGoal, showlog = 0, dafs = 0, mrafs = 0; |
| 1439 | char *parallel; |
| 1440 | char *tmpDir; |
| 1441 | char *orphans; |
| 1442 | char *tp; |
| 1443 | char * serviceName; |
| 1444 | struct MRAFSSalvageParms mrafsParm; |
| 1445 | |
| 1446 | memset(&mrafsParm, 0, sizeof(mrafsParm)); |
| 1447 | |
| 1448 | |
| 1449 | tconn = GetConn(as, 0); |
| 1450 | |
| 1451 | tp = &tname[0]; |
| 1452 | |
| 1453 | |
| 1454 | if (IsDAFS(tconn)) { |
| |
| 1455 | dafs = 1; |
| 1456 | serviceName = "dafs"; |
| 1457 | |
| 1458 | |
| 1459 | if ((code = BOZO_GetInstanceParm(tconn, serviceName, 4, &tp) == 0)) |
| 1460 | mrafs = 1; |
| 1461 | } else { |
| 1462 | serviceName = "fs"; |
| 1463 | |
| 1464 | |
| 1465 | if ((code = BOZO_GetInstanceParm(tconn, serviceName, 3, &tp) == 0)) |
| |
| 1466 | mrafs = 1; |
| 1467 | } |
| 1468 | |
| 1469 | |
| 1470 | |
| 1471 | if (!as->parms[1].items && as->parms[2].items) { |
| |
| 1472 | printf("bos: must specify partition to salvage individual volume.\n"); |
| 1473 | return -1; |
| 1474 | } |
| 1475 | if (as->parms[5].items && as->parms[3].items) { |
| |
| 1476 | printf("bos: can not specify both -file and -showlog.\n"); |
| 1477 | return -1; |
| 1478 | } |
| 1479 | if (as->parms[4].items && (as->parms[1].items || as->parms[2].items)) { |
| |
| 1480 | printf("bos: can not specify -all with other flags.\n"); |
| 1481 | return -1; |
| 1482 | } |
| 1483 | |
| 1484 | |
| 1485 | if (as->parms[3].items) |
| |
| 1486 | outName = as->parms[3].items->data; |
| 1487 | else |
| 1488 | outName = NULL((void *)0); |
| 1489 | |
| 1490 | if (as->parms[5].items) |
| |
| 1491 | showlog = 1; |
| 1492 | |
| 1493 | |
| 1494 | parallel = NULL((void *)0); |
| 1495 | if (as->parms[6].items) |
| |
| 1496 | parallel = as->parms[6].items->data; |
| 1497 | |
| 1498 | |
| 1499 | tmpDir = NULL((void *)0); |
| 1500 | if (as->parms[7].items) |
| |
| 1501 | tmpDir = as->parms[7].items->data; |
| 1502 | |
| 1503 | |
| 1504 | orphans = NULL((void *)0); |
| 1505 | if (as->parms[8].items) { |
| |
| 1506 | if (mrafs) { |
| 1507 | printf("Can't specify -orphans for MR-AFS fileserver\n"); |
| 1508 | return EINVAL22; |
| 1509 | } |
| 1510 | orphans = as->parms[8].items->data; |
| 1511 | } |
| 1512 | |
| 1513 | if (dafs) { |
| |
| 1514 | if (!as->parms[9].items) { |
| 1515 | printf("This is a demand attach fileserver. Are you sure you want to proceed with a manual salvage?\n"); |
| 1516 | printf("must specify -forceDAFS flag in order to proceed.\n"); |
| 1517 | return EINVAL22; |
| 1518 | } |
| 1519 | } |
| 1520 | |
| 1521 | if (mrafs) { |
| |
| 1522 | if (as->parms[MRAFS_OFFSET10].items) |
| |
| 1523 | mrafsParm.Optdebug = 1; |
| 1524 | if (as->parms[MRAFS_OFFSET10 + 1].items) |
| |
| 1525 | mrafsParm.Optnowrite = 1; |
| 1526 | if (as->parms[MRAFS_OFFSET10 + 2].items) |
| |
| 1527 | mrafsParm.Optforce = 1; |
| 1528 | if (as->parms[MRAFS_OFFSET10 + 3].items) |
| |
| 1529 | mrafsParm.Optoktozap = 1; |
| 1530 | if (as->parms[MRAFS_OFFSET10 + 4].items) |
| |
| 1531 | mrafsParm.Optrootfiles = 1; |
| 1532 | if (as->parms[MRAFS_OFFSET10 + 5].items) |
| |
| 1533 | mrafsParm.Optsalvagedirs = 1; |
| 1534 | if (as->parms[MRAFS_OFFSET10 + 6].items) |
| |
| 1535 | mrafsParm.Optblockreads = 1; |
| 1536 | if (as->parms[MRAFS_OFFSET10 + 7].items) |
| |
| 1537 | mrafsParm.OptListResidencies = 1; |
| 1538 | if (as->parms[MRAFS_OFFSET10 + 8].items) |
| |
| 1539 | mrafsParm.OptSalvageRemote = 1; |
| 1540 | if (as->parms[MRAFS_OFFSET10 + 9].items) |
| |
| 1541 | mrafsParm.OptSalvageArchival = 1; |
| 1542 | if (as->parms[MRAFS_OFFSET10 + 10].items) |
| |
| 1543 | mrafsParm.OptIgnoreCheck = 1; |
| 1544 | if (as->parms[MRAFS_OFFSET10 + 11].items) |
| |
| 1545 | mrafsParm.OptForceOnLine = 1; |
| 1546 | if (as->parms[MRAFS_OFFSET10 + 12].items) |
| |
| 1547 | mrafsParm.OptUseRootDirACL = 1; |
| 1548 | if (as->parms[MRAFS_OFFSET10 + 13].items) |
| |
| 1549 | mrafsParm.OptTraceBadLinkCounts = 1; |
| 1550 | if (as->parms[MRAFS_OFFSET10 + 14].items) |
| |
| 1551 | mrafsParm.OptDontAskFS = 1; |
| 1552 | if (as->parms[MRAFS_OFFSET10 + 15].items) |
| |
| 1553 | mrafsParm.OptLogLevel = |
| 1554 | atoi(as->parms[MRAFS_OFFSET10 + 15].items->data); |
| 1555 | if (as->parms[MRAFS_OFFSET10 + 16].items) |
| |
| 1556 | mrafsParm.OptRxDebug = 1; |
| 1557 | if (as->parms[MRAFS_OFFSET10 + 17].items) { |
| |
| 1558 | if (as->parms[MRAFS_OFFSET10 + 8].items |
| |
| 1559 | || as->parms[MRAFS_OFFSET10 + 9].items) { |
| 1560 | printf |
| 1561 | ("Can't specify -Residencies with -SalvageRemote or -SalvageArchival\n"); |
| 1562 | return EINVAL22; |
| 1563 | } |
| 1564 | code = |
| 1565 | util_GetUInt32(as->parms[MRAFS_OFFSET10 + 17].items->data, |
| 1566 | &mrafsParm.OptResidencies); |
| 1567 | if (code) { |
| |
| 1568 | printf("bos: '%s' is not a valid residency mask.\n", |
| 1569 | as->parms[MRAFS_OFFSET10 + 13].items->data); |
| 33 | Access to field 'data' results in a dereference of a null pointer (loaded from field 'items') |
|
| 1570 | return code; |
| 1571 | } |
| 1572 | } |
| 1573 | } else { |
| 1574 | int stop = 0; |
| 1575 | |
| 1576 | for (i = MRAFS_OFFSET10; i < ADDPARMOFFSET27; i++) { |
| 1577 | if (as->parms[i].items) { |
| 1578 | printf(" %s only possible for MR-AFS fileserver.\n", |
| 1579 | as->parms[i].name); |
| 1580 | stop = 1; |
| 1581 | } |
| 1582 | } |
| 1583 | if (stop) |
| 1584 | exit(1); |
| 1585 | } |
| 1586 | |
| 1587 | if (as->parms[4].items) { |
| 1588 | |
| 1589 | curGoal = GetServerGoal(tconn, serviceName); |
| 1590 | if (curGoal == BSTAT_NORMAL1) { |
| 1591 | printf("bos: shutting down '%s'.\n", serviceName); |
| 1592 | code = BOZO_SetTStatus(tconn, serviceName, BSTAT_SHUTDOWN0); |
| 1593 | if (code) { |
| 1594 | printf("bos: failed to stop '%s' (%s)\n", serviceName, em(code)); |
| 1595 | return code; |
| 1596 | } |
| 1597 | code = BOZO_WaitAll(tconn); |
| 1598 | if (code) |
| 1599 | printf |
| 1600 | ("bos: failed to wait for file server shutdown, continuing.\n"); |
| 1601 | } |
| 1602 | |
| 1603 | printf("Starting salvage.\n"); |
| 1604 | rc = DoSalvage(tconn, NULL((void *)0), NULL((void *)0), outName, showlog, parallel, tmpDir, |
| 1605 | orphans, dafs, &mrafsParm); |
| 1606 | if (curGoal == BSTAT_NORMAL1) { |
| 1607 | printf("bos: restarting %s.\n", serviceName); |
| 1608 | code = BOZO_SetTStatus(tconn, serviceName, BSTAT_NORMAL1); |
| 1609 | if (code) { |
| 1610 | printf("bos: failed to restart '%s' (%s)\n", serviceName, em(code)); |
| 1611 | return code; |
| 1612 | } |
| 1613 | } |
| 1614 | if (rc) |
| 1615 | return rc; |
| 1616 | } else if (!as->parms[2].items) { |
| 1617 | if (!as->parms[1].items) { |
| 1618 | printf |
| 1619 | ("bos: must specify -all switch to salvage all partitions.\n"); |
| 1620 | return -1; |
| 1621 | } |
| 1622 | if (volutil_GetPartitionID(as->parms[1].items->data) < 0) { |
| 1623 | |
| 1624 | |
| 1625 | |
| 1626 | printf("bos: can't interpret %s as partition ID.\n", |
| 1627 | as->parms[1].items->data); |
| 1628 | return -1; |
| 1629 | } |
| 1630 | curGoal = GetServerGoal(tconn, serviceName); |
| 1631 | |
| 1632 | if (curGoal == BSTAT_NORMAL1) { |
| 1633 | printf("bos: shutting down '%s'.\n", serviceName); |
| 1634 | code = BOZO_SetTStatus(tconn, serviceName, BSTAT_SHUTDOWN0); |
| 1635 | if (code) { |
| 1636 | printf("bos: can't stop '%s' (%s)\n", serviceName, em(code)); |
| 1637 | return code; |
| 1638 | } |
| 1639 | code = BOZO_WaitAll(tconn); |
| 1640 | if (code) |
| 1641 | printf |
| 1642 | ("bos: failed to wait for file server shutdown, continuing.\n"); |
| 1643 | } |
| 1644 | |
| 1645 | printf("Starting salvage.\n"); |
| 1646 | rc = DoSalvage(tconn, as->parms[1].items->data, NULL((void *)0), outName, |
| 1647 | showlog, parallel, tmpDir, orphans, dafs, &mrafsParm); |
| 1648 | if (curGoal == BSTAT_NORMAL1) { |
| 1649 | printf("bos: restarting '%s'.\n", serviceName); |
| 1650 | code = BOZO_SetTStatus(tconn, serviceName, BSTAT_NORMAL1); |
| 1651 | if (code) { |
| 1652 | printf("bos: failed to restart '%s' (%s)\n", serviceName, em(code)); |
| 1653 | return code; |
| 1654 | } |
| 1655 | } |
| 1656 | if (rc) |
| 1657 | return rc; |
| 1658 | } else { |
| 1659 | |
| 1660 | |
| 1661 | |
| 1662 | char *tmpname; |
| 1663 | afs_int32 err; |
| 1664 | const char *confdir; |
| 1665 | int localauth; |
| 1666 | |
| 1667 | if (as->parms[ADDPARMOFFSET27].items) |
| 1668 | tmpname = as->parms[ADDPARMOFFSET27].items->data; |
| 1669 | else |
| 1670 | tmpname = NULL((void *)0); |
| 1671 | |
| 1672 | localauth = (as->parms[ADDPARMOFFSET27 + 2].items != 0); |
| 1673 | confdir = |
| 1674 | (localauth ? AFSDIR_SERVER_ETC_DIRPATHgetDirPath(AFSDIR_SERVER_ETC_DIRPATH_ID) : |
| 1675 | AFSDIR_CLIENT_ETC_DIRPATHgetDirPath(AFSDIR_CLIENT_ETC_DIRPATH_ID)); |
| 1676 | code = vsu_ClientInit( 1, confdir, tmpname, |
| 1677 | 0, &cstruct, (int (*)())0); |
| 1678 | if (code == 0) { |
| 1679 | newID = vsu_GetVolumeID(as->parms[2].items->data, cstruct, &err); |
| 1680 | if (newID == 0) { |
| 1681 | printf("bos: can't interpret %s as volume name or ID\n", |
| 1682 | as->parms[2].items->data); |
| 1683 | return -1; |
| 1684 | } |
| 1685 | sprintf(tname, "%u", newID); |
| 1686 | } else { |
| 1687 | printf |
| 1688 | ("bos: can't initialize volume system client (code %d), trying anyway.\n", |
| 1689 | code); |
| 1690 | strncpy(tname, as->parms[2].items->data, sizeof(tname)); |
| 1691 | } |
| 1692 | if (volutil_GetPartitionID(as->parms[1].items->data) < 0) { |
| 1693 | |
| 1694 | |
| 1695 | |
| 1696 | printf("bos: can't interpret %s as partition ID.\n", |
| 1697 | as->parms[1].items->data); |
| 1698 | return -1; |
| 1699 | } |
| 1700 | printf("Starting salvage.\n"); |
| 1701 | rc = DoSalvage(tconn, as->parms[1].items->data, tname, outName, |
| 1702 | showlog, parallel, tmpDir, orphans, dafs, &mrafsParm); |
| 1703 | if (rc) |
| 1704 | return rc; |
| 1705 | } |
| 1706 | return 0; |
| 1707 | } |
| 1708 | |
| 1709 | static int |
| 1710 | IStatServer(struct cmd_syndesc *as, int int32p) |
| 1711 | { |
| 1712 | struct rx_connection *tconn; |
| 1713 | struct cmd_item *ti; |
| 1714 | int firstTime = 1; |
| 1715 | |
| 1716 | tconn = GetConn(as, 0); |
| 1717 | for (ti = as->parms[1].items; ti; ti = ti->next) { |
| 1718 | DoStat(ti->data, tconn, int32p, firstTime); |
| 1719 | firstTime = 0; |
| 1720 | } |
| 1721 | return 0; |
| 1722 | } |
| 1723 | |
| 1724 | static int |
| 1725 | DoStat(IN char *aname, |
| 1726 | IN struct rx_connection *aconn, |
| 1727 | IN int aint32p, |
| 1728 | IN int firstTime) |
| 1729 | { |
| 1730 | afs_int32 temp; |
| 1731 | char buffer[500]; |
| 1732 | afs_int32 code; |
| 1733 | afs_int32 i; |
| 1734 | struct bozo_status istatus; |
| 1735 | char *tp; |
| 1736 | char *is1, *is2, *is3, *is4; |
| 1737 | |
| 1738 | tp = buffer; |
| 1739 | code = BOZO_GetInstanceInfo(aconn, aname, &tp, &istatus); |
| 1740 | if (code) { |
| 1741 | printf("bos: failed to get instance info for '%s' (%s)\n", aname, |
| 1742 | em(code)); |
| 1743 | return -1; |
| 1744 | } |
| 1745 | if (firstTime && aint32p && (istatus.flags & BOZO_BADDIRACCESS4)) |
| 1746 | printf |
| 1747 | ("Bosserver reports inappropriate access on server directories\n"); |
| 1748 | printf("Instance %s, ", aname); |
| 1749 | if (aint32p) |
| 1750 | printf("(type is %s) ", buffer); |
| 1751 | if (istatus.fileGoal == istatus.goal) { |
| 1752 | if (!istatus.goal) |
| 1753 | printf("disabled, "); |
| 1754 | } else { |
| 1755 | if (istatus.fileGoal) |
| 1756 | printf("temporarily disabled, "); |
| 1757 | else |
| 1758 | printf("temporarily enabled, "); |
| 1759 | } |
| 1760 | |
| 1761 | if (istatus.flags & BOZO_ERRORSTOP2) |
| 1762 | printf("stopped for too many errors, "); |
| 1763 | if (istatus.flags & BOZO_HASCORE1) |
| 1764 | printf("has core file, "); |
| 1765 | |
| 1766 | tp = buffer; |
| 1767 | code = BOZO_GetStatus(aconn, aname, &temp, &tp); |
| 1768 | if (code) |
| 1769 | printf("bos: failed to get status for instance '%s' (%s)\n", aname, |
| 1770 | em(code)); |
| 1771 | else { |
| 1772 | printf("currently "); |
| 1773 | if (temp == BSTAT_NORMAL1) |
| 1774 | printf("running normally.\n"); |
| 1775 | else if (temp == BSTAT_SHUTDOWN0) |
| 1776 | printf("shutdown.\n"); |
| 1777 | else if (temp == BSTAT_STARTINGUP3) |
| 1778 | printf("starting up.\n"); |
| 1779 | else if (temp == BSTAT_SHUTTINGDOWN2) |
| 1780 | printf("shutting down.\n"); |
| 1781 | if (buffer[0] != 0) { |
| 1782 | printf(" Auxiliary status is: %s.\n", buffer); |
| 1783 | } |
| 1784 | } |
| 1785 | |
| 1786 | |
| 1787 | if (!aint32p) |
| 1788 | return 0; |
| 1789 | |
| 1790 | if (istatus.procStartTime) |
| 1791 | printf(" Process last started at %s (%d proc starts)\n", |
| 1792 | DateOf(istatus.procStartTime), istatus.procStarts); |
| 1793 | if (istatus.lastAnyExit) { |
| 1794 | printf(" Last exit at %s\n", DateOf(istatus.lastAnyExit)); |
| 1795 | } |
| 1796 | if (istatus.lastErrorExit) { |
| 1797 | is1 = is2 = is3 = is4 = NULL((void *)0); |
| 1798 | printf(" Last error exit at %s, ", DateOf(istatus.lastErrorExit)); |
| 1799 | code = BOZO_GetInstanceStrings(aconn, aname, &is1, &is2, &is3, &is4); |
| 1800 | |
| 1801 | |
| 1802 | |
| 1803 | if (code == 0) { |
| 1804 | if (*is1 != 0) { |
| 1805 | |
| 1806 | printf("by %s, ", is1); |
| 1807 | } |
| 1808 | free(is1); |
| 1809 | free(is2); |
| 1810 | free(is3); |
| 1811 | free(is4); |
| 1812 | } |
| 1813 | if (istatus.errorSignal) { |
| 1814 | if (istatus.errorSignal == SIGTERM15) |
| 1815 | printf("due to shutdown request\n"); |
| 1816 | else |
| 1817 | printf("due to signal %d\n", istatus.errorSignal); |
| 1818 | } else |
| 1819 | printf("by exiting with code %d\n", istatus.errorCode); |
| 1820 | } |
| 1821 | |
| 1822 | if (aint32p > 1) { |
| 1823 | |
| 1824 | for (i = 0;; i++) { |
| 1825 | tp = buffer; |
| 1826 | code = BOZO_GetInstanceParm(aconn, aname, i, &tp); |
| 1827 | if (code) |
| 1828 | break; |
| 1829 | printf(" Command %d is '%s'\n", i + 1, buffer); |
| 1830 | } |
| 1831 | tp = buffer; |
| 1832 | code = BOZO_GetInstanceParm(aconn, aname, 999, &tp); |
| 1833 | if (!code) { |
| 1834 | |
| 1835 | printf(" Notifier is '%s'\n", buffer); |
| 1836 | } |
| 1837 | printf("\n"); |
| 1838 | } |
| 1839 | return 0; |
| 1840 | } |
| 1841 | |
| 1842 | static int |
| 1843 | GetRestrict(struct cmd_syndesc *as, void *arock) |
| 1844 | { |
| 1845 | struct rx_connection *tconn; |
| 1846 | afs_int32 code, val; |
| 1847 | |
| 1848 | tconn = GetConn(as, 0); |
| 1849 | code = BOZO_GetRestrictedMode(tconn, &val); |
| 1850 | if (code) |
| 1851 | printf("bos: failed to get restricted mode (%s)\n", em(code)); |
| 1852 | else |
| 1853 | printf("Restricted mode is %s\n", val ? "on" : "off"); |
| 1854 | |
| 1855 | return 0; |
| 1856 | } |
| 1857 | |
| 1858 | static int |
| 1859 | SetRestrict(struct cmd_syndesc *as, void *arock) |
| 1860 | { |
| 1861 | struct rx_connection *tconn; |
| 1862 | afs_int32 code, val; |
| 1863 | |
| 1864 | tconn = GetConn(as, 0); |
| 1865 | util_GetInt32(as->parms[1].items->data, &val); |
| 1866 | code = BOZO_SetRestrictedMode(tconn, val); |
| 1867 | if (code) |
| 1868 | printf("bos: failed to set restricted mode (%s)\n", em(code)); |
| 1869 | return 0; |
| 1870 | } |
| 1871 | |
| 1872 | static void |
| 1873 | add_std_args(struct cmd_syndesc *ts) |
| 1874 | { |
| 1875 | cmd_Seek(ts, ADDPARMOFFSET27); |
| 1876 | cmd_AddParm(ts, "-cell", CMD_SINGLE2, CMD_OPTIONAL1, "cell name"); |
| 1877 | cmd_AddParm(ts, "-noauth", CMD_FLAG1, CMD_OPTIONAL1, |
| 1878 | "don't authenticate"); |
| 1879 | cmd_AddParm(ts, "-localauth", CMD_FLAG1, CMD_OPTIONAL1, |
| 1880 | "create tickets from KeyFile"); |
| 1881 | } |
| 1882 | |
| 1883 | #include "AFS_component_version_number.c" |
| 1884 | |
| 1885 | int |
| 1886 | main(int argc, char **argv) |
| 1887 | { |
| 1888 | afs_int32 code; |
| 1889 | struct cmd_syndesc *ts; |
| 1890 | extern int afsconf_SawCell; |
| 1891 | |
| 1892 | #ifdef AFS_AIX32_ENV |
| 1893 | |
| 1894 | |
| 1895 | |
| 1896 | |
| 1897 | |
| 1898 | |
| 1899 | struct sigaction nsa; |
| 1900 | |
| 1901 | sigemptyset(&nsa.sa_mask); |
| 1902 | nsa.sa_handler__sigaction_u.__sa_handler = SIG_DFL((__sighandler_t *)0); |
| 1903 | nsa.sa_flags = SA_FULLDUMP; |
| 1904 | sigaction(SIGSEGV11, &nsa, NULL((void *)0)); |
| 1905 | sigaction(SIGABRT6, &nsa, NULL((void *)0)); |
| 1906 | #endif |
| 1907 | |
| 1908 | |
| 1909 | code = rx_Init(0); |
| 1910 | if (code) { |
| 1911 | printf("bos: could not initialize rx (%s)\n", em(code)); |
| 1912 | exit(1); |
| 1913 | } |
| 1914 | |
| 1915 | |
| 1916 | |
| 1917 | |
| 1918 | |
| 1919 | |
| 1920 | |
| 1921 | afsconf_SawCell = 1; |
| 1922 | ka_Init(0); |
| 1923 | afsconf_SawCell = 0; |
| 1924 | |
| 1925 | |
| 1926 | initialize_CMD_error_table(); |
| 1927 | initialize_BZ_error_table(); |
| 1928 | |
| 1929 | ts = cmd_CreateSyntax("start", StartServer, NULL((void *)0), "start running a server"); |
| 1930 | cmd_AddParm(ts, "-server", CMD_SINGLE2, 0, "machine name"); |
| 1931 | cmd_AddParm(ts, "-instance", CMD_LIST3, 0, "server process name"); |
| 1932 | add_std_args(ts); |
| 1933 | |
| 1934 | ts = cmd_CreateSyntax("stop", StopServer, NULL((void *)0), "halt a server instance"); |
| 1935 | cmd_AddParm(ts, "-server", CMD_SINGLE2, 0, "machine name"); |
| 1936 | cmd_AddParm(ts, "-instance", CMD_LIST3, 0, "server process name"); |
| 1937 | cmd_Seek(ts, 8); |
| 1938 | cmd_AddParm(ts, "-wait", CMD_FLAG1, CMD_OPTIONAL1, |
| 1939 | "wait for process to stop"); |
| 1940 | add_std_args(ts); |
| 1941 | |
| 1942 | ts = cmd_CreateSyntax("status", StatServer, NULL((void *)0), |
| 1943 | "show server instance status"); |
| 1944 | cmd_AddParm(ts, "-server", CMD_SINGLE2, 0, "machine name"); |
| 1945 | cmd_AddParm(ts, "-instance", CMD_LIST3, CMD_OPTIONAL1, |
| 1946 | "server process name"); |
| 1947 | cmd_AddParm(ts, "-long", CMD_FLAG1, CMD_OPTIONAL1, "long status"); |
| 1948 | add_std_args(ts); |
| 1949 | |
| 1950 | ts = cmd_CreateSyntax("shutdown", Shutdown, NULL((void *)0), "shutdown all processes"); |
| 1951 | cmd_AddParm(ts, "-server", CMD_SINGLE2, 0, "machine name"); |
| 1952 | cmd_AddParm(ts, "-instance", CMD_LIST3, CMD_OPTIONAL1, "instances"); |
| 1953 | cmd_Seek(ts, 8); |
| 1954 | cmd_AddParm(ts, "-wait", CMD_FLAG1, CMD_OPTIONAL1, |
| 1955 | "wait for process to stop"); |
| 1956 | add_std_args(ts); |
| 1957 | |
| 1958 | ts = cmd_CreateSyntax("startup", Startup, NULL((void *)0), "start all processes"); |
| 1959 | cmd_AddParm(ts, "-server", CMD_SINGLE2, 0, "machine name"); |
| 1960 | cmd_AddParm(ts, "-instance", CMD_LIST3, CMD_OPTIONAL1, "instances"); |
| 1961 | add_std_args(ts); |
| 1962 | |
| 1963 | ts = cmd_CreateSyntax("restart", Restart, NULL((void *)0), "restart processes"); |
| 1964 | cmd_AddParm(ts, "-server", CMD_SINGLE2, 0, "machine name"); |
| 1965 | cmd_AddParm(ts, "-instance", CMD_LIST3, CMD_OPTIONAL1, "instances"); |
| 1966 | cmd_AddParm(ts, "-bosserver", CMD_FLAG1, CMD_OPTIONAL1, |
| 1967 | "restart bosserver"); |
| 1968 | cmd_AddParm(ts, "-all", CMD_FLAG1, CMD_OPTIONAL1, "restart all processes"); |
| 1969 | add_std_args(ts); |
| 1970 | |
| 1971 | #ifndef OPBOS |
| 1972 | |
| 1973 | ts = cmd_CreateSyntax("create", CreateServer, NULL((void *)0), |
| 1974 | "create a new server instance"); |
| 1975 | cmd_AddParm(ts, "-server", CMD_SINGLE2, 0, "machine name"); |
| 1976 | cmd_AddParm(ts, "-instance", CMD_SINGLE2, 0, "server process name"); |
| 1977 | cmd_AddParm(ts, "-type", CMD_SINGLE2, 0, "server type"); |
| 1978 | cmd_AddParm(ts, "-cmd", CMD_LIST3, 0, "command lines"); |
| 1979 | cmd_AddParm(ts, "-notifier", CMD_SINGLE2, CMD_OPTIONAL1, |
| 1980 | "Notifier program"); |
| 1981 | add_std_args(ts); |
| 1982 | |
| 1983 | ts = cmd_CreateSyntax("delete", DeleteServer, NULL((void *)0), |
| 1984 | "delete a server instance"); |
| 1985 | cmd_AddParm(ts, "-server", CMD_SINGLE2, 0, "machine name"); |
| 1986 | cmd_AddParm(ts, "-instance", CMD_LIST3, 0, "server process name"); |
| 1987 | add_std_args(ts); |
| 1988 | |
| 1989 | ts = cmd_CreateSyntax("adduser", AddSUser, NULL((void *)0), |
| 1990 | "add users to super-user list"); |
| 1991 | cmd_AddParm(ts, "-server", CMD_SINGLE2, 0, "machine name"); |
| 1992 | cmd_AddParm(ts, "-user", CMD_LIST3, 0, "user names"); |
| 1993 | add_std_args(ts); |
| 1994 | |
| 1995 | ts = cmd_CreateSyntax("removeuser", RemoveSUser, NULL((void *)0), |
| 1996 | "remove users from super-user list"); |
| 1997 | cmd_AddParm(ts, "-server", CMD_SINGLE2, 0, "machine name"); |
| 1998 | cmd_AddParm(ts, "-user", CMD_LIST3, 0, "user names"); |
| 1999 | add_std_args(ts); |
| 2000 | |
| 2001 | ts = cmd_CreateSyntax("listusers", ListSUsers, NULL((void *)0), "list super-users"); |
| 2002 | cmd_AddParm(ts, "-server", CMD_SINGLE2, 0, "machine name"); |
| 2003 | add_std_args(ts); |
| 2004 | |
| 2005 | ts = cmd_CreateSyntax("addkey", AddKey, NULL((void *)0), |
| 2006 | "add keys to key dbase (kvno 999 is bcrypt)"); |
| 2007 | cmd_AddParm(ts, "-server", CMD_SINGLE2, 0, "machine name"); |
| 2008 | cmd_AddParm(ts, "-key", CMD_SINGLE2, CMD_OPTIONAL1, "key"); |
| 2009 | cmd_AddParm(ts, "-kvno", CMD_SINGLE2, 0, "key version number"); |
| 2010 | add_std_args(ts); |
| 2011 | |
| 2012 | ts = cmd_CreateSyntax("removekey", RemoveKey, NULL((void *)0), |
| 2013 | "remove keys from key dbase"); |
| 2014 | cmd_AddParm(ts, "-server", CMD_SINGLE2, 0, "machine name"); |
| 2015 | cmd_AddParm(ts, "-kvno", CMD_LIST3, 0, "key version number"); |
| 2016 | add_std_args(ts); |
| 2017 | |
| 2018 | ts = cmd_CreateSyntax("listkeys", ListKeys, NULL((void *)0), "list keys"); |
| 2019 | cmd_AddParm(ts, "-server", CMD_SINGLE2, 0, "machine name"); |
| 2020 | cmd_AddParm(ts, "-showkey", CMD_FLAG1, CMD_OPTIONAL1, |
| 2021 | "show the actual key rather than the checksum"); |
| 2022 | add_std_args(ts); |
| 2023 | |
| 2024 | ts = cmd_CreateSyntax("listhosts", ListHosts, NULL((void *)0), "get cell host list"); |
| 2025 | cmd_AddParm(ts, "-server", CMD_SINGLE2, 0, "machine name"); |
| 2026 | add_std_args(ts); |
| 2027 | cmd_CreateAlias(ts, "getcell"); |
| 2028 | |
| 2029 | ts = cmd_CreateSyntax("setcellname", SetCellName, NULL((void *)0), "set cell name"); |
| 2030 | cmd_AddParm(ts, "-server", CMD_SINGLE2, 0, "machine name"); |
| 2031 | cmd_AddParm(ts, "-name", CMD_SINGLE2, 0, "cell name"); |
| 2032 | add_std_args(ts); |
| 2033 | |
| 2034 | ts = cmd_CreateSyntax("addhost", AddHost, NULL((void *)0), "add host to cell dbase"); |
| 2035 | cmd_AddParm(ts, "-server", CMD_SINGLE2, 0, "machine name"); |
| 2036 | cmd_AddParm(ts, "-host", CMD_LIST3, 0, "host name"); |
| 2037 | cmd_AddParm(ts, "-clone", CMD_FLAG1, CMD_OPTIONAL1, "vote doesn't count"); |
| 2038 | add_std_args(ts); |
| 2039 | |
| 2040 | ts = cmd_CreateSyntax("removehost", RemoveHost, NULL((void *)0), |
| 2041 | "remove host from cell dbase"); |
| 2042 | cmd_AddParm(ts, "-server", CMD_SINGLE2, 0, "machine name"); |
| 2043 | cmd_AddParm(ts, "-host", CMD_LIST3, 0, "host name"); |
| 2044 | add_std_args(ts); |
| 2045 | |
| 2046 | ts = cmd_CreateSyntax("setauth", SetAuth, NULL((void *)0), |
| 2047 | "set authentication required flag"); |
| 2048 | cmd_AddParm(ts, "-server", CMD_SINGLE2, 0, "machine name"); |
| 2049 | cmd_AddParm(ts, "-authrequired", CMD_SINGLE2, 0, |
| 2050 | "on or off: authentication required for admin requests"); |
| 2051 | add_std_args(ts); |
| 2052 | |
| 2053 | ts = cmd_CreateSyntax("install", Install, NULL((void *)0), "install program"); |
| 2054 | cmd_AddParm(ts, "-server", CMD_SINGLE2, 0, "machine name"); |
| 2055 | cmd_AddParm(ts, "-file", CMD_LIST3, 0, "files to install"); |
| 2056 | cmd_AddParm(ts, "-dir", CMD_SINGLE2, CMD_OPTIONAL1, "destination dir"); |
| 2057 | add_std_args(ts); |
| 2058 | |
| 2059 | ts = cmd_CreateSyntax("uninstall", UnInstall, NULL((void *)0), "uninstall program"); |
| 2060 | cmd_AddParm(ts, "-server", CMD_SINGLE2, 0, "machine name"); |
| 2061 | cmd_AddParm(ts, "-file", CMD_LIST3, 0, "files to uninstall"); |
| 2062 | cmd_AddParm(ts, "-dir", CMD_SINGLE2, CMD_OPTIONAL1, "destination dir"); |
| 2063 | add_std_args(ts); |
| 2064 | |
| 2065 | ts = cmd_CreateSyntax("getlog", GetLogCmd, NULL((void *)0), "examine log file"); |
| 2066 | cmd_AddParm(ts, "-server", CMD_SINGLE2, 0, "machine name"); |
| 2067 | cmd_AddParm(ts, "-file", CMD_SINGLE2, 0, "log file to examine"); |
| 2068 | add_std_args(ts); |
| 2069 | |
| 2070 | ts = cmd_CreateSyntax("getdate", GetDate, NULL((void *)0), "get dates for programs"); |
| 2071 | cmd_AddParm(ts, "-server", CMD_SINGLE2, 0, "machine name"); |
| 2072 | cmd_AddParm(ts, "-file", CMD_LIST3, 0, "files to check"); |
| 2073 | cmd_AddParm(ts, "-dir", CMD_SINGLE2, CMD_OPTIONAL1, "destination dir"); |
| 2074 | add_std_args(ts); |
| 2075 | |
| 2076 | ts = cmd_CreateSyntax("exec", Exec, NULL((void *)0), "execute shell command on server"); |
| 2077 | cmd_AddParm(ts, "-server", CMD_SINGLE2, 0, "machine name"); |
| 2078 | cmd_AddParm(ts, "-cmd", CMD_SINGLE2, 0, "command to execute"); |
| 2079 | add_std_args(ts); |
| 2080 | |
| 2081 | ts = cmd_CreateSyntax("prune", Prune, NULL((void *)0), "prune server files"); |
| 2082 | cmd_AddParm(ts, "-server", CMD_SINGLE2, 0, "machine name"); |
| 2083 | cmd_AddParm(ts, "-bak", CMD_FLAG1, CMD_OPTIONAL1, "delete .BAK files"); |
| 2084 | cmd_AddParm(ts, "-old", CMD_FLAG1, CMD_OPTIONAL1, "delete .OLD files"); |
| 2085 | cmd_AddParm(ts, "-core", CMD_FLAG1, CMD_OPTIONAL1, "delete core files"); |
| 2086 | cmd_AddParm(ts, "-all", CMD_FLAG1, CMD_OPTIONAL1, "delete all junk files"); |
| 2087 | add_std_args(ts); |
| 2088 | |
| 2089 | ts = cmd_CreateSyntax("setrestart", SetRestartCmd, NULL((void *)0), |
| 2090 | "set restart times"); |
| 2091 | cmd_AddParm(ts, "-server", CMD_SINGLE2, CMD_REQUIRED0, "machine name"); |
| 2092 | cmd_AddParm(ts, "-time", CMD_SINGLE2, CMD_REQUIRED0, |
| 2093 | "time to restart server"); |
| 2094 | cmd_AddParm(ts, "-general", CMD_FLAG1, CMD_OPTIONAL1, |
| 2095 | "set general restart time"); |
| 2096 | cmd_AddParm(ts, "-newbinary", CMD_FLAG1, CMD_OPTIONAL1, |
| 2097 | "set new binary restart time"); |
| 2098 | add_std_args(ts); |
| 2099 | cmd_CreateAlias(ts, "setr"); |
| 2100 | |
| 2101 | ts = cmd_CreateSyntax("getrestart", GetRestartCmd, NULL((void *)0), |
| 2102 | "get restart times"); |
| 2103 | cmd_AddParm(ts, "-server", CMD_SINGLE2, CMD_REQUIRED0, "machine name"); |
| 2104 | add_std_args(ts); |
| 2105 | cmd_CreateAlias(ts, "getr"); |
| 2106 | |
| 2107 | ts = cmd_CreateSyntax("salvage", SalvageCmd, NULL((void *)0), |
| 2108 | "salvage partition or volumes"); |
| 2109 | cmd_AddParm(ts, "-server", CMD_SINGLE2, 0, "machine name"); |
| 2110 | cmd_AddParm(ts, "-partition", CMD_SINGLE2, CMD_OPTIONAL1, |
| 2111 | "salvage partition"); |
| 2112 | cmd_AddParm(ts, "-volume", CMD_SINGLE2, CMD_OPTIONAL1, |
| 2113 | "salvage volume number or volume name"); |
| 2114 | cmd_AddParm(ts, "-file", CMD_SINGLE2, CMD_OPTIONAL1, |
| 2115 | "salvage log output file"); |
| 2116 | cmd_AddParm(ts, "-all", CMD_FLAG1, CMD_OPTIONAL1, "salvage whole server"); |
| 2117 | cmd_AddParm(ts, "-showlog", CMD_FLAG1, CMD_OPTIONAL1, |
| 2118 | "display salvage log"); |
| 2119 | cmd_AddParm(ts, "-parallel", CMD_SINGLE2, CMD_OPTIONAL1, |
| 2120 | "# of max parallel partition salvaging"); |
| 2121 | cmd_AddParm(ts, "-tmpdir", CMD_SINGLE2, CMD_OPTIONAL1, |
| 2122 | "directory to place tmp files"); |
| 2123 | cmd_AddParm(ts, "-orphans", CMD_SINGLE2, CMD_OPTIONAL1, |
| 2124 | "ignore | remove | attach"); |
| 2125 | cmd_AddParm(ts, "-forceDAFS", CMD_FLAG1, CMD_OPTIONAL1, |
| 2126 | "(DAFS) force salvage of demand attach fileserver"); |
| 2127 | cmd_AddParm(ts, "-debug", CMD_FLAG1, CMD_OPTIONAL1, |
| 2128 | "(MR-AFS) Run in Debugging mode"); |
| 2129 | cmd_AddParm(ts, "-nowrite", CMD_FLAG1, CMD_OPTIONAL1, |
| 2130 | "(MR-AFS) Run readonly/test mode"); |
| 2131 | cmd_AddParm(ts, "-force", CMD_FLAG1, CMD_OPTIONAL1, |
| 2132 | "(MR-AFS) Force full salvaging"); |
| 2133 | cmd_AddParm(ts, "-oktozap", CMD_FLAG1, CMD_OPTIONAL1, |
| 2134 | "(MR-AFS) Give permission to destroy bogus file residencies/volumes - debugging flag"); |
| 2135 | cmd_AddParm(ts, "-rootfiles", CMD_FLAG1, CMD_OPTIONAL1, |
| 2136 | "(MR-AFS) Show files owned by root - debugging flag"); |
| 2137 | cmd_AddParm(ts, "-salvagedirs", CMD_FLAG1, CMD_OPTIONAL1, |
| 2138 | "(MR-AFS) Force rebuild/salvage of all directories"); |
| 2139 | cmd_AddParm(ts, "-blockreads", CMD_FLAG1, CMD_OPTIONAL1, |
| 2140 | "(MR-AFS) Read smaller blocks to handle IO/bad blocks"); |
| 2141 | cmd_AddParm(ts, "-ListResidencies", CMD_FLAG1, CMD_OPTIONAL1, |
| 2142 | "(MR-AFS) Just list affected file residencies - debugging flag"); |
| 2143 | cmd_AddParm(ts, "-SalvageRemote", CMD_FLAG1, CMD_OPTIONAL1, |
| 2144 | "(MR-AFS) Salvage storage systems that are not directly attached"); |
| 2145 | cmd_AddParm(ts, "-SalvageArchival", CMD_FLAG1, CMD_OPTIONAL1, |
| 2146 | "(MR-AFS) Salvage HSM storage systems"); |
| 2147 | cmd_AddParm(ts, "-IgnoreCheck", CMD_FLAG1, CMD_OPTIONAL1, |
| 2148 | "(MR-AFS) Don't perform VLDB safety check when deleting unreferenced files. Only a good idea in single server cell."); |
| 2149 | cmd_AddParm(ts, "-ForceOnLine", CMD_FLAG1, CMD_OPTIONAL1, |
| 2150 | "(MR-AFS) Force the volume to come online, even if it hasn't salvaged cleanly."); |
| 2151 | cmd_AddParm(ts, "-UseRootDirACL", CMD_FLAG1, CMD_OPTIONAL1, |
| 2152 | "(MR-AFS) Use the root directory ACL for lost+found directory if it is created."); |
| 2153 | cmd_AddParm(ts, "-TraceBadLinkCounts", CMD_FLAG1, CMD_OPTIONAL1, |
| 2154 | "(MR-AFS) Print out lines about volume reference count changes."); |
| 2155 | cmd_AddParm(ts, "-DontAskFS", CMD_FLAG1, CMD_OPTIONAL1, |
| 2156 | "(MR-AFS) Don't ask fileserver to take volume offline. THIS IS VERY DANGEROUS."); |
| 2157 | cmd_AddParm(ts, "-LogLevel", CMD_SINGLE2, CMD_OPTIONAL1, |
| 2158 | "(MR-AFS) log level"); |
| 2159 | cmd_AddParm(ts, "-rxdebug", CMD_FLAG1, CMD_OPTIONAL1, |
| 2160 | "(MR-AFS) Write out rx debug information."); |
| 2161 | cmd_AddParm(ts, "-Residencies", CMD_SINGLE2, CMD_OPTIONAL1, |
| 2162 | "(MR-AFS) Numeric mask of residencies to be included in the salvage. Do not use with -SalvageRemote or -SalvageArchival"); |
| 2163 | add_std_args(ts); |
| 2164 | |
| 2165 | ts = cmd_CreateSyntax("blockscanner", BlockScannerCmd, NULL((void *)0), |
| 2166 | "block scanner daemon from making migration requests"); |
| 2167 | cmd_AddParm(ts, "-server", CMD_SINGLE2, CMD_REQUIRED0, "machine name"); |
| 2168 | add_std_args(ts); |
| 2169 | |
| 2170 | ts = cmd_CreateSyntax("unblockscanner", UnBlockScannerCmd, NULL((void *)0), |
| 2171 | "allow scanner daemon to make migration requests again"); |
| 2172 | cmd_AddParm(ts, "-server", CMD_SINGLE2, CMD_REQUIRED0, "machine name"); |
| 2173 | add_std_args(ts); |
| 2174 | |
| 2175 | ts = cmd_CreateSyntax("getrestricted", GetRestrict, NULL((void *)0), |
| 2176 | "get restrict mode"); |
| 2177 | cmd_AddParm(ts, "-server", CMD_SINGLE2, 0, "machine name"); |
| 2178 | add_std_args(ts); |
| 2179 | |
| 2180 | ts = cmd_CreateSyntax("setrestricted", SetRestrict, NULL((void *)0), |
| 2181 | "set restrict mode"); |
| 2182 | cmd_AddParm(ts, "-server", CMD_SINGLE2, 0, "machine name"); |
| 2183 | cmd_AddParm(ts, "-mode", CMD_SINGLE2, 0, "mode to set"); |
| 2184 | add_std_args(ts); |
| 2185 | #endif |
| 2186 | |
| 2187 | code = cmd_Dispatch(argc, argv); |
| 2188 | rx_Finalize(); |
| 2189 | exit(code); |
| 2190 | } |