void dse_f_free(void) { block_id blk; boolean_t in_last_bmap, was_crit, was_hold_onto_crit; cache_rec_ptr_t dummy_cr; char util_buff[MAX_UTIL_LEN]; int4 bplmap, dummy_int, hint_mod_bplmap, hint_over_bplmap; int4 lmap_bit, master_bit, nocrit_present, total_blks, util_len; sm_uc_ptr_t lmap_base; if (0 == cs_addrs->hdr->bplmap) { util_out_print("Cannot perform free block search: bplmap field of file header is zero.", TRUE); return; } bplmap = cs_addrs->hdr->bplmap; if (BADDSEBLK == (blk = dse_getblk("HINT", DSEBMLOK, DSEBLKNOCUR))) /* WARNING: assignment */ return; hint_over_bplmap = blk / bplmap; master_bit = bmm_find_free(hint_over_bplmap, cs_addrs->bmm, (cs_addrs->ti->total_blks + bplmap - 1)/ bplmap); if (-1 == master_bit) { util_out_print("Error: database full.", TRUE); return; } in_last_bmap = (master_bit == (cs_addrs->ti->total_blks / bplmap)); was_crit = cs_addrs->now_crit; nocrit_present = (CLI_NEGATED == cli_present("CRIT")); DSE_GRAB_CRIT_AS_APPROPRIATE(was_crit, was_hold_onto_crit, nocrit_present, cs_addrs, gv_cur_region); if(!(lmap_base = t_qread(master_bit * bplmap, &dummy_int, &dummy_cr))) rts_error_csa(CSA_ARG(cs_addrs) VARLSTCNT(1) ERR_DSEBLKRDFAIL); if (master_bit == hint_over_bplmap) hint_mod_bplmap = blk - blk / bplmap * bplmap; else hint_mod_bplmap = 0; if (in_last_bmap) total_blks = (cs_addrs->ti->total_blks - master_bit); else total_blks = bplmap; lmap_bit = bml_find_free(hint_mod_bplmap, lmap_base + SIZEOF(blk_hdr), total_blks); if (-1 == lmap_bit) { memcpy(util_buff, "Error: bit map in block ", 24); util_len = 24; util_len += i2hex_nofill(master_bit * bplmap, (uchar_ptr_t)&util_buff[util_len], 8); memcpy(&util_buff[util_len], " incorrectly marked free in master map.", 39); util_len += 39; util_buff[util_len] = 0; util_out_print(util_buff, TRUE); DSE_REL_CRIT_AS_APPROPRIATE(was_crit, was_hold_onto_crit, nocrit_present, cs_addrs, gv_cur_region); return; } memcpy(util_buff, "!/Next free block is ", 21); util_len = 21; util_len += i2hex_nofill(master_bit * bplmap + lmap_bit, (uchar_ptr_t)&util_buff[util_len], 8); memcpy(&util_buff[util_len], ".!/", 3); util_len += 3; util_buff[util_len] = 0; util_out_print(util_buff, TRUE); DSE_REL_CRIT_AS_APPROPRIATE(was_crit, was_hold_onto_crit, nocrit_present, cs_addrs, gv_cur_region); return; }
void dse_range(void) { char lower[256], targ_key[256], upper[256], util_buff[MAX_UTIL_LEN]; block_id from, to, blk, blk_child; sm_uc_ptr_t bp, b_top, key_bot, key_top, key_top1, rp, r_top; char level; int4 dummy_int, nocrit_present; cache_rec_ptr_t dummy_cr; short int rsize, size, size1; int cnt, dummy, lower_len, util_len, upper_len; boolean_t busy_matters, free, got_lonely_star, index, low, lost, star, up, was_crit, was_hold_onto_crit; if (cli_present("FROM") == CLI_PRESENT) { if (!cli_get_hex("FROM", (uint4 *)&from)) return; if (from < 0 || from > cs_addrs->ti->total_blks || !(from % cs_addrs->hdr->bplmap)) { util_out_print("Error: invalid block number.", TRUE); return; } } else from = 1; if (cli_present("TO") == CLI_PRESENT) { if(!cli_get_hex("TO", (uint4 *)&to)) return; if (to < 0 || to > cs_addrs->ti->total_blks || !(to % cs_addrs->hdr->bplmap)) { util_out_print("Error: invalid block number.", TRUE); return; } } else to = cs_addrs->ti->total_blks - 1; if (low = (cli_present("LOWER") == CLI_PRESENT)) { if (!dse_getki(&lower[0], &lower_len, LIT_AND_LEN("LOWER"))) return; } if (up = (cli_present("UPPER") == CLI_PRESENT)) { if (!dse_getki(&upper[0], &upper_len, LIT_AND_LEN("UPPER"))) return; } star = (cli_present("STAR") == CLI_PRESENT); if (!low && !up && !star) { util_out_print("Must specify star, or a lower or upper key limit.", TRUE); return; } index = (cli_present("INDEX") == CLI_PRESENT); lost = (cli_present("LOST") == CLI_PRESENT); dummy = cli_present("BUSY"); if (dummy == CLI_PRESENT) { busy_matters = TRUE; free = FALSE; } else if (dummy == CLI_NEGATED) busy_matters = free = TRUE; else busy_matters = free = FALSE; patch_path[0] = get_dir_root(); cnt = 0; was_crit = cs_addrs->now_crit; nocrit_present = (CLI_NEGATED == cli_present("CRIT")); DSE_GRAB_CRIT_AS_APPROPRIATE(was_crit, was_hold_onto_crit, nocrit_present, cs_addrs, gv_cur_region); for (blk = from; blk <= to ;blk++) { if (util_interrupt) { DSE_REL_CRIT_AS_APPROPRIATE(was_crit, was_hold_onto_crit, nocrit_present, cs_addrs, gv_cur_region); rts_error(VARLSTCNT(1) ERR_CTRLC); break; } if (!(blk % cs_addrs->hdr->bplmap)) continue; if (!(bp = t_qread(blk, &dummy_int, &dummy_cr))) rts_error(VARLSTCNT(1) ERR_DSEBLKRDFAIL); level = ((blk_hdr_ptr_t)bp)->levl; if (index && (level == 0)) continue; if (busy_matters && (free != dse_is_blk_free(blk, &dummy_int, &dummy_cr))) continue; if (((blk_hdr_ptr_t) bp)->bsiz > cs_addrs->hdr->blk_size) b_top = bp + cs_addrs->hdr->blk_size; else if (((blk_hdr_ptr_t) bp)->bsiz < SIZEOF(blk_hdr)) b_top = bp + SIZEOF(blk_hdr); else b_top = bp + ((blk_hdr_ptr_t) bp)->bsiz; rp = bp + SIZEOF(blk_hdr); GET_SHORT(rsize, &((rec_hdr_ptr_t) rp)->rsiz); if (rsize < SIZEOF(rec_hdr)) r_top = rp + SIZEOF(rec_hdr); else r_top = rp + rsize; if (r_top >= b_top) r_top = b_top; got_lonely_star = FALSE; if (((blk_hdr_ptr_t) bp)->levl) { key_top = r_top - SIZEOF(block_id); if (star && (r_top == b_top)) got_lonely_star = TRUE; } else { if (!up && !low) continue; for (key_top = rp + SIZEOF(rec_hdr); key_top < r_top ; ) if (!*key_top++ && !*key_top++) break; } if (!got_lonely_star) { key_bot = rp + SIZEOF(rec_hdr); size = key_top - key_bot; if (size <= 0) continue; if (size > SIZEOF(targ_key)) size = SIZEOF(targ_key); if (lost) { for (key_top1 = rp + SIZEOF(rec_hdr); key_top1 < r_top ; ) if (!*key_top1++) break; size1 = key_top1 - rp - SIZEOF(rec_hdr); if (size1 > SIZEOF(targ_key)) size1 = SIZEOF(targ_key); patch_find_root_search = TRUE; patch_path_count = 1; patch_find_blk = blk; if (dse_is_blk_in(rp, r_top, size1)) continue; } if (low && memcmp(lower, key_bot, MIN(lower_len, size)) > 0) continue; if (up && memcmp(upper, key_bot, MIN(upper_len, size)) < 0) continue; } else { got_lonely_star = FALSE; if (lost) { blk_child = *(block_id_ptr_t)key_top; if (!(bp = t_qread(blk_child, &dummy_int, &dummy_cr))) rts_error(VARLSTCNT(1) ERR_DSEBLKRDFAIL); if (((blk_hdr_ptr_t) bp)->bsiz > cs_addrs->hdr->blk_size) b_top = bp + cs_addrs->hdr->blk_size; else if (((blk_hdr_ptr_t) bp)->bsiz < SIZEOF(blk_hdr)) b_top = bp + SIZEOF(blk_hdr); else b_top = bp + ((blk_hdr_ptr_t) bp)->bsiz; rp = bp + SIZEOF(blk_hdr); GET_SHORT(rsize, &((rec_hdr_ptr_t) rp)->rsiz); if (rsize < SIZEOF(rec_hdr)) r_top = rp + SIZEOF(rec_hdr); else r_top = rp + rsize; if (r_top >= b_top) r_top = b_top; if (((blk_hdr_ptr_t) bp)->levl) key_top = r_top - SIZEOF(block_id); for (key_top1 = rp + SIZEOF(rec_hdr); key_top1 < r_top ; ) if (!*key_top1++) break; size1 = key_top1 - rp - SIZEOF(rec_hdr); if (size1 > 0) { if (size1 > SIZEOF(targ_key)) size1 = SIZEOF(targ_key); patch_find_root_search = TRUE; patch_path_count = 1; patch_find_blk = blk; if (dse_is_blk_in(rp, r_top, size1)) continue; } } } if (!cnt++) util_out_print("!/Blocks in the specified key range:", TRUE); util_out_print("Block: !8XL Level: !2UL", TRUE, blk, level); } DSE_REL_CRIT_AS_APPROPRIATE(was_crit, was_hold_onto_crit, nocrit_present, cs_addrs, gv_cur_region); if (cnt) util_out_print("Found !UL blocks", TRUE, cnt); else util_out_print("None found.", TRUE); return; }
boolean_t dse_r_dmp(void) { block_id blk; sm_uc_ptr_t bp, b_top, rp; int4 count; int4 dummy_int; cache_rec_ptr_t dummy_cr; short record, size; boolean_t was_crit; int4 nocrit_present; error_def(ERR_DSEBLKRDFAIL); error_def(ERR_CTRLC); if (cli_present("BLOCK") == CLI_PRESENT) { uint4 tmp_blk; if(!cli_get_hex("BLOCK", &tmp_blk)) return FALSE; blk = (block_id)tmp_blk; if (blk < 0 || blk >= cs_addrs->ti->total_blks || !(blk % cs_addrs->hdr->bplmap)) { util_out_print("Error: invalid block number.", TRUE); return FALSE; } patch_curr_blk = blk; } if (cli_present("COUNT") == CLI_PRESENT) { if (!cli_get_hex("COUNT", (uint4 *)&count)) return FALSE; } else count = 1; was_crit = cs_addrs->now_crit; nocrit_present = (CLI_NEGATED == cli_present("CRIT")); DSE_GRAB_CRIT_AS_APPROPRIATE(was_crit, nocrit_present, cs_addrs, gv_cur_region); if (!(bp = t_qread(patch_curr_blk, &dummy_int, &dummy_cr))) rts_error(VARLSTCNT(1) ERR_DSEBLKRDFAIL); if (((blk_hdr_ptr_t) bp)->bsiz > cs_addrs->hdr->blk_size) b_top = bp + cs_addrs->hdr->blk_size; else if (((blk_hdr_ptr_t) bp)->bsiz < SIZEOF(blk_hdr)) b_top = bp + SIZEOF(blk_hdr); else b_top = bp + ((blk_hdr_ptr_t) bp)->bsiz; if (((blk_hdr_ptr_t) bp)->levl && patch_is_fdmp) { DSE_REL_CRIT_AS_APPROPRIATE(was_crit, nocrit_present, cs_addrs, gv_cur_region); util_out_print("Error: cannot perform GLO/ZWR dump on index block.", TRUE); return FALSE; } if (cli_present("RECORD") == CLI_PRESENT) { if (!(rp = skan_rnum (bp, FALSE))) { DSE_REL_CRIT_AS_APPROPRIATE(was_crit, nocrit_present, cs_addrs, gv_cur_region); return FALSE; } } else if (!(rp = skan_offset (bp, FALSE))) { DSE_REL_CRIT_AS_APPROPRIATE(was_crit, nocrit_present, cs_addrs, gv_cur_region); return FALSE; } util_out_print(0, TRUE); for ( ; 0 < count; count--) { if (util_interrupt || !(rp = dump_record(rp, patch_curr_blk, bp, b_top))) break; patch_rec_counter += 1; } DSE_REL_CRIT_AS_APPROPRIATE(was_crit, nocrit_present, cs_addrs, gv_cur_region); if (util_interrupt) rts_error(VARLSTCNT(1) ERR_CTRLC); else if (cli_present("HEADER") == CLI_NEGATED) util_out_print(0, TRUE); return TRUE; }
boolean_t dse_b_dmp(void) { int4 util_len, head, lmap_num, iter1, iter2, mapsize, bplmap, nocrit_present, dummy_int, len, count; unsigned char util_buff[MAX_UTIL_LEN], mask; boolean_t free, was_crit, invalid_bitmap = FALSE, is_mm; block_id blk; sm_uc_ptr_t bp, b_top, rp, mb, dump_record(sm_uc_ptr_t rp, block_id blk, sm_uc_ptr_t bp, sm_uc_ptr_t b_top); cache_rec_ptr_t cr; enum db_ver ondsk_blkver; error_def(ERR_DSEBLKRDFAIL); error_def(ERR_CTRLC); error_def(ERR_BITMAPSBAD); head = cli_present("HEADER"); if (CLI_PRESENT == cli_present("BLOCK")) { if (!cli_get_hex("BLOCK", (uint4 *)&blk)) return FALSE; if (blk < 0 || blk >= cs_addrs->ti->total_blks) { util_out_print("Error: invalid block number.", TRUE); return FALSE; } patch_curr_blk = blk; } else blk = patch_curr_blk; if (CLI_PRESENT == cli_present("COUNT")) { if (!cli_get_hex("COUNT", (uint4 *)&count)) return FALSE; if (count < 1) return FALSE; } else count = 1; util_out_print(0, TRUE); bplmap = cs_addrs->hdr->bplmap; is_mm = (dba_mm == cs_addrs->hdr->acc_meth); mapsize = BM_SIZE(bplmap); patch_rec_counter = 1; was_crit = cs_addrs->now_crit; nocrit_present = (CLI_NEGATED == cli_present("CRIT")); DSE_GRAB_CRIT_AS_APPROPRIATE(was_crit, nocrit_present, cs_addrs, gv_cur_region); for ( ; ; ) { if (blk / bplmap * bplmap != blk) { if (!(bp = t_qread(blk, &dummy_int, &cr))) { DSE_REL_CRIT_AS_APPROPRIATE(was_crit, nocrit_present, cs_addrs, gv_cur_region); rts_error(VARLSTCNT(1) ERR_DSEBLKRDFAIL); } if (((blk_hdr_ptr_t) bp)->levl && patch_is_fdmp) { DSE_REL_CRIT_AS_APPROPRIATE(was_crit, nocrit_present, cs_addrs, gv_cur_region); util_out_print("Error: cannot perform GLO/ZWR dump on index block.", TRUE); return FALSE; } if (((blk_hdr_ptr_t) bp)->bsiz > cs_addrs->hdr->blk_size) b_top = bp + cs_addrs->hdr->blk_size; else if (((blk_hdr_ptr_t) bp)->bsiz < SIZEOF(blk_hdr)) b_top = bp + SIZEOF(blk_hdr); else b_top = bp + ((blk_hdr_ptr_t) bp)->bsiz; if (CLI_NEGATED != head && !patch_is_fdmp) { memcpy(util_buff, "Block ", 6); util_len = 6; util_len += i2hex_nofill(blk, &util_buff[util_len], 8); memcpy(&util_buff[util_len], " Size ", 8); util_len += 8; util_len += i2hex_nofill(((blk_hdr_ptr_t)bp)->bsiz, &util_buff[util_len], 8); memcpy(&util_buff[util_len], " Level !UL TN ", 18); util_len += 18; util_len += i2hexl_nofill(((blk_hdr_ptr_t)bp)->tn, &util_buff[util_len], 16); memcpy(&util_buff[util_len], " ", 1); util_len++; ondsk_blkver = (!is_mm ? cr->ondsk_blkver : GDSV5); len = STRLEN(gtm_dbversion_table[ondsk_blkver]); memcpy(&util_buff[util_len], gtm_dbversion_table[ondsk_blkver], len); util_len += len; memcpy(&util_buff[util_len], "!/", 2); util_len += 2; util_buff[util_len] = 0; util_out_print((caddr_t)util_buff, TRUE, ((blk_hdr_ptr_t) bp)->levl ); } rp = bp + SIZEOF(blk_hdr); if (CLI_PRESENT != head && (!patch_is_fdmp || ((blk_hdr_ptr_t) bp)->levl == 0)) { while (!util_interrupt && (rp = dump_record(rp, blk, bp, b_top))) patch_rec_counter += 1; } if (util_interrupt) { DSE_REL_CRIT_AS_APPROPRIATE(was_crit, nocrit_present, cs_addrs, gv_cur_region); rts_error(VARLSTCNT(1) ERR_CTRLC); break; } if (CLI_NEGATED == head) util_out_print(0, TRUE); } else if (!patch_is_fdmp) { if (!(bp = t_qread(blk, &dummy_int, &cr))) { DSE_REL_CRIT_AS_APPROPRIATE(was_crit, nocrit_present, cs_addrs, gv_cur_region); rts_error(VARLSTCNT(1) ERR_DSEBLKRDFAIL); } if (CLI_NEGATED != head) { if (bplmap == 0) { memcpy(util_buff, "Block ", 6); util_len = 6; util_len += i2hex_nofill(blk, &util_buff[util_len], 8); memcpy(&util_buff[util_len], " Size ", 8); util_len += 8; util_len += i2hex_nofill(mapsize, &util_buff[util_len], 4); memcpy(&util_buff[util_len], " Master Status: Cannot Determine (bplmap == 0)!/", 50); util_len += 50; util_buff[util_len] = 0; util_out_print((caddr_t)util_buff, TRUE ); } else { mb = cs_addrs->bmm + blk / (8 * bplmap); lmap_num = blk / bplmap; mask = 1 << ( lmap_num - lmap_num / 8 * 8); free = mask & *mb; memcpy(util_buff, "Block ", 6); util_len = 6; util_len += i2hex_nofill(blk, &util_buff[util_len], 8); memcpy(&util_buff[util_len], " Size ", 7); util_len += 7; util_len += i2hex_nofill(((blk_hdr_ptr_t)bp)->bsiz, &util_buff[util_len], 8); memcpy(&util_buff[util_len], " Level !SB TN ", 16); util_len += 16; util_len += i2hexl_nofill(((blk_hdr_ptr_t)bp)->tn, &util_buff[util_len], 16); memcpy(&util_buff[util_len], " ", 1); util_len++; ondsk_blkver = (!is_mm ? cr->ondsk_blkver : GDSV5); len = STRLEN(gtm_dbversion_table[ondsk_blkver]); memcpy(&util_buff[util_len], gtm_dbversion_table[ondsk_blkver], len); util_len += len; util_buff[util_len] = 0; util_out_print((caddr_t)util_buff, FALSE, ((blk_hdr_ptr_t) bp)->levl ); util_len = 0; memcpy(&util_buff[util_len], " Master Status: !AD!/",23); util_len = 23; util_buff[util_len] = 0; util_out_print((caddr_t)util_buff, TRUE, free ? 10 : 4, free ? "Free Space" : "Full"); } } if (CLI_PRESENT != head) { util_out_print(" !_Low order High order", TRUE); lmap_num = 0; while (lmap_num < bplmap) { memcpy(util_buff, "Block ", 6); util_len = 6; i2hex_blkfill(blk + lmap_num, &util_buff[util_len], 8); util_len += 8; memcpy(&util_buff[util_len], ":!_| ", 6); util_len += 6; util_buff[util_len] = 0; util_out_print((caddr_t)util_buff, FALSE); for (iter1 = 0; iter1 < 4; iter1++) { for (iter2 = 0; iter2 < 8; iter2++) { mask = dse_lm_blk_free(lmap_num * BML_BITS_PER_BLK, bp + SIZEOF(blk_hdr)); if (!mask) util_out_print("!AD", FALSE, 1, BUSY_CHAR); else if (BLK_FREE == mask) util_out_print("!AD", FALSE, 1, FREE_CHAR); else if (BLK_RECYCLED == mask) util_out_print("!AD", FALSE, 1, REUSABLE_CHAR); else { invalid_bitmap = TRUE; util_out_print("!AD", FALSE, 1, CORRUPT_CHAR); } if (++lmap_num >= bplmap) break; } util_out_print(" ", FALSE); if (lmap_num >= bplmap) break; } util_out_print("|", TRUE); if (util_interrupt) { DSE_REL_CRIT_AS_APPROPRIATE(was_crit, nocrit_present, cs_addrs, gv_cur_region); rts_error(VARLSTCNT(1) ERR_CTRLC); } } util_out_print("!/'!AD' == BUSY '!AD' == FREE '!AD' == REUSABLE '!AD' == CORRUPT!/", TRUE,1, BUSY_CHAR, 1, FREE_CHAR, 1, REUSABLE_CHAR, 1, CORRUPT_CHAR); if (invalid_bitmap) { DSE_REL_CRIT_AS_APPROPRIATE(was_crit, nocrit_present, cs_addrs, gv_cur_region); rts_error(VARLSTCNT(1) ERR_BITMAPSBAD); } } } count--; if (count <= 0 || util_interrupt) break; blk++; if (blk >= cs_addrs->ti->total_blks) blk = 0; } patch_curr_blk = blk; DSE_REL_CRIT_AS_APPROPRIATE(was_crit, nocrit_present, cs_addrs, gv_cur_region); return TRUE; }
void dse_f_key(void) { block_id path[MAX_BT_DEPTH + 1], root_path[MAX_BT_DEPTH + 1]; int4 offset[MAX_BT_DEPTH + 1], root_offset[MAX_BT_DEPTH + 1], nocrit_present; char targ_key[MAX_KEY_SZ + 1], targ_key_root[MAX_KEY_SZ + 1], *key_top, util_buff[MAX_UTIL_LEN]; int size, size_root, root_path_count, count, util_len; boolean_t found, was_crit, was_hold_onto_crit; if (!dse_getki(&targ_key[0], &size, LIT_AND_LEN("KEY"))) return; patch_path_count = 1; root_path[0] = get_dir_root(); for (key_top = &targ_key[0]; key_top < ARRAYTOP(targ_key); ) if (!*key_top++) break; size_root = (int)(key_top - &targ_key[0] + 1); memcpy(&targ_key_root[0],&targ_key[0],size_root); targ_key_root[size_root - 1] = targ_key_root[size_root] = 0; patch_find_root_search = TRUE; was_crit = cs_addrs->now_crit; nocrit_present = (CLI_NEGATED == cli_present("CRIT")); DSE_GRAB_CRIT_AS_APPROPRIATE(was_crit, was_hold_onto_crit, nocrit_present, cs_addrs, gv_cur_region); if (!dse_key_srch(root_path[0], &root_path[1], &root_offset[0], &targ_key_root[0], size_root)) { util_out_print("!/Key not found, no root present.!/",TRUE); DSE_REL_CRIT_AS_APPROPRIATE(was_crit, was_hold_onto_crit, nocrit_present, cs_addrs, gv_cur_region); return; } root_path_count = patch_path_count; patch_path_count = 1; path[0] = ksrch_root; patch_find_root_search = FALSE; if (!dse_key_srch(path[0], &path[1], &offset[0], &targ_key[0], size)) { memcpy(util_buff,"!/Key not found, would be in block ",36); util_len = 36; util_len += i2hex_nofill(path[patch_path_count - 2], (uchar_ptr_t)&util_buff[util_len], 8); memcpy(&util_buff[util_len], ".",1); util_len += 1; util_buff[util_len] = 0; util_out_print(util_buff,FALSE); patch_path_count -= 1; }else { memcpy(util_buff,"!/Key found in block ",22); util_len = 22; util_len += i2hex_nofill(path[patch_path_count - 1], (uchar_ptr_t)&util_buff[util_len], 8); memcpy(&util_buff[util_len], ".",1); util_len += 1; util_buff[util_len] = 0; util_out_print(util_buff,FALSE); } util_out_print("!/ Directory path!/ Path--blk:off",TRUE); for (count = 0; count < root_path_count ;count++) { memcpy(util_buff," ",1); util_len = 1; util_len += i2hex_nofill(root_path[count],(uchar_ptr_t)&util_buff[util_len], 8); memcpy(&util_buff[util_len],":",1); util_len += 1; util_len += i2hex_nofill(root_offset[count],(uchar_ptr_t)&util_buff[util_len], 4); memcpy(&util_buff[util_len],",",1); util_len += 1; util_buff[util_len] = 0; util_out_print(util_buff,FALSE); } util_out_print("!/ Global tree path!/ Path--blk:off",TRUE); if (patch_path_count) { for (count = 0; count < patch_path_count ;count++) { memcpy(util_buff," ",1); util_len = 1; util_len += i2hex_nofill(path[count],(uchar_ptr_t)&util_buff[util_len], 8); memcpy(&util_buff[util_len],":",1); util_len += 1; util_len += i2hex_nofill(offset[count],(uchar_ptr_t)&util_buff[util_len], 4); memcpy(&util_buff[util_len],",",1); util_len += 1; util_buff[util_len] = 0; util_out_print(util_buff,FALSE); } util_out_print(0,TRUE); } else { memcpy(util_buff," ",1); util_len = 1; util_len += i2hex_nofill(root_path[count],(uchar_ptr_t)&util_buff[util_len], 8); memcpy(&util_buff[util_len],"!/",2); util_len += 2; util_buff[util_len] = 0; util_out_print(util_buff,TRUE); } DSE_REL_CRIT_AS_APPROPRIATE(was_crit, was_hold_onto_crit, nocrit_present, cs_addrs, gv_cur_region); return; }
void dse_f_free(void) { block_id blk; bool in_last_bmap; char util_buff[MAX_UTIL_LEN]; sm_uc_ptr_t lmap_base; int4 bplmap, total_blks; int4 util_len, master_bit, lmap_bit, hint_over_bplmap, hint_mod_bplmap; boolean_t was_crit; int4 dummy_int, nocrit_present; cache_rec_ptr_t dummy_cr; error_def(ERR_DSEBLKRDFAIL); if (cs_addrs->hdr->bplmap == 0) { util_out_print("Cannot perform free block search: bplmap field of file header is zero.", TRUE); return; } bplmap = cs_addrs->hdr->bplmap; if(!cli_get_hex("HINT", (uint4 *)&blk)) return; if (blk < 0 || blk >= cs_addrs->ti->total_blks || (blk / bplmap * bplmap == blk)) { util_out_print("Error: invalid block number.", TRUE); return; } hint_over_bplmap = blk / bplmap; master_bit = bmm_find_free(hint_over_bplmap, cs_addrs->bmm, (cs_addrs->ti->total_blks + bplmap - 1)/ bplmap); if (master_bit == -1) { util_out_print("Error: database full.", TRUE); return; } in_last_bmap = (master_bit == (cs_addrs->ti->total_blks / bplmap)); was_crit = cs_addrs->now_crit; nocrit_present = (CLI_NEGATED == cli_present("CRIT")); DSE_GRAB_CRIT_AS_APPROPRIATE(was_crit, nocrit_present, cs_addrs, gv_cur_region); if(!(lmap_base = t_qread(master_bit * bplmap, &dummy_int, &dummy_cr))) rts_error(VARLSTCNT(1) ERR_DSEBLKRDFAIL); if (master_bit == hint_over_bplmap) hint_mod_bplmap = blk - blk / bplmap * bplmap; else hint_mod_bplmap = 0; if (in_last_bmap) total_blks = (cs_addrs->ti->total_blks - master_bit); else total_blks = bplmap; lmap_bit = bml_find_free(hint_mod_bplmap, lmap_base + SIZEOF(blk_hdr), total_blks); if (lmap_bit == -1) { memcpy(util_buff, "Error: bit map in block ", 24); util_len = 24; util_len += i2hex_nofill(master_bit * bplmap, (uchar_ptr_t)&util_buff[util_len], 8); memcpy(&util_buff[util_len], " incorrectly marked free in master map.", 39); util_len += 39; util_buff[util_len] = 0; util_out_print(util_buff, TRUE); DSE_REL_CRIT_AS_APPROPRIATE(was_crit, nocrit_present, cs_addrs, gv_cur_region); return; } memcpy(util_buff, "!/Next free block is ", 21); util_len = 21; util_len += i2hex_nofill(master_bit * bplmap + lmap_bit, (uchar_ptr_t)&util_buff[util_len], 8); memcpy(&util_buff[util_len], ".!/", 3); util_len += 3; util_buff[util_len] = 0; util_out_print(util_buff, TRUE); DSE_REL_CRIT_AS_APPROPRIATE(was_crit, nocrit_present, cs_addrs, gv_cur_region); return; }