Line data Source code
1 : #ifndef __HEXVIEW_DOT_H__ 2 : #define __HEXVIEW_DOT_H__ 3 : 4 : #include <sys/types.h> 5 : #include <inttypes.h> 6 : #include <limits.h> 7 : #include <string.h> 8 : #include <ncurses.h> 9 : 10 : #include "libgfs2.h" 11 : #include "copyright.cf" 12 : 13 : #ifndef TRUE 14 : #define TRUE 1 15 : #endif 16 : #ifndef FALSE 17 : #define FALSE 0 18 : #endif 19 : 20 : #define DMODES 3 21 : enum dsp_mode { HEX_MODE = 0, GFS2_MODE = 1, EXTENDED_MODE = 2, INIT_MODE = 3 }; 22 : #define BLOCK_STACK_SIZE 256 23 : 24 : #define RGLIST_DUMMY_BLOCK -2 25 : #define JOURNALS_DUMMY_BLOCK -3 26 : 27 : extern const char *mtypes[]; 28 : extern int blockhist; 29 : extern int edit_mode; 30 : extern int line; 31 : extern char edit_fmt[80]; 32 : extern char estring[1024]; /* edit string */ 33 : extern char efield[64]; 34 : extern uint64_t dev_offset; 35 : extern uint64_t max_block; 36 : extern int termlines; 37 : extern int insert; 38 : extern const char *termtype; 39 : extern int line; 40 : extern int struct_len; 41 : extern unsigned int offset; 42 : extern int edit_row[DMODES], edit_col[DMODES], print_entry_ndx; 43 : extern int start_row[DMODES], end_row[DMODES], lines_per_row[DMODES]; 44 : extern int edit_size[DMODES], last_entry_onscreen[DMODES]; 45 : extern char edit_fmt[80]; 46 : extern struct lgfs2_sbd sbd; 47 : extern struct gfs2_dinode *di; 48 : extern int screen_chunk_size; /* how much of the 4K can fit on screen */ 49 : extern int gfs2_struct_type; 50 : extern int identify; 51 : extern int color_scheme; 52 : extern WINDOW *wind; 53 : extern int editing; 54 : extern uint64_t temp_blk; 55 : extern uint64_t starting_blk; 56 : extern int dsplines; 57 : extern int dsp_lines[DMODES]; 58 : extern int combined_display; 59 : extern int details; 60 : extern const char *allocdesc[5]; 61 : extern char *device; 62 : 63 : struct idirent { 64 : struct lgfs2_inum inum; 65 : uint32_t hash; 66 : uint16_t rec_len; 67 : uint16_t name_len; 68 : uint16_t type; 69 : uint16_t rahead; 70 : char filename[NAME_MAX]; 71 : }; 72 : 73 : extern void idirent_in(struct idirent *id, void *de); 74 : 75 : struct indirect_info { 76 : int is_dir; 77 : int height; 78 : uint64_t block; 79 : uint32_t dirents; 80 : struct gfs2_leaf lf; 81 : struct lgfs2_metapath mp; 82 : struct idirent dirent[64]; 83 : uint64_t ptroff; 84 : }; 85 : 86 : struct iinfo { 87 : struct indirect_info ii[512]; 88 : }; 89 : 90 : struct blkstack_info { 91 : uint64_t block; 92 : int start_row[DMODES]; 93 : int end_row[DMODES]; 94 : int lines_per_row[DMODES]; 95 : int edit_row[DMODES]; 96 : int edit_col[DMODES]; 97 : enum dsp_mode dmode; 98 : int gfs2_struct_type; 99 : struct lgfs2_metapath mp; 100 : }; 101 : 102 : extern struct blkstack_info blockstack[BLOCK_STACK_SIZE]; 103 : extern struct iinfo *indirect; /* more than the most indirect 104 : pointers possible for any given 4K block */ 105 : extern struct indirect_info masterdir; /* Master directory info */ 106 : extern int indirect_blocks; /* count of indirect blocks */ 107 : extern enum dsp_mode dmode; 108 : 109 : /* ------------------------------------------------------------------------ */ 110 : /* block_is_rgtree - there's no such block as the rglist. This is a */ 111 : /* special case meant to parse the rindex and follow the */ 112 : /* blocks to the real rgs. */ 113 : /* ------------------------------------------------------------------------ */ 114 0 : static inline int block_is_rgtree(uint64_t blk) 115 : { 116 0 : if (blk == RGLIST_DUMMY_BLOCK) 117 0 : return TRUE; 118 0 : return FALSE; 119 : } 120 : 121 0 : static inline int block_is_journals(uint64_t blk) 122 : { 123 0 : if (blk == JOURNALS_DUMMY_BLOCK) 124 0 : return TRUE; 125 0 : return FALSE; 126 : } 127 : 128 : #define SCREEN_HEIGHT (16) 129 : #define SCREEN_WIDTH (16) 130 : 131 : #define TITLE1 "gfs2_edit - Global File System Editor (use with extreme caution)" 132 : #define TITLE2 REDHAT_COPYRIGHT " - Press H for help" 133 : 134 : #define COLOR_TITLE 1 135 : #define COLOR_NORMAL 2 136 : #define COLOR_INVERSE 3 137 : #define COLOR_SPECIAL 4 138 : #define COLOR_HIGHLIGHT 5 139 : #define COLOR_OFFSETS 6 140 : #define COLOR_CONTENTS 7 141 : 142 : #define COLORS_TITLE \ 143 : do { \ 144 : if (termlines) { \ 145 : attrset(COLOR_PAIR(COLOR_TITLE)); \ 146 : attron(A_BOLD); \ 147 : } \ 148 : } while (0) 149 : #define COLORS_NORMAL \ 150 : do { \ 151 : if (termlines) { \ 152 : attrset(COLOR_PAIR(COLOR_NORMAL)); \ 153 : attron(A_BOLD); \ 154 : } \ 155 : } while (0) 156 : #define COLORS_INVERSE \ 157 : do { \ 158 : if (termlines) { \ 159 : attrset(COLOR_PAIR(COLOR_INVERSE)); \ 160 : attron(A_BOLD); \ 161 : } \ 162 : } while (0) 163 : #define COLORS_SPECIAL \ 164 : do { \ 165 : if (termlines) { \ 166 : attrset(COLOR_PAIR(COLOR_SPECIAL)); \ 167 : attron(A_BOLD); \ 168 : } \ 169 : } while (0) 170 : #define COLORS_HIGHLIGHT \ 171 : do { \ 172 : if (termlines) { \ 173 : attrset(COLOR_PAIR(COLOR_HIGHLIGHT)); \ 174 : attron(A_BOLD); \ 175 : } \ 176 : } while (0) 177 : #define COLORS_OFFSETS \ 178 : do { \ 179 : if (termlines) { \ 180 : attrset(COLOR_PAIR(COLOR_OFFSETS)); \ 181 : attron(A_BOLD); \ 182 : } \ 183 : } while (0) 184 : #define COLORS_CONTENTS \ 185 : do { \ 186 : if (termlines) { \ 187 : attrset(COLOR_PAIR(COLOR_CONTENTS)); \ 188 : attron(A_BOLD); \ 189 : } \ 190 : } while (0) 191 : 192 : extern int block_is_rindex(uint64_t blk); 193 : extern int block_is_inum_file(uint64_t blk); 194 : extern int block_is_statfs_file(uint64_t blk); 195 : extern int block_is_quota_file(uint64_t blk); 196 : extern int block_is_per_node(uint64_t blk); 197 : extern int display_block_type(char *buf, uint64_t addr, int from_restore); 198 : extern void gfs_log_header_print(void *lhp); 199 : extern void savemeta(char *out_fn, int saveoption, int gziplevel); 200 : extern void restoremeta(const char *in_fn, const char *out_device, 201 : uint64_t printblocksonly); 202 : extern int display(int identify_only, int trunc_zeros, uint64_t flagref, 203 : uint64_t ref_blk); 204 : extern uint64_t check_keywords(const char *kword); 205 : extern uint64_t masterblock(const char *fn); 206 : extern void gfs_rgrp_print(void *rgp); 207 : extern int has_indirect_blocks(void); 208 : extern const struct lgfs2_metadata *get_block_type(char *buf); 209 : 210 : #endif /* __HEXVIEW_DOT_H__ */