| 119 | |
| 120 | |
| 121 | int SDW_add_file(thread_db* tdbb, const TEXT* file_name, SLONG start, USHORT shadow_number) |
| 122 | { |
| 123 | /************************************** |
| 124 | * |
| 125 | * S D W _ a d d _ f i l e |
| 126 | * |
| 127 | ************************************** |
| 128 | * |
| 129 | * Functional description |
| 130 | * Add a file to a shadow set. |
| 131 | * Return the sequence number for the new file. |
| 132 | * |
| 133 | **************************************/ |
| 134 | SET_TDBB(tdbb); |
| 135 | Database* dbb = tdbb->getDatabase(); |
| 136 | |
| 137 | SyncLockGuard guard(&dbb->dbb_shadow_sync, SYNC_EXCLUSIVE, "SDW_add_file"); |
| 138 | |
| 139 | // Find the file to be extended |
| 140 | |
| 141 | jrd_file* shadow_file = 0; |
| 142 | Shadow* shadow; |
| 143 | for (shadow = dbb->dbb_shadow; shadow; shadow = shadow->sdw_next) |
| 144 | { |
| 145 | if ((shadow->sdw_number == shadow_number) && |
| 146 | !(shadow->sdw_flags & (SDW_IGNORE | SDW_rollover))) |
| 147 | { |
| 148 | shadow_file = shadow->sdw_file; |
| 149 | break; |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | if (!shadow) { |
| 154 | return 0; |
| 155 | } |
| 156 | |
| 157 | // find the last file in the list, open the new file |
| 158 | |
| 159 | jrd_file* file = shadow_file; |
| 160 | while (file->fil_next) { |
| 161 | file = file->fil_next; |
| 162 | } |
| 163 | |
| 164 | // Verify shadow file path against DatabaseAccess entry of firebird.conf |
| 165 | if (!JRD_verify_database_access(file_name)) |
| 166 | { |
| 167 | ERR_post(Arg::Gds(isc_conf_access_denied) << Arg::Str("database shadow") << |
| 168 | Arg::Str(file_name)); |
| 169 | } |
| 170 | |
| 171 | const SLONG sequence = PIO_add_file(tdbb, shadow_file, file_name, start); |
| 172 | if (!sequence) |
| 173 | return 0; |
| 174 | |
| 175 | jrd_file* next = file->fil_next; |
| 176 | |
| 177 | if (dbb->dbb_flags & (DBB_force_write | DBB_no_fs_cache)) |
| 178 | { |
nothing calls this directly
no test coverage detected