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. */
| 1179 | * stages before draining the cohort; this public helper preserves the old |
| 1180 | * focused regression surface for independent callers. */ |
| 1181 | int cbm_copy_binary_to_target(const char *src, const char *dst) { |
| 1182 | if (!src || !dst) { |
| 1183 | return CLI_ERR; |
| 1184 | } |
| 1185 | if (cbm_same_file(src, dst)) { |
| 1186 | return CLI_OK; |
| 1187 | } |
| 1188 | cbm_activation_transaction_t *transaction = NULL; |
| 1189 | cbm_activation_transaction_status_t status = |
| 1190 | cbm_activation_transaction_stage_file(dst, src, &transaction); |
| 1191 | cli_binary_validator_t validator; |
| 1192 | if (status != CBM_ACTIVATION_TRANSACTION_OK || !transaction || |
| 1193 | !cli_activation_transaction_expected_build(transaction, &validator)) { |
| 1194 | (void)cli_activation_transaction_abort(&transaction); |
| 1195 | return CLI_ERR; |
| 1196 | } |
| 1197 | if (cli_activation_transaction_commit_validated(transaction, &validator, CLI_OCTAL_PERM) != |
| 1198 | CLI_OK) { |
| 1199 | (void)cli_activation_transaction_abort(&transaction); |
| 1200 | return CLI_ERR; |
| 1201 | } |
| 1202 | return cli_activation_transaction_finalize_close(&transaction); |
| 1203 | } |
| 1204 | |
| 1205 | /* Replace a binary transactionally, retaining the old target until the exact |
| 1206 | * staged bytes have been published and validated. */ |
no test coverage detected