/* get reserved block * anything, except deldir, root, boot, dir and rext */ error_t GetResBlock(cachedblock_t *blok, uint16 bloktype, uint32 seqnr, bool fix) { cachedblock_t blk, *t; uint32 blknr, *bp = NULL, index, offset; error_t error = e_none; // controleer build block lijst t = GetBuildBlock(bloktype, seqnr); if (t) { blok->blocknr = t->blocknr; blok->mode = t->mode; *blok->data = *t->data; return e_none; } blk.data = calloc(1, SIZEOF_RESBLOCK); index = seqnr/INDEX_PER_BLOCK; offset = seqnr%INDEX_PER_BLOCK; switch(bloktype) { case SBLKID: if (seqnr > MAXSUPER) { free (blk.data); return e_number_error; } bp = &rext.data->superindex[seqnr]; if (!*bp) { if (fix) { adderror("superindex block not found"); error = RepairSuperIndex(bp, seqnr); if (error) *bp = 0; else { volume.writeblock((cachedblock_t *)&rext); KillAnodeBitmap(); } } } break; case BMIBLKID: bp = &rbl->idx.large.bitmapindex[seqnr]; if (!*bp) { if (fix) { adderror("bitmapindex block not found"); error = RepairBitmapIndex(bp, seqnr); if (error) *bp = 0; else c_WriteBlock((uint8 *)rbl, ROOTBLOCK + volume.firstblock, volume.blocksize); } } break; case IBLKID: if (rbl->options & MODE_SUPERINDEX) { error = GetResBlock(&blk, SBLKID, index, fix); if (error) { free (blk.data); return error; } bp = &blk.data->indexblock.index[offset]; } else { bp = &rbl->idx.small.indexblocks[seqnr]; } if (!*bp) { if (fix) { adderror("anodeindex block not found"); error = RepairAnodeIndex(bp, seqnr); if (error) *bp = 0; else { /* the anodebitmap, which is made per aib, * could be too small */ KillAnodeBitmap(); if (rbl->options & MODE_SUPERINDEX) volume.writeblock((cachedblock_t *)&blk); else c_WriteBlock((uint8 *)rbl, ROOTBLOCK + volume.firstblock, volume.blocksize); } } } break; case ABLKID: error = GetResBlock(&blk, IBLKID, index, fix); if (error) { free (blk.data); return error; } bp = &blk.data->indexblock.index[offset]; if (!*bp) { if (fix) { adderror("anode block not found"); // RepairAnodeBlock already called from RepairAnodeTree // Pointless to call it again here. //if (error = RepairAnodeBlock(bp, seqnr)) // *bp = 0; //else // volume.writeblock((cachedblock_t *)&blk); } } break; case BMBLKID: error = GetResBlock(&blk, BMIBLKID, index, fix); if (error) { free (blk.data); return error; } bp = &blk.data->indexblock.index[offset]; if (!*bp) { if (fix) { adderror("bitmap block not found"); error = RepairBitmapBlock(bp, seqnr); if (error) *bp = 0; else volume.writeblock((cachedblock_t *)&blk); } } break; } blknr = *bp; free (blk.data); if (!blknr) return e_not_found; error = volume.getblock(blok, blknr); if (error) return error; return e_none; }
static void err_msg_big_integer(const char *msg, int bits, linepos_t epoint) { char msg2[256]; new_error(SV_CONDERROR, current_file_list, epoint); sprintf(msg2, msg, bits); adderror(msg2); }
static void err_msg_str_name(const char *msg, const str_t *name, linepos_t epoint) { new_error(SV_ERROR, current_file_list, epoint); adderror(msg); if (name) str_name(name->data, name->len); }
static void err_msg_char_name(const char *msg, const char *name, linepos_t epoint) { new_error(SV_CONDERROR, current_file_list, epoint); adderror(msg); str_name((const uint8_t *)name, strlen(name)); }
void err_msg2(enum errors_e no, const void *prm, linepos_t epoint) { if (no < 0x40) { new_error(SV_WARNING, current_file_list, epoint); if (!arguments.warning) return; if (no == ERROR_WUSER_DEFINED) adderror2(((value_t)prm)->u.str.data, ((value_t)prm)->u.str.len); else adderror(terr_warning[no]); return; } if (no < 0x80) { char line[1024]; switch (no) { case ERROR____PAGE_ERROR: case ERROR_BRANCH_TOOFAR: case ERROR____PTEXT_LONG: case ERROR__BRANCH_CROSS: case ERROR__USER_DEFINED: case ERROR___UNKNOWN_CHR: case ERROR_CANT_CROSS_BA: case ERROR_OUTOF_SECTION: case ERROR_DIVISION_BY_Z: case ERROR_NO_ZERO_VALUE: case ERROR_CONSTNT_LARGE: case ERROR_NUMERIC_OVERF: case ERROR_NEGFRAC_POWER: case ERROR_SQUARE_ROOT_N: case ERROR_LOG_NON_POSIT: case ERROR___MATH_DOMAIN: new_error(SV_CONDERROR, current_file_list, epoint); break; default: new_error(SV_ERROR, current_file_list, epoint); } switch (no) { case ERROR____PAGE_ERROR: adderror("page error at $"); sprintf(line,"%06" PRIaddress, *(const address_t *)prm); adderror(line); break; case ERROR_BRANCH_TOOFAR: sprintf(line,"branch too far by %+d bytes", *(const int *)prm); adderror(line); break; case ERROR____PTEXT_LONG: sprintf(line,"ptext too long by %lu bytes", (unsigned long)*(const size_t *)prm - 0x100); adderror(line); break; case ERROR__BRANCH_CROSS: adderror("branch crosses page"); break; case ERROR__USER_DEFINED: adderror2(((value_t)prm)->u.str.data, ((value_t)prm)->u.str.len); break; case ERROR___UNKNOWN_CHR: sprintf(line,"can't encode character $%02x", *(const uint32_t *)prm); adderror(line); break; case ERROR______EXPECTED: adderror((char *)prm); adderror(" expected"); break; case ERROR___NOT_ALLOWED: adderror("not allowed here: "); adderror((char *)prm); break; case ERROR_RESERVED_LABL: adderror("reserved symbol name '"); adderror2(((str_t *)prm)->data, ((str_t *)prm)->len); adderror("'"); break; case ERROR_____NOT_BANK0: case ERROR____NOT_DIRECT: case ERROR__NOT_DATABANK: adderror(terr_error[no & 63]); adderror(" '"); err_msg_variable((value_t)prm, epoint); adderror("'"); break; case ERROR___UNKNOWN_CPU: adderror("unknown processor "); err_msg_variable((value_t)prm, epoint); break; default: adderror(terr_error[no & 63]); } return; } new_error(SV_FATAL, current_file_list, epoint); switch (no) { case ERROR_UNKNOWN_OPTIO: adderror("unknown option '"); adderror2(((str_t *)prm)->data, ((str_t *)prm)->len); adderror("'"); break; default: adderror(terr_fatal[no & 63]); } status(1);exit(1); }