Copy the running binary transactionally. The command-level install path * stages before draining the cohort; this public helper preserves the old * focused regression surface for independent callers. */
| 1420 | * stages before draining the cohort; this public helper preserves the old |
| 1421 | * focused regression surface for independent callers. */ |
| 1422 | int cbm_copy_binary_to_target(const char *src, const char *dst) { |
| 1423 | if (!src || !dst) { |
| 1424 | return CLI_ERR; |
| 1425 | } |
| 1426 | if (cbm_same_file(src, dst)) { |
| 1427 | return CLI_OK; |
| 1428 | } |
| 1429 | cbm_activation_transaction_t *transaction = NULL; |
| 1430 | cbm_activation_transaction_status_t status = |
| 1431 | cbm_activation_transaction_stage_file(dst, src, &transaction); |
| 1432 | cli_binary_validator_t validator; |
| 1433 | if (status != CBM_ACTIVATION_TRANSACTION_OK || !transaction || |
| 1434 | !cli_activation_transaction_expected_build(transaction, &validator)) { |
| 1435 | (void)cli_activation_transaction_abort(&transaction); |
| 1436 | return CLI_ERR; |
| 1437 | } |
| 1438 | if (cli_activation_transaction_commit_validated(transaction, &validator, CLI_OCTAL_PERM) != |
| 1439 | CLI_OK) { |
| 1440 | (void)cli_activation_transaction_abort(&transaction); |
| 1441 | return CLI_ERR; |
| 1442 | } |
| 1443 | return cli_activation_transaction_finalize_close(&transaction); |
| 1444 | } |
| 1445 | |
| 1446 | /* Replace a binary transactionally, retaining the old target until the exact |
| 1447 | * staged bytes have been published and validated. */ |
no test coverage detected