void mu_signal_process(char *command, int signal) { boolean_t pid_present, name_present; int4 pid, length, status, item, outv; char prc_nam[20]; unsigned short name_len; $DESCRIPTOR(d_prc_nam,""); memset(prc_nam, 0, SIZEOF(prc_nam)); pid_present = name_present = FALSE; if (cli_present("id") == CLI_PRESENT) { if(!cli_get_hex("id", &pid)) return; pid_present = TRUE; } if (cli_present("name") == CLI_PRESENT) { name_len = 20; if (!cli_get_str("name", prc_nam, &name_len)) return; if (prc_nam[name_len-1] == '"') name_len--; if (prc_nam[0] == '"') { d_prc_nam.dsc$a_pointer = &prc_nam[1]; name_len--; } else d_prc_nam.dsc$a_pointer = &prc_nam; d_prc_nam.dsc$w_length = name_len; name_present = TRUE; } if (!name_present) { if (SS$_NORMAL == send_signal(pid, signal)) SENDMSG_OUTPUT("", pid); return; } item = JPI$_PID; status = lib$getjpi(&item, 0, &d_prc_nam, &outv, 0, 0); if (SS$_NORMAL != status) { rts_error(VARLSTCNT(1) status); return; } if (!pid_present) { if (SS$_NORMAL == send_signal(outv, signal)) SENDMSG_OUTPUT(&prc_nam, outv); return; } if (outv != pid) { util_out_print("ID !XL and NAME !AD are not the same process", FLUSH, pid, LEN_AND_STR(&prc_nam)); return; } if (SS$_NORMAL == send_signal(pid, signal)) SENDMSG_OUTPUT(&prc_nam, pid); return; }
void dse_integ(void) { block_id blk; char util_buff[MAX_UTIL_LEN]; sm_uc_ptr_t bp; int4 dummy_int, nocrit_present; cache_rec_ptr_t dummy_cr; int util_len; bool was_crit; error_def(ERR_DSEBLKRDFAIL); if (CLI_PRESENT == cli_present("BLOCK")) { if (!cli_get_hex("BLOCK", &blk)) return; if (blk < 0 || blk >= cs_addrs->ti->total_blks) { util_out_print("Error: invalid block number.", TRUE); return; } patch_curr_blk = blk; } memcpy(util_buff, "!/Checking integrity of block ", 30); util_len = 30; util_len += i2hex_nofill(patch_curr_blk, (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, TRUE); was_crit = cs_addrs->now_crit; nocrit_present = (CLI_NEGATED == cli_present("CRIT")); if (!was_crit) { if (nocrit_present) cs_addrs->now_crit = TRUE; else grab_crit(gv_cur_region); } if (!(bp = t_qread(patch_curr_blk, &dummy_int, &dummy_cr))) rts_error(VARLSTCNT(1) ERR_DSEBLKRDFAIL); if (TRUE == cert_blk(gv_cur_region, patch_curr_blk, (blk_hdr_ptr_t)bp, 0)) util_out_print("!/ No errors detected.!/", TRUE); else util_out_print(NULL, TRUE); if (!was_crit) { if (nocrit_present) cs_addrs->now_crit = FALSE; else rel_crit(gv_cur_region); } return; }
void dse_remove(void) { if (cli_present("RECORD") == CLI_PRESENT) { dse_rmrec(); }else if (cli_present("BLOCK") == CLI_PRESENT) { dse_rmsb(); } return; }
int mdsdcl_set_command( /* Return: status */ struct _mdsdcl_ctrl *ctrl /* <m> the control structure */ ) { int sts; void *newTable; static DYNAMIC_DESCRIPTOR(dsc_table); /*------------------------------------------------------ * Get tablename and find its address in shared library ... *-----------------------------------------------------*/ sts = cli_get_value("TABLE",&dsc_table); if (sts & 1) { int i; for (i=0;i<dsc_table.dscW_length;i++) dsc_table.dscA_pointer[i] = _tolower(dsc_table.dscA_pointer[i]); if (!strstr(dsc_table.dscA_pointer,"_commands")) str_concat(&dsc_table,&dsc_table,"_commands",0); sts = LibFindImageSymbol(&dsc_table,&dsc_table,&newTable); if (~sts & 1) return(MdsMsg(sts,"Failed to open table %s", dsc_table.dscA_pointer)); /*------------------------------------------------------ *... add newTable address to "tbladr[]" list *-----------------------------------------------------*/ for (i=0 ; i<ctrl->tables ; i++) if (newTable == ctrl->tbladr[i]) break; if (i == ctrl->tables) { if (ctrl->tables >= MAX_TABLES) { fprintf(stderr,"set_command: *WARN* Max_tables exceeded\n"); return(0); } ctrl->tbladr[ctrl->tables++] = newTable; } } /*------------------------------------------------------ * Check for other qualifiers ... *-----------------------------------------------------*/ if (cli_present("HELPLIB") & 1) cli_get_value("HELPLIB",&ctrl->helplib); if (cli_present("PROMPT") & 1) cli_get_value("PROMPT",&ctrl->prompt); if (cli_present("DEF_FILE") & 1) cli_get_value("DEF_FILE",&ctrl->def_file); return(1); }
void dse_dmp(void) { boolean_t dmp_res, glo_present, zwr_present; patch_fdmp_recs = 0; glo_present = (CLI_PRESENT == cli_present("GLO")); zwr_present = (CLI_PRESENT == cli_present("ZWR")); if (glo_present || zwr_present) { if (CLOSED_FMT == dse_dmp_format) { util_out_print("Error: must open an output file before dump.", TRUE); return; } if (gtm_utf8_mode && (GLO_FMT == glo_present)) { util_out_print("Error: GLO format is not supported in UTF-8 mode. Use ZWR format.", TRUE); return; } if (OPEN_FMT == dse_dmp_format) { dse_dmp_format = (glo_present ? GLO_FMT : ZWR_FMT); if (!gtm_utf8_mode) dse_fdmp_output(LIT_AND_LEN("; DSE EXTRACT")); else dse_fdmp_output(LIT_AND_LEN("; DSE EXTRACT UTF-8")); dse_fdmp_output(STR_AND_LEN(format_label[dse_dmp_format])); } else if ((glo_present ? GLO_FMT : ZWR_FMT) != dse_dmp_format) { util_out_print("Error: current output file already contains !AD records.", TRUE, LEN_AND_STR(&format_label[dse_dmp_format][MESS_OFF])); return; } patch_is_fdmp = TRUE; ESTABLISH(dse_dmp_handler); } else patch_is_fdmp = FALSE; if (CLI_PRESENT == cli_present("RECORD") || CLI_PRESENT == cli_present("OFFSET")) dmp_res = dse_r_dmp(); else dmp_res = dse_b_dmp(); if (patch_is_fdmp) { REVERT; if (dmp_res) util_out_print("!UL !AD records written.!/", TRUE, patch_fdmp_recs, LEN_AND_STR(&format_label[dse_dmp_format][MESS_OFF])); } return; }
void mupip_freeze(void) { int4 status; bool record; tp_region *rptr, *rptr1; boolean_t freeze, override; uint4 online; freeze_status freeze_ret; int dummy_errno; const char *msg1[] = { "unfreeze", "freeze" } ; const char *msg2[] = { "UNFROZEN", "FROZEN" } ; const char *msg3[] = { "unfrozen", "frozen" } ; status = SS_NORMAL; in_mupip_freeze = TRUE; UNIX_ONLY(jnlpool_init_needed = TRUE); mu_outofband_setup(); gvinit(); freeze = (CLI_PRESENT == cli_present("ON")); online = (CLI_PRESENT == cli_present("ONLINE")); if (online) online |= ((!cli_negated("AUTORELEASE")) ? CHILLED_AUTORELEASE_MASK : 0); if (CLI_PRESENT == cli_present("OFF")) { if (TRUE == freeze) { util_out_print("The /ON qualifier is invalid with the /OFF qualifier", TRUE); mupip_exit(ERR_MUPCLIERR); } } if (CLI_PRESENT == cli_present("RECORD")) { record = TRUE; if (FALSE == freeze) { util_out_print("The /RECORD qualifier is invalid with the /OFF qualifier", TRUE); mupip_exit(ERR_MUPCLIERR); } } else record = FALSE; if (CLI_PRESENT == cli_present("OVERRIDE")) { override = TRUE; if (freeze) { util_out_print("The /OVERRIDE qualifier is invalid with the /ON qualifier", TRUE); mupip_exit(ERR_MUPCLIERR); } } else
/* This function will process I/O if -OUTPUT suboption is present. This will create the file and duplicate it as stderr. So anything written to stderr will be written to this file. */ bool open_fileio(int *save_stderr) { char ofnamebuf[1024]; mstr ofname; int status=FALSE, fd; unsigned short len; char *errmsg; #ifdef __MVS__ int realfiletag, fstatus; struct stat info; /* Need the ERR_BADTAG and ERR_TEXT error_defs for the TAG_POLICY macro warning */ error_def(ERR_TEXT); error_def(ERR_BADTAG); #endif *save_stderr = SYS_STDERR; ofname.addr=ofnamebuf; ofname.len=SIZEOF(ofnamebuf); if (cli_present("OUTPUT") == CLI_PRESENT) { len = ofname.len; if (cli_get_str("OUTPUT", ofname.addr, &len)) { int dup2_res; ZOS_ONLY(STAT_FILE(ofname.addr, &info, fstatus);)
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; }
/***************************************************************** * TclSetCurrent: *****************************************************************/ int TclSetCurrent() { int sts; char *experiment; static int shot; static DESCRIPTOR_LONG(dsc_shot,&shot); static DYNAMIC_DESCRIPTOR(dsc_experiment); static DYNAMIC_DESCRIPTOR(dsc_asciiShot); cli_get_value("EXPERIMENT",&dsc_experiment); experiment = dsc_experiment.dscA_pointer; if (cli_present("INCREMENT") & 1) { shot = TreeGetCurrentShotId(experiment); shot++; sts = TreeSetCurrentShotId(experiment,shot); } else { cli_get_value("SHOT",&dsc_asciiShot); #ifdef vms dsc_asciiShot.dscB_class = CLASS_S; /* vms: malloc vs str$ */ sts = TdiExecute(&dsc_asciiShot,&dsc_shot MDS_END_ARG); dsc_asciiShot.dscB_class = CLASS_D; #else sts = TdiExecute(&dsc_asciiShot,&dsc_shot MDS_END_ARG); #endif if (sts & 1) sts = TreeSetCurrentShotId(experiment,shot); } if ((sts & 1) != 1) MdsMsg(sts,0); return sts; }
void mupcli_get_offset_size_value(uint4 *offset, uint4 *size, gtm_uint64_t *value, boolean_t *value_present) { error_def(ERR_MUPCLIERR); error_def(ERR_SIZENOTVALID8); if (!cli_get_hex("OFFSET", offset)) rts_error(VARLSTCNT(1) ERR_MUPCLIERR); if (!cli_get_hex("SIZE", size)) rts_error(VARLSTCNT(1) ERR_MUPCLIERR); if (!((sizeof(char) == *size) || (sizeof(short) == *size) || (sizeof(int4) == *size) || (sizeof(gtm_int64_t) == *size))) rts_error(VARLSTCNT(1) ERR_SIZENOTVALID8); if (0 > (int4)*size) { util_out_print("Error: SIZE specified cannot be negative", TRUE); rts_error(VARLSTCNT(1) ERR_MUPCLIERR); } if (0 != (*offset % *size)) { util_out_print("Error: OFFSET [0x!XL] should be a multiple of Size [!UL]", TRUE, *offset, *size); rts_error(VARLSTCNT(1) ERR_MUPCLIERR); } if (CLI_PRESENT == cli_present("VALUE")) { *value_present = TRUE; if (!cli_get_hex64("VALUE", value)) rts_error(VARLSTCNT(1) ERR_MUPCLIERR); } else *value_present = FALSE; }
void change_fhead_timer(char *timer_name, sm_int_ptr_t timer_address, int default_time, bool zero_is_ok) /* default_time is in milliseconds */ { uint4 status, value; error_def(ERR_TIMRBADVAL); default_time = default_time * TIMER_SCALE; timer_address[1] = 0; status = cli_present((char *)timer_name); if (status == CLI_NEGATED) timer_address[0] = zero_is_ok ? 0 : default_time; else if (status == CLI_PRESENT) { status = cli_get_time((char *)timer_name, &value); if (TRUE == status) { if ((ONE_HOUR < value) || ((0 == value) && (FALSE == zero_is_ok))) rts_error(VARLSTCNT(1) ERR_TIMRBADVAL); else /* the above error is of type GTM-I- */ timer_address[0] = value; } else rts_error(VARLSTCNT(1) ERR_TIMRBADVAL); } return; }
/*************************************************************** * TclEdit: * Open tree for edit ***************************************************************/ int TclEdit() { int shot; int sts; static DYNAMIC_DESCRIPTOR(dsc_filnam); static DYNAMIC_DESCRIPTOR(dsc_asciiShot); cli_get_value("FILE",&dsc_filnam); cli_get_value("SHOTID",&dsc_asciiShot); sscanf(dsc_asciiShot.dscA_pointer,"%d",&shot); if (cli_present("NEW") & 1) sts = TreeOpenNew(dsc_filnam.dscA_pointer,shot); else sts = TreeOpenEdit(dsc_filnam.dscA_pointer,shot); if (sts & 1) TclNodeTouched(0,tree); else { sts = MdsMsg(sts,"Error opening tree-file %s for EDIT", dsc_filnam.dscA_pointer); #ifdef vms lib$signal(sts,0); #endif } return sts; }
/*************************************************************** * TclClose: * Close tree file(s). ***************************************************************/ int TclClose() { int sts; static const char promptWritefirst[] = "This tree has been modified, write it before closing? [Y]: "; static DYNAMIC_DESCRIPTOR(exp); static DYNAMIC_DESCRIPTOR(dsc_shotid); int shotid; if (cli_get_value("FILE",&exp) & 1) { cli_get_value("SHOTID",&dsc_shotid); sscanf(dsc_shotid.dscA_pointer,"%d",&shotid); sts = TreeClose(exp.dscA_pointer,shotid); } else { int doall = cli_present("ALL") & 1; while ((sts = TreeClose(0,0)) & 1 && doall); if (doall && sts == TreeNOT_OPEN) sts = TreeNORMAL; } if (sts == TreeWRITEFIRST) { if (cli_present("CONFIRM") == CLI_STS_NEGATED) sts = TreeQuitTree(0,0); else { printf(promptWritefirst); if (yesno(1)) { sts = TreeWriteTree(0,0); if (sts & 1) { TreeClose(0,0); } } else sts = TreeQuitTree(0,0); } } if (sts & 1) TclNodeTouched(0,tree); else MdsMsg(sts,"TclClose: *WARN* unexpected status"); return sts; }
//------------------------------------------------------------------------- // set a crate on-line or off-line //------------------------------------------------------------------------- int SetCrate() { int status; char *cratename; void *ctx=0; static DESCRIPTOR( crate_p, "CRATE" ); static DESCRIPTOR( quietq, "QUIET" ); static DYNAMIC_DESCRIPTOR( wild ); static DYNAMIC_DESCRIPTOR( crate ); static DESCRIPTOR( offq, "OFFLINE" ); static DESCRIPTOR( onq, "ONLINE" ); int off = cli_present(&offq) & 1; int on = cli_present(&onq ) & 1; int quiet = cli_present(&quietq) & 1; cli_get_value( &crate_p, &wild ); str_upcase( &wild, &wild ); // check to see if db file memory mapped if( CRATEdbFileIsMapped == FALSE ) { // is not, so try if( map_data_file(CRATE_DB) != SUCCESS ) { // we're dead in the water if( MSGLVL(IMPORTANT) ) fprintf( stderr, "error memory mapping crate db file\n" ); status = FAILURE; // MAP_ERROR; [2001.07.12] goto SetCrate_Exit; } } while (find_crate(wild.pointer,&cratename,&ctx)) { status = turn_crate_on_off_line( cratename , (on) ? ON : OFF ); if (!(status & 1) && !quiet) printf("Error turning crate %s %s\n",cratename,on ? "online" : "offline"); free(cratename); } find_crate_end(&ctx); SetCrate_Exit: return SUCCESS; }
/* **++ ** ROUTINE: main ** ** FUNCTIONAL DESCRIPTION: ** ** Main program. Fetches the command from the command line, ** uses CLI$ routines to parse it, then starts the build process. ** ** RETURNS: cond_value, longword (unsigned), write only, by value ** ** PROTOTYPE: ** ** main ** ** IMPLICIT INPUTS: See global definitions at module head. ** ** IMPLICIT OUTPUTS: See global definitions at module head. ** ** COMPLETION CODES: ** ** SS$_NORMAL, MMK__ALLOK : normal successful completion. ** ** SIDE EFFECTS: None. ** **-- */ unsigned int main (void) { DESCRIP cmdstr; char Output_File[256], tmp[256]; $DESCRIPTOR(cmdname, "MMKC "); unsigned int status; int i; /* ** Initialize the globals */ temporary_symbols = 0; for (i = 0; i < MMK_K_SYMTABLE_SIZE; i++) { INIT_QUEUE(global_symbols.symlist[i]); INIT_QUEUE(local_symbols.symlist[i]); INIT_QUEUE(cmdline_symbols.symlist[i]); INIT_QUEUE(builtin_symbols.symlist[i]); } INIT_QUEUE(rules); INIT_QUEUE(dependencies); INIT_QUEUE(dep_internal); INIT_QUEUE(dep_deferred); INIT_QUEUE(suffixes); INIT_QUEUE(do_first); INIT_QUEUE(do_last); exit_status = SS$_NORMAL; ignore = override_silent = override_ignore = symbol_override = 0; skip_intermediates = 0; /* ** Fetch and parse command string */ INIT_DYNDESC(cmdstr); status = lib$get_foreign(&cmdstr); str$prefix(&cmdstr, &cmdname); status = cli$dcl_parse(&cmdstr, MMK_COMPILE_RULES_CLD, lib$get_input, lib$get_input); if (!OK(status)) return (status | STS$M_INHIB_MSG); /* ** Get the command parameters and qualifiers */ Output_File[0] = '\0'; if (cli_present("OUTPUT") == CLI$_PRESENT) { cli_get_value("OUTPUT", Output_File, sizeof(Output_File)); } status = cli_get_value("RULES_FILE", tmp, sizeof(tmp)); if (!OK(status)) return status | STS$M_INHIB_MSG; Read_Description(tmp, "SYS$DISK:[].MMS", 1); if (OK(exit_status)) Generate_Structures(tmp, Output_File); return exit_status | STS$M_INHIB_MSG; }
/* Description: * Edits or displays the contents of a replication instance file. * Parameters: None * Return Value: None */ void repl_inst_edit(void) { unsigned short inst_fn_len; char inst_fn[MAX_FN_LEN + 1], buff_unaligned[REPL_INST_HDR_SIZE + GTMSRC_LCL_SIZE + 8]; char *buff; repl_inst_hdr_ptr_t repl_instance; gtmsrc_lcl_ptr_t gtmsrclcl_ptr; uint4 offset, size; gtm_uint64_t value; boolean_t value_present; error_def(ERR_MUPCLIERR); in_repl_inst_edit = TRUE; inst_fn_len = MAX_FN_LEN; if (!cli_get_str("INSTFILE", inst_fn, &inst_fn_len) || (0 == inst_fn_len)) rts_error(VARLSTCNT(1) ERR_MUPCLIERR); inst_fn[inst_fn_len] = '\0'; buff = &buff_unaligned[0]; buff = (char *)ROUND_UP2((INTPTR_T)buff, 8); if (CLI_PRESENT == cli_present("SHOW")) { print_offset = (CLI_PRESENT == cli_present("DETAIL")); repl_inst_read(inst_fn, (off_t)0, (sm_uc_ptr_t)buff, REPL_INST_HDR_SIZE + GTMSRC_LCL_SIZE); util_out_print("GTM-I-MUREPLSHOW, SHOW output for replication instance file !AD", TRUE, inst_fn_len, inst_fn); repl_instance = (repl_inst_hdr_ptr_t)&buff[0]; section_offset = 0; repl_inst_dump_filehdr(repl_instance); section_offset = REPL_INST_HDR_SIZE; repl_inst_dump_gtmsrclcl((gtmsrc_lcl_ptr_t)&buff[REPL_INST_HDR_SIZE]); section_offset = REPL_INST_TRIPLE_OFFSET; repl_inst_dump_triplehist(inst_fn, repl_instance->num_triples); } if (CLI_PRESENT == cli_present("CHANGE")) { mupcli_get_offset_size_value(&offset, &size, &value, &value_present); assert(size <= REPL_INST_HDR_SIZE + GTMSRC_LCL_SIZE); repl_inst_read(inst_fn, (off_t)offset, (sm_uc_ptr_t)buff, size); mupcli_edit_offset_size_value((sm_uc_ptr_t)buff, offset, size, value, value_present); repl_inst_write(inst_fn, (off_t)offset, (sm_uc_ptr_t)buff, size); } in_repl_inst_edit = FALSE; }
int MDSDCL_SHOW_VM( /* Return: status */ struct _mdsdcl_ctrl *ctrl /* <m> the control structure */ ) { #ifdef malloc int full = cli_present("FULL") & 1; MdsShowVM(full); #else MDSprintf("System not built with memcheck enabled. SHOW VM command is unavailable.\n"); #endif return(1); }
int gtmsource_jnlpool(void) { uint4 offset, size; gtm_uint64_t value; boolean_t value_present; assert(holds_sem[SOURCE][JNL_POOL_ACCESS_SEM]); assert(NULL == jnlpool.gtmsource_local); if (CLI_PRESENT == cli_present("NAME")) { util_out_print("Error: NAME cannot be used with JNLPOOL", TRUE); rts_error(VARLSTCNT(1) ERR_MUPCLIERR); } if (CLI_PRESENT == cli_present("SHOW")) { detail_specified = (CLI_PRESENT == cli_present("DETAIL")); section_offset = 0; repl_inst_dump_jnlpoolctl(jnlpool.jnlpool_ctl); section_offset = (uint4)((sm_uc_ptr_t)jnlpool.repl_inst_filehdr - (sm_uc_ptr_t)jnlpool.jnlpool_ctl); repl_inst_dump_filehdr(jnlpool.repl_inst_filehdr); section_offset = (uint4)((sm_uc_ptr_t)jnlpool.gtmsrc_lcl_array - (sm_uc_ptr_t)jnlpool.jnlpool_ctl); repl_inst_dump_gtmsrclcl(jnlpool.gtmsrc_lcl_array); section_offset = (uint4)((sm_uc_ptr_t)jnlpool.gtmsource_local_array - (sm_uc_ptr_t)jnlpool.jnlpool_ctl); repl_inst_dump_gtmsourcelocal(jnlpool.gtmsource_local_array); } if (CLI_PRESENT == cli_present("CHANGE")) { mupcli_get_offset_size_value(&offset, &size, &value, &value_present); if (size > jnlpool.jnlpool_ctl->jnlpool_size) { util_out_print("Error: SIZE specified [0x!XL] is greater than size of journal pool [0x!XL]", TRUE, size, jnlpool.jnlpool_ctl->jnlpool_size); rts_error(VARLSTCNT(1) ERR_MUPCLIERR); } mupcli_edit_offset_size_value(&((sm_uc_ptr_t)jnlpool.jnlpool_ctl)[offset], offset, size, value, value_present); } return (NORMAL_SHUTDOWN); }
/*---------------------------------------------- * d_c_cli_present: * disallow_check_cli_present * * This is a wrapper for cli_present to be used * from disallow functions (i.e. check_disallow * and those it calls). * * Mimicks VMS CLI. * * Do not use other than in *_disallow functions. * * Arguments: * qualifier string * * Return: * TRUE if present, * FALSE otherwise *---------------------------------------------- */ boolean_t d_c_cli_present(char *str) { int val; char *str_ptr; val = cli_present(str); str_ptr = strchr(str,DOT); if (str_ptr) str_ptr++; /* skip the dot */ else str_ptr = str; cli_err_strcat(str_ptr); return(CLI_PRESENT == val); }
void lke_setgdr(void) { gd_region *r_top; mval reset; bool def; short len; char buf[256]; int4 rundown_status = EXIT_NRM; /* if gds_rundown went smoothly */ static readonly char init_gdr[] = "gtmgbldir"; gvcmy_rundown(); gv_cur_region = gd_header->regions; r_top = gv_cur_region + gd_header->n_regions; for (gv_cur_region = gd_header->regions, r_top = gv_cur_region + gd_header->n_regions; gv_cur_region < r_top; gv_cur_region++) { tp_change_reg(); UNIX_ONLY(rundown_status |=) gds_rundown(); } if (EXIT_NRM != rundown_status) rts_error(VARLSTCNT(1) ERR_NOTALLDBRNDWN); if (cli_present("gld")) { cli_get_value("gld", buf) ; def = FALSE; reset.mvtype = MV_STR; reset.str.len = STRLEN(buf); reset.str.addr = buf; } else { reset.mvtype = MV_STR; reset.str.len = SIZEOF(init_gdr) - 1; reset.str.addr = init_gdr; } zgbldir(&reset); cs_addrs = 0; cs_data = 0; region_init(FALSE) ; #ifndef MUTEX_MSEM_WAKE mutex_sock_cleanup(); #endif gtmsecshr_sock_cleanup(CLIENT); }
/* * -------------------------------------------------- * Find the qualifier and convert it to 64 bit unsigned decimal number. * * Return: * TRUE - OK * FALSE - Could not convert to hex * -------------------------------------------------- */ boolean_t cli_get_uint64(char *entry, gtm_uint64_t *dst) { char buf[MAX_LINE]; char local_str[MAX_LINE]; assert(strlen(entry) > 0); strncpy(local_str, entry, SIZEOF(local_str) - 1); if ((cli_present(local_str) == CLI_PRESENT) && cli_get_value(local_str, buf)) { if (!cli_str_to_uint64(buf, dst)) { FPRINTF(stderr, "Error: cannot convert %s value to 64-bit unsigned decimal number.\n", buf); return FALSE; } return TRUE; } return FALSE; }
/***************************************************************** * mdsdcl_show_macro: *****************************************************************/ int mdsdcl_show_macro() /* Return: status */ { int i; int full; int sts; struct _mdsdcl_macro *m; static DYNAMIC_DESCRIPTOR(dsc_name); struct _mdsdcl_ctrl *ctrl = &MdsdclGetThreadStatic()->ctrl; sts = cli_get_value("MACRO",&dsc_name); if (sts & 1) { l2u(dsc_name.dscA_pointer,0); m = find_macro(dsc_name.dscA_pointer); if (!m) { fprintf(stderr," --> macro '%s' not defined\n\r", dsc_name.dscA_pointer); return(1); } display_macro(m); return(1); } /*======================================================= * List all defined macros ... *======================================================*/ full = cli_present("FULL") & 1; m = ctrl->macro.list; if (!m) { fprintf(stderr," --> No macros defined\n\n\r"); return(1); } for (i=0 ; i<ctrl->macro.numMacros ; i++,m++) { if (full) display_macro(m); else printf(" %s\n\r",m->name); } return(1); }
/* * -------------------------------------------------- * Find the qualifier and convert it to decimal number * unless 0x prefix. * * Return: * TRUE - OK * FALSE - Could not convert to number * -------------------------------------------------- */ boolean_t cli_get_num(char *entry, int4 *dst) { char buf[MAX_LINE]; char local_str[MAX_LINE]; assert(strlen(entry) > 0); strncpy(local_str, entry, SIZEOF(local_str) - 1); if (cli_present(local_str) == CLI_PRESENT && cli_get_value(local_str, buf)) { if (!cli_str_to_num(buf, dst)) { FPRINTF(stderr, "Error: cannot convert %s string to number.\n", buf); return FALSE; } return TRUE; } return FALSE; }
void mupip_crypt(void) { # ifdef GTM_CRYPT unsigned short fname_len; char fname[GTM_PATH_MAX]; int4 len, off; error_def(ERR_MUPCLIERR); fname_len = SIZEOF(fname); if (!cli_get_str("FILE", fname, &fname_len)) mupip_exit(ERR_MUPCLIERR); if (!cli_get_int("OFFSET", &off)) mupip_exit(ERR_MUPCLIERR); if (!cli_get_int("LENGTH", &len)) mupip_exit(ERR_MUPCLIERR); if (CLI_PRESENT == cli_present("DECRYPT")) mupip_exit(mu_decrypt(fname, off, len)); else mupip_exit(ERR_MUPCLIERR); # endif }
int gtmrecv_get_opt(void) { boolean_t autorollback, cmplvl_status, filter, log, log_interval_specified, plaintext_fallback; char statslog_val[4]; /* "ON" or "OFF" */ gtm_int64_t buffsize; int status; uint4 n_readers, n_helpers; unsigned short filter_cmd_len, instfilename_len, instname_len, log_file_len, statslog_val_len, tlsid_len; gtmrecv_options.start = (CLI_PRESENT == cli_present("START")); gtmrecv_options.shut_down = (CLI_PRESENT == cli_present("SHUTDOWN")); gtmrecv_options.checkhealth = (CLI_PRESENT == cli_present("CHECKHEALTH")); gtmrecv_options.statslog = (CLI_PRESENT == cli_present("STATSLOG")); gtmrecv_options.showbacklog = (CLI_PRESENT == cli_present("SHOWBACKLOG")); gtmrecv_options.changelog = (CLI_PRESENT == cli_present("CHANGELOG")); gtmrecv_options.updateonly = (CLI_PRESENT == cli_present("UPDATEONLY")); gtmrecv_options.updateresync = (CLI_PRESENT == cli_present("UPDATERESYNC")); gtmrecv_options.reuse_specified = (CLI_PRESENT == cli_present("REUSE")); gtmrecv_options.resume_specified = (CLI_PRESENT == cli_present("RESUME")); gtmrecv_options.initialize_specified = (CLI_PRESENT == cli_present("INITIALIZE")); if (gtmrecv_options.updateresync) { instfilename_len = SIZEOF(gtmrecv_options.updresync_instfilename) - 1; /* keep 1 byte for trailing NULL */ /* Treat -UPDATERESYNC (with no value) as if -UPDATERESYNC="" was specified */ if (!cli_get_str("UPDATERESYNC", gtmrecv_options.updresync_instfilename, &instfilename_len)) { instfilename_len = 0; if (gtmrecv_options.reuse_specified) { util_out_print("Error: REUSE qualifier not allowed if UPDATERESYNC qualifier has no value", TRUE); return (-1); } } else if (gtmrecv_options.reuse_specified) { instname_len = SIZEOF(gtmrecv_options.reuse_instname) - 1; /* keep 1 byte for trailing NULL */ if (!cli_get_str("REUSE", gtmrecv_options.reuse_instname, &instname_len)) { util_out_print("Error parsing REUSE qualifier", TRUE); return (-1); } else { assert(SIZEOF(gtmrecv_options.reuse_instname) > instname_len); gtmrecv_options.reuse_instname[instname_len] = '\0'; } } assert(SIZEOF(gtmrecv_options.updresync_instfilename) > instfilename_len); gtmrecv_options.updresync_instfilename[instfilename_len] = '\0'; if (gtmrecv_options.resume_specified) { if (!cli_get_int("RESUME", >mrecv_options.resume_strm_num)) { util_out_print("Error parsing RESUME qualifier", TRUE); return (-1); } if ((0 >= gtmrecv_options.resume_strm_num) || (MAX_SUPPL_STRMS <= gtmrecv_options.resume_strm_num)) { util_out_print("RESUME qualifier should specify a stream number between 1 and 15 (both inclusive)", TRUE); return (-1); } } } gtmrecv_options.noresync = (CLI_PRESENT == cli_present("NORESYNC")); gtmrecv_options.helpers = (CLI_PRESENT == cli_present("HELPERS")); gtmrecv_options.listen_port = 0; /* invalid port; indicates listenport not specified */ if (gtmrecv_options.start && CLI_PRESENT == cli_present("LISTENPORT")) { if (!cli_get_int("LISTENPORT", >mrecv_options.listen_port)) { util_out_print("Error parsing LISTENPORT qualifier", TRUE); return (-1); } if (CLI_PRESENT == cli_present("BUFFSIZE")) { /* use a big conversion so we have a signed number for comparison */ if (!cli_get_int64("BUFFSIZE", &buffsize)) { util_out_print("Error parsing BUFFSIZE qualifier", TRUE); return(-1); } if (MIN_RECVPOOL_SIZE > buffsize) gtmrecv_options.buffsize = MIN_RECVPOOL_SIZE; else if ((gtm_int64_t)MAX_RECVPOOL_SIZE < buffsize) gtmrecv_options.buffsize = (uint4)MAX_RECVPOOL_SIZE; else gtmrecv_options.buffsize = (uint4)buffsize; } else gtmrecv_options.buffsize = DEFAULT_RECVPOOL_SIZE; /* Check if -autorollback is specified (default is -noautorollback) */ autorollback = cli_present("AUTOROLLBACK"); gtmrecv_options.autorollback = autorollback ? (CLI_NEGATED != autorollback) : FALSE; if (gtmrecv_options.autorollback) gtmrecv_options.autorollback_verbose = cli_present("AUTOROLLBACK.VERBOSE"); /* Check if compression level is specified */ if (cmplvl_status = (CLI_PRESENT == cli_present("CMPLVL"))) { if (!cli_get_int("CMPLVL", >mrecv_options.cmplvl)) { util_out_print("Error parsing CMPLVL qualifier", TRUE); return(-1); } if (GTM_CMPLVL_OUT_OF_RANGE(gtmrecv_options.cmplvl)) gtmrecv_options.cmplvl = ZLIB_CMPLVL_MIN; /* no compression in this case */ /* CMPLVL qualifier should override any value specified in the environment variable gtm_zlib_cmp_level */ gtm_zlib_cmp_level = gtmrecv_options.cmplvl; } else gtmrecv_options.cmplvl = ZLIB_CMPLVL_MIN; /* no compression in this case */ if (filter = (CLI_PRESENT == cli_present("FILTER"))) { filter_cmd_len = MAX_FILTER_CMD_LEN; if (!cli_get_str("FILTER", gtmrecv_options.filter_cmd, &filter_cmd_len)) { util_out_print("Error parsing FILTER qualifier", TRUE); return (-1); } } else gtmrecv_options.filter_cmd[0] = '\0'; gtmrecv_options.stopsourcefilter = (CLI_PRESENT == cli_present("STOPSOURCEFILTER")); /* Check if SSL/TLS secure communication is requested. */ # ifdef GTM_TLS if (CLI_PRESENT == cli_present("TLSID")) { tlsid_len = MAX_TLSID_LEN; if (!cli_get_str("TLSID", repl_tls.id, &tlsid_len)) { util_out_print("Error parsing TLSID qualifier", TRUE); return -1; } assert(0 < tlsid_len); /* Check if plaintext-fallback mode is specified. Default option is NOPLAINTEXTFALLBACK. */ if (CLI_PRESENT == (plaintext_fallback = cli_present("PLAINTEXTFALLBACK"))) repl_tls.plaintext_fallback = (plaintext_fallback != CLI_NEGATED); else repl_tls.plaintext_fallback = FALSE; } # endif } if ((gtmrecv_options.start && 0 != gtmrecv_options.listen_port) || gtmrecv_options.statslog || gtmrecv_options.changelog) { log = (CLI_PRESENT == cli_present("LOG")); log_interval_specified = (CLI_PRESENT == cli_present("LOG_INTERVAL")); if (log) { log_file_len = MAX_FN_LEN + 1; if (!cli_get_str("LOG", gtmrecv_options.log_file, &log_file_len)) { util_out_print("Error parsing LOG qualifier", TRUE); return (-1); } } else gtmrecv_options.log_file[0] = '\0'; gtmrecv_options.rcvr_log_interval = gtmrecv_options.upd_log_interval = 0; if (log_interval_specified && 0 == cli_parse_two_numbers("LOG_INTERVAL", GTMRECV_LOGINTERVAL_DELIM, >mrecv_options.rcvr_log_interval, >mrecv_options.upd_log_interval)) return (-1); if (gtmrecv_options.start) { if (0 == gtmrecv_options.rcvr_log_interval) gtmrecv_options.rcvr_log_interval = LOGTRNUM_INTERVAL; if (0 == gtmrecv_options.upd_log_interval) gtmrecv_options.upd_log_interval = LOGTRNUM_INTERVAL; } /* For changelog, interval == 0 implies don't change log interval already established */ /* We ignore interval specification for statslog, Vinaya 2005/02/07 */ } if (gtmrecv_options.shut_down) { if (CLI_PRESENT == (status = cli_present("TIMEOUT"))) { if (!cli_get_int("TIMEOUT", >mrecv_options.shutdown_time)) { util_out_print("Error parsing TIMEOUT qualifier", TRUE); return (-1); } if (DEFAULT_SHUTDOWN_TIMEOUT < gtmrecv_options.shutdown_time || 0 > gtmrecv_options.shutdown_time) { gtmrecv_options.shutdown_time = DEFAULT_SHUTDOWN_TIMEOUT; util_out_print("shutdown TIMEOUT changed to !UL", TRUE, gtmrecv_options.shutdown_time); } } else if (CLI_NEGATED == status) gtmrecv_options.shutdown_time = -1; else /* TIMEOUT not specified */ gtmrecv_options.shutdown_time = DEFAULT_SHUTDOWN_TIMEOUT; } if (gtmrecv_options.statslog) { statslog_val_len = 4; /* max(strlen("ON"), strlen("OFF")) + 1 */ if (!cli_get_str("STATSLOG", statslog_val, &statslog_val_len)) { util_out_print("Error parsing STATSLOG qualifier", TRUE); return (-1); } cli_strupper(statslog_val); if (0 == STRCMP(statslog_val, "ON")) gtmrecv_options.statslog = TRUE; else if (0 == STRCMP(statslog_val, "OFF")) gtmrecv_options.statslog = FALSE; else { util_out_print("Invalid value for STATSLOG qualifier, should be either ON or OFF", TRUE); return (-1); } } gtmrecv_options.n_readers = gtmrecv_options.n_writers = 0; if (gtmrecv_options.helpers && gtmrecv_options.start) { /* parse the helpers qualifier to find out how many readers and writes have to be started */ if (0 == (status = cli_parse_two_numbers("HELPERS", UPD_HELPERS_DELIM, &n_helpers, &n_readers))) return (-1); if (!(status & CLI_2NUM_FIRST_SPECIFIED)) n_helpers = DEFAULT_UPD_HELPERS; if (MIN_UPD_HELPERS > n_helpers || MAX_UPD_HELPERS < n_helpers) { util_out_print("Invalid number of helpers; must be in the range [!UL,!UL]", TRUE, MIN_UPD_HELPERS, MAX_UPD_HELPERS); return (-1); } if (!(status & CLI_2NUM_SECOND_SPECIFIED)) n_readers = (int)(n_helpers * ((float)DEFAULT_UPD_HELP_READERS)/DEFAULT_UPD_HELPERS); /* may round down */ if (n_readers > n_helpers) { n_readers = n_helpers; util_out_print("Number of readers exceeds number of helpers, reducing number of readers to number of " "helpers", TRUE); } gtmrecv_options.n_readers = n_readers; gtmrecv_options.n_writers = n_helpers - n_readers; } return (0); }
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[256], targ_key_root[256], *key_top, util_buff[MAX_UTIL_LEN]; int size, size_root, root_path_count, count, util_len; bool found, was_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 <= &targ_key[256]; ) if (!*key_top++) break; size_root = 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")); if (!was_crit) { if (nocrit_present) cs_addrs->now_crit = TRUE; else grab_crit(gv_cur_region); } if (!dse_ksrch(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); if (!was_crit) { if (nocrit_present) cs_addrs->now_crit = FALSE; else rel_crit(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_ksrch(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); } if (!was_crit) { if (nocrit_present) cs_addrs->now_crit = FALSE; else rel_crit(gv_cur_region); } return; }
/**************************************************************** * mdsdcl_do_macro: ****************************************************************/ int mdsdcl_do_macro() /* Return: status */ { int i; int icnt; int irepeat; int sts; char prmName[4]; struct _mdsdcl_io *io; struct _mdsdcl_macro *macro; static DYNAMIC_DESCRIPTOR(dsc_util); static char fmt0[] = "Qualifier not supported: use '@'"; static char fmt1[] = "No such command: '%s'"; static char fmt2[] = "Macro '%s' is already in use"; static char fmt3[] = "Exceeded MAX_DEPTH for indirect files & macros"; struct _mdsdcl_ctrl *ctrl = &MdsdclGetThreadStatic()->ctrl; sts = cli_get_value("NAME",&dsc_util); if (~sts & 1) return(MdsMsg(MDSDCL_STS_ERROR,"Error getting NAME")); if (cli_present("INTERACTIVE") & 1) return(MdsMsg(MDSDCL_STS_ERROR,fmt0,0)); if (cli_present("INDIRECT") & 1) { sts = mdsdcl_openIndirectLevel(dsc_util.dscA_pointer); if (!sts & 1) return(MdsMsg(sts,"failed to open file %s",dsc_util.dscA_pointer)); for ( ; sts & 1 ; ) sts = mdsdcl_do_command(0); return((sts==MDSDCL_STS_INDIRECT_EOF) ? 1 : sts); } l2u(dsc_util.dscA_pointer,0); /* convert to uc */ macro = find_macro(dsc_util.dscA_pointer); if (!macro) { MdsMsg(0,"No such command"); return(MDSDCL_STS_ERROR); } if (macro->isOpen) return(MdsMsg(MDSDCL_STS_ERROR,fmt2,dsc_util.dscA_pointer)); /*======================================================= * Get repeat count ... *======================================================*/ sts = cli_get_value("REPEAT",&dsc_util); if (sts & 1) { if (sscanf(dsc_util.dscA_pointer,"%d",&irepeat) != 1) irepeat = 1; } else irepeat = 1; /*======================================================== * Create new ioLevel[] in ctrl struct ... *=======================================================*/ if (ctrl->depth >= MAX_DEPTH) return(MdsMsg(MDSDCL_STS_INDIRECT_ERROR,fmt3,0)); for (icnt=0 ; icnt<irepeat ; icnt++) { macro->isOpen = 1; io = ctrl->ioLevel + ++ctrl->depth; io->fp = 0; io->ioMacro = macro; io->lineno = 0; for (i=0 ; i<8 ; i++) { sprintf(prmName,"P%d",i+1); sts = cli_get_value(prmName,io->ioParameter+i); if (~sts & 1) break; } for ( ; i<8 ; i++) str_free1_dx(io->ioParameter+i); do { sts = mdsdcl_do_command(0); } while (sts & 1); if (sts == MDSDCL_STS_INDIRECT_EOF) continue; else break; } return((sts==MDSDCL_STS_INDIRECT_EOF) ? 1 : sts); }
void mupip_restore(void) { static readonly char label[] = GDS_LABEL; char db_name[MAX_FN_LEN + 1], *inbuf, *p; inc_list_struct *ptr; inc_header *inhead; sgmnt_data *old_data; short iosb[4]; unsigned short n_len; int4 status, vbn, rsize, temp, save_errno; uint4 rest_blks, totblks; trans_num curr_tn; uint4 ii; block_id blk_num; bool extend; uint4 cli_status; BFILE *in; int i, db_fd; uint4 old_blk_size, old_tot_blks, bplmap; short old_start_vbn; off_t new_eof; char buff[DISK_BLOCK_SIZE]; char msg_buffer[1024], *newmap, *newmap_bptr; mstr msg_string; char addr[SA_MAXLEN+1]; unsigned char tcp[5]; backup_type type; unsigned short port; int4 timeout, cut, match; char debug_info[256]; void (*common_read)(); char *errptr; pid_t waitpid_res; error_def(ERR_MUPRESTERR); error_def(ERR_MUPCLIERR); error_def(ERR_IOEOF); extend = TRUE; if (CLI_NEGATED == (cli_status = cli_present("EXTEND"))) extend = FALSE; mu_outofband_setup(); mu_gv_cur_reg_init(); n_len = sizeof(db_name); if (cli_get_str("DATABASE", db_name, &n_len) == FALSE) mupip_exit(ERR_MUPCLIERR); strcpy((char *)gv_cur_region->dyn.addr->fname, db_name); gv_cur_region->dyn.addr->fname_len = n_len; if (!mu_rndwn_file(gv_cur_region, TRUE)) { util_out_print("Error securing stand alone access to output file !AD. Aborting restore.", TRUE, n_len, db_name); mupip_exit(ERR_MUPRESTERR); } OPENFILE(db_name, O_RDWR, db_fd); if (-1 == db_fd) { save_errno = errno; util_out_print("Error accessing output file !AD. Aborting restore.", TRUE, n_len, db_name); errptr = (char *)STRERROR(save_errno); util_out_print("open : !AZ", TRUE, errptr); mupip_exit(save_errno); } murgetlst(); inbuf = (char*)malloc(INC_BACKUP_CHUNK_SIZE); old_data = (sgmnt_data*)malloc(sizeof(sgmnt_data)); LSEEKREAD(db_fd, 0, old_data, sizeof(sgmnt_data), save_errno); if (0 != save_errno) { util_out_print("Error accessing output file !AD. Aborting restore.", TRUE, n_len, db_name); if (-1 != save_errno) { errptr = (char *)STRERROR(save_errno); util_out_print("read : !AZ", TRUE, errptr); db_ipcs_reset(gv_cur_region, TRUE); mu_gv_cur_reg_free(); mupip_exit(save_errno); } else { db_ipcs_reset(gv_cur_region, TRUE); mu_gv_cur_reg_free(); mupip_exit(ERR_IOEOF); } } if (memcmp(&old_data->label[0], &label[0], GDS_LABEL_SZ)) { util_out_print("Output file !AD has an unrecognizable format", TRUE, n_len, db_name); free(old_data); free(inbuf); db_ipcs_reset(gv_cur_region, TRUE); mu_gv_cur_reg_free(); mupip_exit(ERR_MUPRESTERR); } curr_tn = old_data->trans_hist.curr_tn; old_blk_size = old_data->blk_size; old_tot_blks = old_data->trans_hist.total_blks; old_start_vbn = old_data->start_vbn; bplmap = old_data->bplmap; free(old_data); msg_string.addr = msg_buffer; msg_string.len = sizeof(msg_buffer); inhead = (inc_header *)malloc(sizeof(inc_header) + 8); inhead = (inc_header *)((((int4)inhead) + 7) & -8); rest_blks = 0; for (ptr = in_files.next; ptr; ptr = ptr->next) { /* --- determine source type --- */ type = backup_to_file; if (0 == ptr->input_file.len) continue; else if ('|' == *(ptr->input_file.addr + ptr->input_file.len - 1)) { type = backup_to_exec; ptr->input_file.len--; *(ptr->input_file.addr + ptr->input_file.len) = '\0'; } else if (ptr->input_file.len > 5) { lower_to_upper(tcp, (uchar_ptr_t)ptr->input_file.addr, 5); if (0 == memcmp(tcp, "TCP:/", 5)) { type = backup_to_tcp; cut = 5; while ('/' == *(ptr->input_file.addr + cut)) cut++; ptr->input_file.len -= cut; p = ptr->input_file.addr; while (p < ptr->input_file.addr + ptr->input_file.len) { *p = *(p + cut); p++; } *p = '\0'; } } /* --- open the input stream --- */ restore_read_errno = 0; switch(type) { case backup_to_file: common_read = iob_read; if ((in = iob_open_rd(ptr->input_file.addr, DISK_BLOCK_SIZE, BLOCKING_FACTOR)) == NULL) { save_errno = errno; util_out_print("Error accessing input file !AD. Aborting restore.", TRUE, ptr->input_file.len, ptr->input_file.addr); errptr = (char *)STRERROR(save_errno); util_out_print("open : !AZ", TRUE, errptr); db_ipcs_reset(gv_cur_region, TRUE); mu_gv_cur_reg_free(); mupip_exit(save_errno); } ESTABLISH(iob_io_error); break; case backup_to_exec: pipe_child = 0; common_read = exec_read; in = (BFILE *)malloc(sizeof(BFILE)); if (0 > (in->fd = gtm_pipe(ptr->input_file.addr, input_from_comm))) { util_out_print("Error creating input pipe from !AD.", TRUE, ptr->input_file.len, ptr->input_file.addr); db_ipcs_reset(gv_cur_region, TRUE); mu_gv_cur_reg_free(); mupip_exit(ERR_MUPRESTERR); } #ifdef DEBUG_ONLINE PRINTF("file descriptor for the openned pipe is %d.\n", in->fd); PRINTF("the command passed to gtm_pipe is %s.\n", ptr->input_file.addr); #endif break; case backup_to_tcp: common_read = tcp_read; /* parse the input */ switch (match = SSCANF(ptr->input_file.addr, "%[^:]:%hu", addr, &port)) { case 1 : port = DEFAULT_BKRS_PORT; case 2 : break; default : util_out_print("Error : A hostname has to be specified.", TRUE); db_ipcs_reset(gv_cur_region, TRUE); mu_gv_cur_reg_free(); mupip_exit(ERR_MUPRESTERR); } if ((0 == cli_get_int("NETTIMEOUT", &timeout)) || (0 > timeout)) timeout = DEFAULT_BKRS_TIMEOUT; in = (BFILE *)malloc(sizeof(BFILE)); iotcp_fillroutine(); if (0 > (in->fd = tcp_open(addr, port, timeout, TRUE))) { util_out_print("Error establishing TCP connection to !AD.", TRUE, ptr->input_file.len, ptr->input_file.addr); db_ipcs_reset(gv_cur_region, TRUE); mu_gv_cur_reg_free(); mupip_exit(ERR_MUPRESTERR); } break; default: util_out_print("Aborting restore!/", TRUE); util_out_print("Unrecognized input format !AD", TRUE, ptr->input_file.len, ptr->input_file.addr); db_ipcs_reset(gv_cur_region, TRUE); mu_gv_cur_reg_free(); mupip_exit(ERR_MUPRESTERR); } COMMON_READ(in, inhead, sizeof(inc_header)); if (memcmp(&inhead->label[0], INC_HEADER_LABEL, INC_HDR_LABEL_SZ)) { util_out_print("Input file !AD has an unrecognizable format", TRUE, ptr->input_file.len, ptr->input_file.addr); free(inbuf); db_ipcs_reset(gv_cur_region, TRUE); mu_gv_cur_reg_free(); mupip_exit(ERR_MUPRESTERR); } if (curr_tn != inhead->start_tn) { util_out_print("Transaction in input file !AD does not align with database TN.!/DB: !XL!_Input file: !XL", TRUE, ptr->input_file.len, ptr->input_file.addr, curr_tn, inhead->start_tn); free(inbuf); db_ipcs_reset(gv_cur_region, TRUE); mu_gv_cur_reg_free(); mupip_exit(ERR_MUPRESTERR); } if (old_blk_size != inhead->blk_size) { util_out_print("Incompatable block size. Output file !AD has block size !XL,", TRUE, n_len, db_name); util_out_print("while input file !AD is from a database with block size !XL,", TRUE, ptr->input_file.len, ptr->input_file.addr, inhead->blk_size); free(inbuf); db_ipcs_reset(gv_cur_region, TRUE); mu_gv_cur_reg_free(); mupip_exit(ERR_MUPRESTERR); } if (old_tot_blks != inhead->db_total_blks) { if (old_tot_blks > inhead->db_total_blks || !extend) { totblks = old_tot_blks - DIVIDE_ROUND_UP(old_tot_blks, DISK_BLOCK_SIZE); util_out_print("Incompatable database sizes. Output file !AD has!/ !UL (!XL hex) total blocks,", TRUE, n_len, db_name, totblks, totblks); totblks = inhead->db_total_blks - DIVIDE_ROUND_UP(inhead->db_total_blks, DISK_BLOCK_SIZE); util_out_print("while input file !AD is from a database with!/ !UL (!XL hex) total blocks", TRUE, ptr->input_file.len, ptr->input_file.addr, totblks, totblks); free(inbuf); db_ipcs_reset(gv_cur_region, TRUE); mu_gv_cur_reg_free(); mupip_exit(ERR_MUPRESTERR); } else { /* this part of the code is similar to gdsfilext except that you don't need to do * most of the work that gdsfilext does. However, for situations where the database * extended since the last backup (the beginning of this incremental backup), and * there are new bitmaps that are never touched later on by GT.M, these bitmaps * will have tn == 0, which prevents the backup process to pick up these blocks, * so, we need to initialize these bitmaps here */ new_eof = ((off_t)(old_start_vbn - 1) * DISK_BLOCK_SIZE) + ((off_t)inhead->db_total_blks * old_blk_size); memset(buff, 0, DISK_BLOCK_SIZE); LSEEKWRITE(db_fd, new_eof, buff, DISK_BLOCK_SIZE, status); if (0 != status) { util_out_print("Aborting restore!/", TRUE); util_out_print("lseek or write error : Unable to extend output file !AD!/", TRUE, n_len, db_name); util_out_print(" from !UL (!XL hex) total blocks to !UL (!XL hex) total blocks.!/", TRUE, old_tot_blks, old_tot_blks, inhead->db_total_blks, inhead->db_total_blks); util_out_print(" Current input file is !AD with !UL (!XL hex) total blocks!/", TRUE, ptr->input_file.len, ptr->input_file.addr, inhead->db_total_blks, inhead->db_total_blks); gtm_putmsg(VARLSTCNT(1) status); free(inbuf); db_ipcs_reset(gv_cur_region, TRUE); mu_gv_cur_reg_free(); mupip_exit(ERR_MUPRESTERR); } /* --- initialize all new bitmaps, just in case they are not touched later --- */ if (DIVIDE_ROUND_DOWN(inhead->db_total_blks, bplmap) > DIVIDE_ROUND_DOWN(old_tot_blks, bplmap)) { /* -- similar logic exist in bml_newmap.c, which need to pick up any new updates here -- */ newmap = (char *)malloc(old_blk_size); ((blk_hdr *)newmap)->bsiz = BM_SIZE(bplmap); ((blk_hdr *)newmap)->levl = LCL_MAP_LEVL; ((blk_hdr *)newmap)->tn = curr_tn; newmap_bptr = newmap + sizeof(blk_hdr); *newmap_bptr++ = THREE_BLKS_FREE; memset(newmap_bptr, FOUR_BLKS_FREE, BM_SIZE(bplmap) - sizeof(blk_hdr) - 1); for (ii = ROUND_UP(old_tot_blks, bplmap); ii <= inhead->db_total_blks; ii += bplmap) { new_eof = (off_t)(old_start_vbn - 1) * DISK_BLOCK_SIZE + (off_t)ii * old_blk_size; LSEEKWRITE(db_fd, new_eof, newmap, old_blk_size, status); if (0 != status) { util_out_print("Aborting restore!/", TRUE); util_out_print("Bitmap 0x!XL initialization error!", TRUE, ii); gtm_putmsg(VARLSTCNT(1) status); free(inbuf); free(newmap); db_ipcs_reset(gv_cur_region, TRUE); mu_gv_cur_reg_free(); mupip_exit(ERR_MUPRESTERR); } } free(newmap); } old_tot_blks = inhead->db_total_blks; } } COMMON_READ(in, &rsize, sizeof(int4)); for ( ; ;) { /* rsize is the size of the record, including the size, but, since the size has already been read in, this will read in the current record and the size for the next record */ /* ensure we have a reasonable record size, at least */ if (rsize - sizeof(int4) - sizeof(block_id) > old_blk_size) { util_out_print("Invalid information in restore file !AD. Aborting restore.", TRUE, ptr->input_file.len, ptr->input_file.addr); iob_close(in); db_ipcs_reset(gv_cur_region, TRUE); mu_gv_cur_reg_free(); mupip_exit(ERR_MUPRESTERR); } COMMON_READ(in, inbuf, rsize); if (!memcmp(inbuf, &end_msg[0], sizeof end_msg - 1)) break; rest_blks++; blk_num = *(block_id*)inbuf; vbn = old_start_vbn - 1 + (old_blk_size / DISK_BLOCK_SIZE * blk_num); LSEEKWRITE(db_fd, (off_t)vbn * DISK_BLOCK_SIZE, inbuf + sizeof(block_id), rsize - sizeof(block_id) - sizeof(int4), save_errno); if (0 != save_errno) { util_out_print("Error accessing output file !AD. Aborting restore.", TRUE, n_len, db_name); errptr = (char *)STRERROR(save_errno); util_out_print("write : !AZ", TRUE, errptr); db_ipcs_reset(gv_cur_region, TRUE); mu_gv_cur_reg_free(); mupip_exit(save_errno); } GET_LONG(temp, (inbuf + rsize - sizeof(int4))); rsize = temp; } GET_LONG(temp, (inbuf + rsize - sizeof(int4))); rsize = temp; vbn = 0; for (i = 0; ; i++) /* Restore file header */ { COMMON_READ(in, inbuf, rsize); if (!memcmp(inbuf, &hdr_msg[0], sizeof hdr_msg - 1)) break; LSEEKWRITE(db_fd, vbn, inbuf, rsize - sizeof(int4), save_errno); if (0 != save_errno) { util_out_print("Error accessing output file !AD. Aborting restore.", TRUE, n_len, db_name); errptr = (char *)STRERROR(save_errno); util_out_print("write : !AZ", TRUE, errptr); db_ipcs_reset(gv_cur_region, TRUE); mu_gv_cur_reg_free(); mupip_exit(save_errno); } vbn += rsize - sizeof(int4); GET_LONG(temp, (inbuf + rsize - sizeof(int4))); rsize = temp; } curr_tn = inhead->end_tn; switch (type) { case backup_to_file: REVERT; iob_close(in); break; case backup_to_exec: close(in->fd); if ((pipe_child > 0) && (FALSE != is_proc_alive(pipe_child, 0))) WAITPID(pipe_child, (int *)&status, 0, waitpid_res); break; case backup_to_tcp: break; } } util_out_print("!/RESTORE COMPLETED", TRUE); util_out_print("!UL blocks restored", TRUE, rest_blks); free(inbuf); db_ipcs_reset(gv_cur_region, FALSE); mu_gv_cur_reg_free(); mupip_exit(SS_NORMAL); }
sm_uc_ptr_t dump_record(sm_uc_ptr_t rp, block_id blk, sm_uc_ptr_t bp, sm_uc_ptr_t b_top) { sm_uc_ptr_t r_top, key_top, cptr0, cptr1; char key_buf[MAX_KEY_SZ + 1], *temp_ptr, *temp_key, util_buff[MAX_UTIL_LEN]; unsigned char cc; short int size; int4 util_len, head; int buf_len; block_id blk_id; if (rp >= b_top) return NULL; head = cli_present("HEADER"); GET_SHORT(size, &((rec_hdr_ptr_t)rp)->rsiz); cc = ((rec_hdr_ptr_t)rp)->cmpc; if ((CLI_NEGATED != head) && !patch_is_fdmp) { memcpy(util_buff, "Rec:", sizeof("Rec:") - 1); util_len = sizeof("Rec:") - 1; util_len += i2hex_nofill(patch_rec_counter, (uchar_ptr_t)&util_buff[util_len], 4); memcpy(&util_buff[util_len], " Blk ", sizeof(" Blk ") - 1); util_len += sizeof(" Blk ") - 1; util_len += i2hex_nofill(blk, (uchar_ptr_t)&util_buff[util_len], 8); memcpy(&util_buff[util_len], " Off ", sizeof(" Off ") - 1); util_len += sizeof(" Off ") - 1; util_len += i2hex_nofill(rp - bp, (uchar_ptr_t)&util_buff[util_len], 4); memcpy(&util_buff[util_len], " Size ", sizeof(" Size ") - 1); util_len += sizeof(" Size ") - 1; util_len += i2hex_nofill(size, (uchar_ptr_t)&util_buff[util_len], 4); memcpy(&util_buff[util_len], " Cmpc ", sizeof(" Cmpc ") - 1); util_len += sizeof(" Cmpc ") - 1; util_len += i2hex_nofill(cc, (uchar_ptr_t)&util_buff[util_len], 2); memcpy(&util_buff[util_len], " ", sizeof(" ") - 1); util_len += sizeof(" ") - 1; util_buff[util_len] = 0; util_out_print(util_buff, FALSE); } r_top = rp + size; if (r_top > b_top) r_top = b_top; else if (r_top < rp + sizeof(rec_hdr)) r_top = rp + sizeof(rec_hdr); if (cc > patch_comp_count) cc = patch_comp_count; if (((blk_hdr_ptr_t)bp)->levl) key_top = r_top - sizeof(block_id); else { for (key_top = rp + sizeof(rec_hdr); key_top < r_top;) if (!*key_top++ && !*key_top++) break; } size = key_top - rp - sizeof(rec_hdr); if (size < 0) size = 0; else if (size > sizeof(patch_comp_key) - 2) size = sizeof(patch_comp_key) - 2; memcpy(&patch_comp_key[cc], rp + sizeof(rec_hdr), size); patch_comp_count = cc + size; patch_comp_key[patch_comp_count] = patch_comp_key[patch_comp_count + 1] = 0; if (patch_is_fdmp) { if (dse_fdmp(key_top, r_top - key_top)) patch_fdmp_recs++; } else { if (r_top - sizeof(block_id) >= key_top) { GET_LONG(blk_id, key_top); if ((((blk_hdr_ptr_t)bp)->levl) || (blk_id <= cs_addrs->ti->total_blks)) { memcpy(util_buff, "Ptr ", sizeof("Ptr ") - 1); util_len = sizeof("Ptr ") - 1; util_len += i2hex_nofill(blk_id, (uchar_ptr_t)&util_buff[util_len], sizeof(blk_id) * 2); memcpy(&util_buff[util_len], " ", sizeof(" ") - 1); util_len += sizeof(" ") - 1; util_buff[util_len] = 0; util_out_print(util_buff, FALSE); } } util_out_print("Key ", FALSE); if (r_top == b_top && ((blk_hdr_ptr_t)bp)->levl && !((rec_hdr_ptr_t)rp)->cmpc && r_top - rp == sizeof(rec_hdr) + sizeof(block_id)) util_out_print("*", FALSE); else if (patch_comp_key[0]) { util_out_print("^", FALSE); RETRIEVE_ROOT_VAL(patch_comp_key, key_buf, temp_ptr, temp_key, buf_len); INIT_ROOT_GVT(key_buf, buf_len, curr_gbl_root); } print_target((uchar_ptr_t)patch_comp_key); util_out_print(0, TRUE); if (CLI_PRESENT != head) { for (cptr0 = rp; cptr0 < r_top; cptr0 += 20) { if (util_interrupt) { /* return, rather than signal ERR_CTRLC so * that the calling routine can deal with * that signal and do the appropriate * cleanup. */ return NULL; } util_len = 8; i2hex_blkfill(cptr0 - bp, (uchar_ptr_t)util_buff, 8); memcpy(&util_buff[util_len], " : |", sizeof(" : |") - 1 ); util_len += sizeof(" : |") - 1; util_buff[util_len] = 0; util_out_print(util_buff, FALSE); for (cptr1 = cptr0; cptr1 < (cptr0 + 20); cptr1++) { if (wide_out) { if (cptr1 < r_top) { i2hex_blkfill(*(sm_uc_ptr_t)cptr1, (uchar_ptr_t)util_buff, 4); util_buff[4] = 0; util_out_print(util_buff, FALSE); } else util_out_print(" ", FALSE); } else { if (cptr1 < r_top) { i2hex_blkfill(*(sm_uc_ptr_t)cptr1, (uchar_ptr_t)util_buff, 3); util_buff[3] = 0; util_out_print(util_buff, FALSE); } else util_out_print(" ", FALSE); } } if (wide_out) { util_out_print("| |", FALSE); for (cptr1 = cptr0; cptr1 < (cptr0 + 20); cptr1++) { if (cptr1 < r_top) { if (PRINTABLE(*(sm_uc_ptr_t)cptr1)) util_out_print("!AD", FALSE, 1, cptr1); else util_out_print(".", FALSE); } else util_out_print(" ", FALSE); } } else { util_out_print("|", TRUE); util_out_print(" |", FALSE); for (cptr1 = cptr0; cptr1 < (cptr0 + 20); cptr1++) { if (cptr1 < r_top) { if (PRINTABLE(*(sm_uc_ptr_t)cptr1)) util_out_print(" !AD", FALSE, 1, cptr1); else util_out_print(" .", FALSE); } else util_out_print(" ", FALSE); } } util_out_print("|", TRUE); } } if (CLI_NEGATED != head) util_out_print(0, TRUE); } return (r_top == b_top) ? NULL : r_top; }
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; }