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. */
| 1202 | * stages before draining the cohort; this public helper preserves the old |
| 1203 | * focused regression surface for independent callers. */ |
| 1204 | int cbm_copy_binary_to_target(const char *src, const char *dst) { |
| 1205 | if (!src || !dst) { |
| 1206 | return CLI_ERR; |
| 1207 | } |
| 1208 | if (cbm_same_file(src, dst)) { |
| 1209 | return CLI_OK; |
| 1210 | } |
| 1211 | cbm_activation_transaction_t *transaction = NULL; |
| 1212 | cbm_activation_transaction_status_t status = |
| 1213 | cbm_activation_transaction_stage_file(dst, src, &transaction); |
| 1214 | cli_binary_validator_t validator; |
| 1215 | if (status != CBM_ACTIVATION_TRANSACTION_OK || !transaction || |
| 1216 | !cli_activation_transaction_expected_build(transaction, &validator)) { |
| 1217 | (void)cli_activation_transaction_abort(&transaction); |
| 1218 | return CLI_ERR; |
| 1219 | } |
| 1220 | if (cli_activation_transaction_commit_validated(transaction, &validator, CLI_OCTAL_PERM) != |
| 1221 | CLI_OK) { |
| 1222 | (void)cli_activation_transaction_abort(&transaction); |
| 1223 | return CLI_ERR; |
| 1224 | } |
| 1225 | return cli_activation_transaction_finalize_close(&transaction); |
| 1226 | } |
| 1227 | |
| 1228 | /* Replace a binary transactionally, retaining the old target until the exact |
| 1229 | * staged bytes have been published and validated. */ |
no test coverage detected