| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | #include <afsconfig.h> |
| 13 | #include <afs/param.h> |
| 14 | |
| 15 | #include <afs/procmgmt.h> |
| 16 | #include <roken.h> |
| 17 | |
| 18 | #include <rx/xdr.h> |
| 19 | #include <rx/rx.h> |
| 20 | #include <afs/afsint.h> |
| 21 | #include <afs/afs_assert.h> |
| 22 | #include <afs/prs_fs.h> |
| 23 | #include <afs/nfs.h> |
| 24 | #include <lwp.h> |
| 25 | #include <lock.h> |
| 26 | #include <afs/cellconfig.h> |
| 27 | #include <afs/keys.h> |
| 28 | #include <ubik.h> |
| 29 | #include <afs/tcdata.h> |
| 30 | #include <afs/budb_client.h> |
| 31 | #include <afs/bucoord_prototypes.h> |
| 32 | |
| 33 | #include "error_macros.h" |
| 34 | #include "butc_xbsa.h" |
| 35 | #include "butc_prototypes.h" |
| 36 | #include "butc_internal.h" |
| 37 | |
| 38 | static int CopyDumpDesc(struct tc_dumpDesc *, tc_dumpArray *); |
| 39 | static int CopyRestoreDesc(struct tc_restoreDesc *, tc_restoreArray *); |
| 40 | static int CopyTapeSetDesc(struct tc_tapeSet *, struct tc_tapeSet *); |
| 41 | |
| 42 | int |
| 43 | callPermitted(struct rx_call *call) |
| 44 | { |
| 45 | |
| 46 | |
| 47 | |
| 48 | return 1; |
| 49 | } |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | static int |
| 57 | CopyDumpDesc(struct tc_dumpDesc *toDump, tc_dumpArray *fromDump) |
| 58 | { |
| 59 | struct tc_dumpDesc *toPtr, *fromPtr; |
| 60 | int i; |
| 61 | |
| 62 | toPtr = toDump; |
| 63 | fromPtr = fromDump->tc_dumpArray_val; |
| 64 | for (i = 0; i < fromDump->tc_dumpArray_len; i++) { |
| 65 | toPtr->vid = fromPtr->vid; |
| 66 | toPtr->vtype = fromPtr->vtype; |
| 67 | toPtr->partition = fromPtr->partition; |
| 68 | toPtr->date = fromPtr->date; |
| 69 | toPtr->cloneDate = fromPtr->cloneDate; |
| 70 | toPtr->hostAddr = fromPtr->hostAddr; |
| 71 | strcpy(toPtr->name, fromPtr->name); |
| 72 | fromPtr++; |
| 73 | toPtr++; |
| 74 | } |
| 75 | return 0; |
| 76 | } |
| 77 | |
| 78 | |
| 79 | static int |
| 80 | CopyRestoreDesc(struct tc_restoreDesc *toRestore, tc_restoreArray *fromRestore) |
| 81 | { |
| 82 | struct tc_restoreDesc *toPtr, *fromPtr; |
| 83 | int i; |
| 84 | |
| 85 | toPtr = toRestore; |
| 86 | fromPtr = fromRestore->tc_restoreArray_val; |
| 87 | for (i = 0; i < fromRestore->tc_restoreArray_len; i++) { |
| 88 | toPtr->flags = fromPtr->flags; |
| 89 | toPtr->position = fromPtr->position; |
| 90 | strcpy(toPtr->tapeName, fromPtr->tapeName); |
| 91 | toPtr->dbDumpId = fromPtr->dbDumpId; |
| 92 | toPtr->initialDumpId = fromPtr->initialDumpId; |
| 93 | toPtr->origVid = fromPtr->origVid; |
| 94 | toPtr->vid = fromPtr->vid; |
| 95 | toPtr->partition = fromPtr->partition; |
| 96 | toPtr->dumpLevel = fromPtr->dumpLevel; |
| 97 | toPtr->hostAddr = fromPtr->hostAddr; |
| 98 | strcpy(toPtr->newName, fromPtr->newName); |
| 99 | strcpy(toPtr->oldName, fromPtr->oldName); |
| 100 | fromPtr++; |
| 101 | toPtr++; |
| 102 | |
| 103 | } |
| 104 | return 0; |
| 105 | } |
| 106 | |
| 107 | static int |
| 108 | CopyTapeSetDesc(struct tc_tapeSet *toPtr, struct tc_tapeSet *fromPtr) |
| 109 | { |
| 110 | |
| 111 | toPtr->id = fromPtr->id; |
| 112 | toPtr->maxTapes = fromPtr->maxTapes; |
| 113 | toPtr->a = fromPtr->a; |
| 114 | toPtr->b = fromPtr->b; |
| 115 | strcpy(toPtr->tapeServer, fromPtr->tapeServer); |
| 116 | strcpy(toPtr->format, fromPtr->format); |
| 117 | |
| 118 | toPtr->expDate = fromPtr->expDate; |
| 119 | toPtr->expType = fromPtr->expType; |
| 120 | return 0; |
| 121 | } |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | afs_int32 |
| 129 | STC_LabelTape(struct rx_call *acid, struct tc_tapeLabel *label, afs_uint32 *taskId) |
| 130 | { |
| 131 | #ifdef AFS_PTHREAD_ENV |
| 132 | pthread_t pid; |
| 133 | pthread_attr_t tattr; |
| 134 | AFS_SIGSET_DECL; |
| 135 | #else |
| 136 | PROCESS pid; |
| 137 | #endif |
| 138 | struct labelTapeIf *ptr; |
| 139 | statusP statusPtr = NULL((void *)0); |
| 140 | afs_int32 code; |
| 141 | |
| 142 | #ifdef xbsa |
| 143 | if (CONF_XBSA0) |
| 144 | return (TC_BADTASK(156566293L)); |
| 145 | #endif |
| 146 | |
| 147 | if (callPermitted(acid) == 0) |
| 148 | return (TC_NOTPERMITTED(156566291L)); |
| 149 | |
| 150 | ptr = (struct labelTapeIf *)malloc(sizeof(*ptr)); |
| 151 | if (!ptr) |
| 152 | ERROR_EXIT(TC_NOMEMORY)do { code = (156566290L); goto error_exit; } while (0); |
| 153 | memcpy(&ptr->label, label, sizeof(ptr->label)); |
| 154 | |
| 155 | |
| 156 | *taskId = allocTaskId(); |
| 157 | ptr->taskId = *taskId; |
| 158 | |
| 159 | statusPtr = createStatusNode(); |
| 160 | if (!statusPtr) |
| 161 | ERROR_EXIT(TC_INTERNALERROR)do { code = (156566288L); goto error_exit; } while (0); |
| 162 | |
| 163 | lock_Status(); |
| 164 | statusPtr->taskId = *taskId; |
| 165 | statusPtr->lastPolled = time(0); |
| 166 | statusPtr->flags &= ~STARTING0x1; |
| 167 | strncpy(statusPtr->taskName, "Labeltape", sizeof(statusPtr->taskName)); |
| 168 | unlock_Status(); |
| 169 | |
| 170 | |
| 171 | #ifdef AFS_PTHREAD_ENV |
| 172 | code = pthread_attr_init(&tattr); |
| 173 | if (code) |
| 174 | ERROR_EXIT(code)do { code = code; goto error_exit; } while (0); |
| 175 | |
| 176 | code = pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED); |
| 177 | if (code) |
| 178 | ERROR_EXIT(code)do { code = code; goto error_exit; } while (0); |
| 179 | |
| 180 | AFS_SIGSET_CLEAR(); |
| 181 | code = pthread_create(&pid, &tattr, Labeller, ptr); |
| 182 | AFS_SIGSET_RESTORE(); |
| 183 | #else |
| 184 | code = |
| 185 | LWP_CreateProcess(Labeller, 32768, 1, (void *)ptr, "labeller process", |
| 186 | &pid); |
| 187 | #endif |
| 188 | |
| 189 | error_exit: |
| 190 | if (code) { |
| 191 | if (statusPtr) |
| 192 | deleteStatusNode(statusPtr); |
| 193 | if (ptr) |
| 194 | free(ptr); |
| 195 | } |
| 196 | |
| 197 | return (code); |
| 198 | } |
| 199 | |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | afs_int32 |
| 205 | STC_PerformDump(struct rx_call *rxCallId, struct tc_dumpInterface *tcdiPtr, tc_dumpArray *tc_dumpArrayPtr, afs_int32 *taskId) |
| 206 | { |
| 207 | struct dumpNode *newNode = 0; |
| 208 | statusP statusPtr = 0; |
| 209 | #ifdef AFS_PTHREAD_ENV |
| 210 | pthread_t pid; |
| 211 | pthread_attr_t tattr; |
| 212 | AFS_SIGSET_DECL; |
| 213 | #else |
| 214 | PROCESS pid; |
| 215 | #endif |
| 216 | afs_int32 code = 0; |
| 217 | |
| 218 | if (callPermitted(rxCallId) == 0) |
| |
| 219 | return (TC_NOTPERMITTED(156566291L)); |
| 220 | |
| 221 | |
| 222 | *taskId = 0; |
| 223 | |
| 224 | |
| 225 | CreateNode(&newNode); |
| 226 | |
| 227 | |
| 228 | strcpy(newNode->dumpSetName, tcdiPtr->dumpName); |
| 229 | |
| 230 | newNode->dumpName = (char *)malloc(strlen(tcdiPtr->dumpPath) + 1); |
| 231 | strcpy(newNode->dumpName, tcdiPtr->dumpPath); |
| 232 | |
| 233 | newNode->volumeSetName = |
| 234 | (char *)malloc(strlen(tcdiPtr->volumeSetName) + 1); |
| 235 | strcpy(newNode->volumeSetName, tcdiPtr->volumeSetName); |
| 236 | |
| 237 | CopyTapeSetDesc(&(newNode->tapeSetDesc), &tcdiPtr->tapeSet); |
| 238 | |
| 239 | newNode->dumps = (struct tc_dumpDesc *) |
| 240 | malloc(sizeof(struct tc_dumpDesc) * |
| 241 | tc_dumpArrayPtr->tc_dumpArray_len); |
| 242 | newNode->arraySize = tc_dumpArrayPtr->tc_dumpArray_len; |
| 243 | CopyDumpDesc(newNode->dumps, tc_dumpArrayPtr); |
| 244 | |
| 245 | newNode->parent = tcdiPtr->parentDumpId; |
| 246 | newNode->level = tcdiPtr->dumpLevel; |
| 247 | newNode->doAppend = tcdiPtr->doAppend; |
| 248 | #ifdef xbsa |
| 249 | if (CONF_XBSA0) |
| 250 | newNode->doAppend = 0; |
| 251 | #endif |
| 252 | |
| 253 | |
| 254 | statusPtr = createStatusNode(); |
| 255 | if (!statusPtr) |
| |
| 256 | ERROR_EXIT(TC_INTERNALERROR)do { code = (156566288L); goto error_exit; } while (0); |
| 257 | |
| 258 | lock_Status(); |
| 259 | statusPtr->taskId = newNode->taskID; |
| 260 | statusPtr->lastPolled = time(0); |
| 261 | statusPtr->flags &= ~STARTING0x1; |
| 262 | strncpy(statusPtr->taskName, "Dump", sizeof(statusPtr->taskName)); |
| 263 | unlock_Status(); |
| 264 | |
| 265 | newNode->statusNodePtr = statusPtr; |
| 266 | |
| 267 | |
| 268 | #ifdef AFS_PTHREAD_ENV |
| 269 | code = pthread_attr_init(&tattr); |
| 270 | if (code) |
| 271 | ERROR_EXIT(code)do { code = code; goto error_exit; } while (0); |
| 272 | |
| 273 | code = pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED); |
| 274 | if (code) |
| 275 | ERROR_EXIT(code)do { code = code; goto error_exit; } while (0); |
| 276 | |
| 277 | AFS_SIGSET_CLEAR(); |
| 278 | code = pthread_create(&pid, &tattr, Dumper, newNode); |
| 279 | AFS_SIGSET_RESTORE(); |
| 280 | #else |
| 281 | code = |
| 282 | LWP_CreateProcess(Dumper, 32768, 1, (void *)newNode, "dumper process", |
| 283 | &pid); |
| 284 | #endif |
| 285 | if (code) |
| |
| 286 | ERROR_EXIT(code)do { code = code; goto error_exit; } while (0); |
| 4 | Within the expansion of the macro 'ERROR_EXIT':
|
a | Assigned value is always the same as the existing value |
|
| 287 | |
| 288 | *taskId = newNode->taskID; |
| 289 | |
| 290 | error_exit: |
| 291 | if (code) { |
| 292 | if (statusPtr) |
| 293 | deleteStatusNode(statusPtr); |
| 294 | FreeNode(newNode->taskID); |
| 295 | } |
| 296 | |
| 297 | return (code); |
| 298 | } |
| 299 | |
| 300 | afs_int32 |
| 301 | STC_PerformRestore(struct rx_call *acid, char *dumpSetName, tc_restoreArray *arestores, afs_int32 *taskID) |
| 302 | { |
| 303 | struct dumpNode *newNode; |
| 304 | statusP statusPtr; |
| 305 | afs_int32 code = 0; |
| 306 | #ifdef AFS_PTHREAD_ENV |
| 307 | pthread_t pid; |
| 308 | pthread_attr_t tattr; |
| 309 | AFS_SIGSET_DECL; |
| 310 | #else |
| 311 | PROCESS pid; |
| 312 | #endif |
| 313 | |
| 314 | if (callPermitted(acid) == 0) |
| 315 | return (TC_NOTPERMITTED(156566291L)); |
| 316 | |
| 317 | |
| 318 | |
| 319 | |
| 320 | CreateNode(&newNode); |
| 321 | |
| 322 | newNode->restores = (struct tc_restoreDesc *) |
| 323 | malloc(sizeof(struct tc_restoreDesc) * |
| 324 | arestores->tc_restoreArray_len); |
| 325 | newNode->arraySize = arestores->tc_restoreArray_len; |
| 326 | CopyRestoreDesc(newNode->restores, arestores); |
| 327 | *taskID = newNode->taskID; |
| 328 | |
| 329 | |
| 330 | |
| 331 | |
| 332 | statusPtr = createStatusNode(); |
| 333 | if (!statusPtr) |
| 334 | ERROR_EXIT(TC_INTERNALERROR)do { code = (156566288L); goto error_exit; } while (0); |
| 335 | |
| 336 | lock_Status(); |
| 337 | statusPtr->taskId = newNode->taskID; |
| 338 | statusPtr->flags &= ~STARTING0x1; |
| 339 | statusPtr->lastPolled = time(0); |
| 340 | strncpy(statusPtr->taskName, "Restore", sizeof(statusPtr->taskName)); |
| 341 | unlock_Status(); |
| 342 | |
| 343 | newNode->statusNodePtr = statusPtr; |
| 344 | |
| 345 | |
| 346 | #ifdef AFS_PTHREAD_ENV |
| 347 | code = pthread_attr_init(&tattr); |
| 348 | if (code) |
| 349 | ERROR_EXIT(code)do { code = code; goto error_exit; } while (0); |
| 350 | |
| 351 | code = pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED); |
| 352 | if (code) |
| 353 | ERROR_EXIT(code)do { code = code; goto error_exit; } while (0); |
| 354 | |
| 355 | AFS_SIGSET_CLEAR(); |
| 356 | code = pthread_create(&pid, &tattr, Restorer, newNode); |
| 357 | AFS_SIGSET_RESTORE(); |
| 358 | #else |
| 359 | code = |
| 360 | LWP_CreateProcess(Restorer, 65368, 1, (void *)newNode, |
| 361 | "restorer process", &pid); |
| 362 | #endif |
| 363 | |
| 364 | error_exit: |
| 365 | if (code) { |
| 366 | if (statusPtr) |
| 367 | deleteStatusNode(statusPtr); |
| 368 | FreeNode(newNode->taskID); |
| 369 | } |
| 370 | |
| 371 | return (code); |
| 372 | } |
| 373 | |
| 374 | afs_int32 |
| 375 | STC_ReadLabel(struct rx_call *acid, struct tc_tapeLabel *label, afs_uint32 *taskId) |
| 376 | { |
| 377 | afs_int32 code; |
| 378 | |
| 379 | #ifdef xbsa |
| 380 | if (CONF_XBSA0) |
| 381 | return (TC_BADTASK(156566293L)); |
| 382 | #endif |
| 383 | |
| 384 | if (callPermitted(acid) == 0) |
| 385 | return (TC_NOTPERMITTED(156566291L)); |
| 386 | |
| 387 | code = ReadLabel(label); |
| 388 | return code; |
| 389 | } |
| 390 | |
| 391 | |
| 392 | |
| 393 | |
| 394 | |
| 395 | afs_int32 |
| 396 | STC_RestoreDb(struct rx_call *rxCall, afs_uint32 *taskId) |
| 397 | { |
| 398 | #ifdef AFS_PTHREAD_ENV |
| 399 | pthread_t pid; |
| 400 | pthread_attr_t tattr; |
| 401 | AFS_SIGSET_DECL; |
| 402 | #else |
| 403 | PROCESS pid; |
| 404 | #endif |
| 405 | statusP statusPtr; |
| 406 | afs_int32 code = 0; |
| 407 | |
| 408 | #ifdef xbsa |
| 409 | if (CONF_XBSA0) |
| 410 | return (TC_BADTASK(156566293L)); |
| 411 | #endif |
| 412 | |
| 413 | if (callPermitted(rxCall) == 0) |
| 414 | return (TC_NOTPERMITTED(156566291L)); |
| 415 | |
| 416 | *taskId = allocTaskId(); |
| 417 | |
| 418 | |
| 419 | statusPtr = createStatusNode(); |
| 420 | if (!statusPtr) |
| 421 | ERROR_EXIT(TC_INTERNALERROR)do { code = (156566288L); goto error_exit; } while (0); |
| 422 | |
| 423 | lock_Status(); |
| 424 | statusPtr->taskId = *taskId; |
| 425 | statusPtr->flags &= ~STARTING0x1; |
| 426 | statusPtr->lastPolled = time(0); |
| 427 | strncpy(statusPtr->taskName, "RestoreDb", sizeof(statusPtr->taskName)); |
| 428 | unlock_Status(); |
| 429 | |
| 430 | #ifdef AFS_PTHREAD_ENV |
| 431 | code = pthread_attr_init(&tattr); |
| 432 | if (code) |
| 433 | ERROR_EXIT(code)do { code = code; goto error_exit; } while (0); |
| 434 | |
| 435 | code = pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED); |
| 436 | if (code) |
| 437 | ERROR_EXIT(code)do { code = code; goto error_exit; } while (0); |
| 438 | |
| 439 | AFS_SIGSET_CLEAR(); |
| 440 | code = pthread_create(&pid, &tattr, restoreDbFromTape, (void *)(intptr_t)*taskId); |
| 441 | AFS_SIGSET_RESTORE(); |
| 442 | #else |
| 443 | code = |
| 444 | LWP_CreateProcess(restoreDbFromTape, 32768, 1, (void *)(intptr_t)*taskId, |
| 445 | "Db restore", &pid); |
| 446 | #endif |
| 447 | |
| 448 | error_exit: |
| 449 | if (code) { |
| 450 | if (statusPtr) |
| 451 | deleteStatusNode(statusPtr); |
| 452 | } |
| 453 | |
| 454 | return (code); |
| 455 | } |
| 456 | |
| 457 | |
| 458 | |
| 459 | |
| 460 | |
| 461 | afs_int32 |
| 462 | STC_SaveDb(struct rx_call *rxCall, Dateafs_uint32 archiveTime, afs_uint32 *taskId) |
| 463 | { |
| 464 | #ifdef AFS_PTHREAD_ENV |
| 465 | pthread_t pid; |
| 466 | pthread_attr_t tattr; |
| 467 | AFS_SIGSET_DECL; |
| 468 | #else |
| 469 | PROCESS pid; |
| 470 | #endif |
| 471 | statusP statusPtr = NULL((void *)0); |
| 472 | afs_int32 code = 0; |
| 473 | struct saveDbIf *ptr; |
| 474 | |
| 475 | #ifdef xbsa |
| 476 | if (CONF_XBSA0) |
| 477 | return (TC_BADTASK(156566293L)); |
| 478 | #endif |
| 479 | |
| 480 | if (callPermitted(rxCall) == 0) |
| 481 | return (TC_NOTPERMITTED(156566291L)); |
| 482 | |
| 483 | *taskId = allocTaskId(); |
| 484 | |
| 485 | ptr = (struct saveDbIf *)malloc(sizeof(struct saveDbIf)); |
| 486 | if (!ptr) |
| 487 | ERROR_EXIT(TC_NOMEMORY)do { code = (156566290L); goto error_exit; } while (0); |
| 488 | ptr->archiveTime = archiveTime; |
| 489 | ptr->taskId = *taskId; |
| 490 | |
| 491 | |
| 492 | statusPtr = createStatusNode(); |
| 493 | if (!statusPtr) |
| 494 | ERROR_EXIT(TC_INTERNALERROR)do { code = (156566288L); goto error_exit; } while (0); |
| 495 | |
| 496 | lock_Status(); |
| 497 | statusPtr->taskId = *taskId; |
| 498 | statusPtr->lastPolled = time(0); |
| 499 | statusPtr->flags &= ~STARTING0x1; |
| 500 | strncpy(statusPtr->taskName, "SaveDb", sizeof(statusPtr->taskName)); |
| 501 | unlock_Status(); |
| 502 | |
| 503 | ptr->statusPtr = statusPtr; |
| 504 | |
| 505 | #ifdef AFS_PTHREAD_ENV |
| 506 | code = pthread_attr_init(&tattr); |
| 507 | if (code) |
| 508 | ERROR_EXIT(code)do { code = code; goto error_exit; } while (0); |
| 509 | |
| 510 | code = pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED); |
| 511 | if (code) |
| 512 | ERROR_EXIT(code)do { code = code; goto error_exit; } while (0); |
| 513 | |
| 514 | AFS_SIGSET_CLEAR(); |
| 515 | code = pthread_create(&pid, &tattr, saveDbToTape, ptr); |
| 516 | AFS_SIGSET_RESTORE(); |
| 517 | #else |
| 518 | code = LWP_CreateProcess(saveDbToTape, 32768, 1, ptr, "Db save", &pid); |
| 519 | #endif |
| 520 | |
| 521 | error_exit: |
| 522 | if (code) { |
| 523 | if (statusPtr) |
| 524 | deleteStatusNode(statusPtr); |
| 525 | if (ptr) |
| 526 | free(ptr); |
| 527 | } |
| 528 | |
| 529 | return (code); |
| 530 | } |
| 531 | |
| 532 | |
| 533 | |
| 534 | |
| 535 | |
| 536 | |
| 537 | |
| 538 | |
| 539 | |
| 540 | afs_int32 |
| 541 | STC_ScanDumps(struct rx_call *acid, afs_int32 addDbFlag, afs_uint32 *taskId) |
| 542 | { |
| 543 | #ifdef AFS_PTHREAD_ENV |
| 544 | pthread_t pid; |
| 545 | pthread_attr_t tattr; |
| 546 | AFS_SIGSET_DECL; |
| 547 | #else |
| 548 | PROCESS pid; |
| 549 | #endif |
| 550 | struct scanTapeIf *ptr; |
| 551 | statusP statusPtr = NULL((void *)0); |
| 552 | afs_int32 code = 0; |
| 553 | |
| 554 | #ifdef xbsa |
| 555 | if (CONF_XBSA0) |
| 556 | return (TC_BADTASK(156566293L)); |
| 557 | #endif |
| 558 | |
| 559 | if (callPermitted(acid) == 0) |
| 560 | return (TC_NOTPERMITTED(156566291L)); |
| 561 | |
| 562 | *taskId = allocTaskId(); |
| 563 | |
| 564 | ptr = (struct scanTapeIf *)malloc(sizeof(*ptr)); |
| 565 | if (!ptr) |
| 566 | ERROR_EXIT(TC_NOMEMORY)do { code = (156566290L); goto error_exit; } while (0); |
| 567 | ptr->addDbFlag = addDbFlag; |
| 568 | ptr->taskId = *taskId; |
| 569 | |
| 570 | |
| 571 | statusPtr = createStatusNode(); |
| 572 | if (!statusPtr) |
| 573 | ERROR_EXIT(TC_INTERNALERROR)do { code = (156566288L); goto error_exit; } while (0); |
| 574 | |
| 575 | lock_Status(); |
| 576 | statusPtr->taskId = *taskId; |
| 577 | statusPtr->lastPolled = time(0); |
| 578 | statusPtr->flags &= ~STARTING0x1; |
| 579 | strncpy(statusPtr->taskName, "Scantape", sizeof(statusPtr->taskName)); |
| 580 | unlock_Status(); |
| 581 | |
| 582 | #ifdef AFS_PTHREAD_ENV |
| 583 | code = pthread_attr_init(&tattr); |
| 584 | if (code) |
| 585 | ERROR_EXIT(code)do { code = code; goto error_exit; } while (0); |
| 586 | |
| 587 | code = pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED); |
| 588 | if (code) |
| 589 | ERROR_EXIT(code)do { code = code; goto error_exit; } while (0); |
| 590 | |
| 591 | AFS_SIGSET_CLEAR(); |
| 592 | code = pthread_create(&pid, &tattr, ScanDumps, ptr); |
| 593 | AFS_SIGSET_RESTORE(); |
| 594 | #else |
| 595 | code = |
| 596 | LWP_CreateProcess(ScanDumps, 32768, 1, ptr, "scandump process", &pid); |
| 597 | #endif |
| 598 | |
| 599 | error_exit: |
| 600 | if (code) { |
| 601 | if (statusPtr) |
| 602 | deleteStatusNode(statusPtr); |
| 603 | if (ptr) |
| 604 | free(ptr); |
| 605 | } |
| 606 | |
| 607 | return code; |
| 608 | } |
| 609 | |
| 610 | |
| 611 | |
| 612 | |
| 613 | |
| 614 | |
| 615 | afs_int32 |
| 616 | STC_TCInfo(struct rx_call *acid, struct tc_tcInfo *tciptr) |
| 617 | { |
| 618 | if (callPermitted(acid) == 0) |
| 619 | return (TC_NOTPERMITTED(156566291L)); |
| 620 | |
| 621 | tciptr->tcVersion = CUR_BUTC_VERSION3; |
| 622 | return (0); |
| 623 | } |
| 624 | |
| 625 | |
| 626 | |
| 627 | afs_int32 |
| 628 | STC_DeleteDump(struct rx_call *acid, afs_uint32 dumpID, afs_uint32 *taskId) |
| 629 | { |
| 630 | afs_int32 code = TC_BADTASK(156566293L); |
| 631 | #ifdef xbsa |
| 632 | struct deleteDumpIf *ptr = 0; |
| 633 | statusP statusPtr = 0; |
| 634 | #ifdef AFS_PTHREAD_ENV |
| 635 | pthread_t pid; |
| 636 | pthread_attr_t tattr; |
| 637 | AFS_SIGSET_DECL; |
| 638 | #else |
| 639 | PROCESS pid; |
| 640 | #endif |
| 641 | #endif |
| 642 | |
| 643 | *taskId = 0; |
| 644 | if (!CONF_XBSA0) |
| 645 | return (TC_BADTASK(156566293L)); |
| 646 | |
| 647 | #ifdef xbsa |
| 648 | code = 0; |
| 649 | if (callPermitted(acid) == 0) |
| 650 | return (TC_NOTPERMITTED(156566291L)); |
| 651 | |
| 652 | ptr = (struct deleteDumpIf *)malloc(sizeof(*ptr)); |
| 653 | if (!ptr) |
| 654 | ERROR_EXIT(TC_NOMEMORY)do { code = (156566290L); goto error_exit; } while (0); |
| 655 | |
| 656 | *taskId = allocTaskId(); |
| 657 | ptr->dumpID = dumpID; |
| 658 | ptr->taskId = *taskId; |
| 659 | |
| 660 | statusPtr = createStatusNode(); |
| 661 | if (!statusPtr) |
| 662 | ERROR_EXIT(TC_INTERNALERROR)do { code = (156566288L); goto error_exit; } while (0); |
| 663 | |
| 664 | lock_Status(); |
| 665 | statusPtr->taskId = *taskId; |
| 666 | statusPtr->lastPolled = time(0); |
| 667 | statusPtr->flags &= ~STARTING0x1; |
| 668 | strncpy(statusPtr->taskName, "DeleteDump", sizeof(statusPtr->taskName)); |
| 669 | unlock_Status(); |
| 670 | |
| 671 | #ifdef AFS_PTHREAD_ENV |
| 672 | code = pthread_attr_init(&tattr); |
| 673 | if (code) |
| 674 | ERROR_EXIT(code)do { code = code; goto error_exit; } while (0); |
| 675 | |
| 676 | code = pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED); |
| 677 | if (code) |
| 678 | ERROR_EXIT(code)do { code = code; goto error_exit; } while (0); |
| 679 | |
| 680 | AFS_SIGSET_CLEAR(); |
| 681 | code = pthread_create(&pid, &tattr, DeleteDump, ptr); |
| 682 | AFS_SIGSET_RESTORE(); |
| 683 | #else |
| 684 | code = |
| 685 | LWP_CreateProcess(DeleteDump, 32768, 1, ptr, "deletedump process", |
| 686 | &pid); |
| 687 | #endif |
| 688 | |
| 689 | error_exit: |
| 690 | if (code) { |
| 691 | if (statusPtr) |
| 692 | deleteStatusNode(statusPtr); |
| 693 | if (ptr) |
| 694 | free(ptr); |
| 695 | } |
| 696 | #endif /* xbsa */ |
| 697 | |
| 698 | return (code); |
| 699 | } |
| 700 | |