Initialize and open difference file for writing
| 247 | |
| 248 | // Initialize and open difference file for writing |
| 249 | void BackupManager::beginBackup(thread_db* tdbb) |
| 250 | { |
| 251 | NBAK_TRACE(("beginBackup")); |
| 252 | |
| 253 | SET_TDBB(tdbb); |
| 254 | |
| 255 | // Check for raw device |
| 256 | if ((!explicit_diff_name) && database->onRawDevice()) { |
| 257 | ERR_post(Arg::Gds(isc_need_difference)); |
| 258 | } |
| 259 | |
| 260 | MasterGuard masterGuard(*this); |
| 261 | |
| 262 | WIN window(HEADER_PAGE_NUMBER); |
| 263 | |
| 264 | StateWriteGuard stateGuard(tdbb, &window); |
| 265 | Ods::header_page* header = (Ods::header_page*) window.win_buffer; |
| 266 | |
| 267 | // Check state |
| 268 | if (backup_state != Ods::hdr_nbak_normal) |
| 269 | { |
| 270 | NBAK_TRACE(("begin backup - invalid state %d", backup_state)); |
| 271 | stateGuard.setSuccess(); |
| 272 | return; |
| 273 | } |
| 274 | |
| 275 | // Check crypt state |
| 276 | if (header->hdr_flags & Ods::hdr_crypt_process) |
| 277 | { |
| 278 | NBAK_TRACE(("begin backup - crypt thread runs")); |
| 279 | stateGuard.setSuccess(); |
| 280 | ERR_post(Arg::Gds(isc_wish_list) << Arg::Gds(isc_random) << |
| 281 | "Cannot begin backup: please wait for crypt thread completion"); |
| 282 | } |
| 283 | |
| 284 | try |
| 285 | { |
| 286 | // Create file |
| 287 | NBAK_TRACE(("Creating difference file %s", diff_name.c_str())); |
| 288 | diff_file = PIO_create(tdbb, diff_name, true, false); |
| 289 | } |
| 290 | catch (const Firebird::Exception&) |
| 291 | { |
| 292 | // no reasons to set it to unknown if we just failed to create difference file |
| 293 | stateGuard.setSuccess(); |
| 294 | backup_state = Ods::hdr_nbak_normal; |
| 295 | throw; |
| 296 | } |
| 297 | |
| 298 | { // logical scope |
| 299 | if (database->dbb_flags & (DBB_force_write | DBB_no_fs_cache)) |
| 300 | { |
| 301 | setForcedWrites(database->dbb_flags & DBB_force_write, |
| 302 | database->dbb_flags & DBB_no_fs_cache); |
| 303 | } |
| 304 | |
| 305 | #ifdef UNIX |
| 306 | // adjust difference file access rights to make it match main DB ones |
nothing calls this directly
no test coverage detected