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. */
| 1224 | * stages before draining the cohort; this public helper preserves the old |
| 1225 | * focused regression surface for independent callers. */ |
| 1226 | int cbm_copy_binary_to_target(const char *src, const char *dst) { |
| 1227 | if (!src || !dst) { |
| 1228 | return CLI_ERR; |
| 1229 | } |
| 1230 | if (cbm_same_file(src, dst)) { |
| 1231 | return CLI_OK; |
| 1232 | } |
| 1233 | cbm_activation_transaction_t *transaction = NULL; |
| 1234 | cbm_activation_transaction_status_t status = |
| 1235 | cbm_activation_transaction_stage_file(dst, src, &transaction); |
| 1236 | cli_binary_validator_t validator; |
| 1237 | if (status != CBM_ACTIVATION_TRANSACTION_OK || !transaction || |
| 1238 | !cli_activation_transaction_expected_build(transaction, &validator)) { |
| 1239 | (void)cli_activation_transaction_abort(&transaction); |
| 1240 | return CLI_ERR; |
| 1241 | } |
| 1242 | if (cli_activation_transaction_commit_validated(transaction, &validator, CLI_OCTAL_PERM) != |
| 1243 | CLI_OK) { |
| 1244 | (void)cli_activation_transaction_abort(&transaction); |
| 1245 | return CLI_ERR; |
| 1246 | } |
| 1247 | return cli_activation_transaction_finalize_close(&transaction); |
| 1248 | } |
| 1249 | |
| 1250 | /* Replace a binary transactionally, retaining the old target until the exact |
| 1251 | * staged bytes have been published and validated. */ |
no test coverage detected