This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Cluster Project".
http://sources.redhat.com/git/gitweb.cgi?p=cluster.git;a=commitdiff;h=01a041fa83a8596788deb5ef1f4e142c191d74db The branch, master has been updated via 01a041fa83a8596788deb5ef1f4e142c191d74db (commit) from 05b3793aa23b44f2c4c6e139f8fa3658eb6db311 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 01a041fa83a8596788deb5ef1f4e142c191d74db Author: Fabio M. Di Nitto <[EMAIL PROTECTED]> Date: Tue Jun 10 06:07:46 2008 +0200 [GFS] Remove obsoleted gfs_edit in favour of gfs2_edit Signed-off-by: Bob Peterson <[EMAIL PROTECTED]> Signed-off-by: Fabio M. Di Nitto <[EMAIL PROTECTED]> ----------------------------------------------------------------------- Summary of changes: gfs/Makefile | 6 +- gfs/gfs_edit/Makefile | 29 -- gfs/gfs_edit/gfshex.c | 344 -------------------- gfs/gfs_edit/gfshex.h | 10 - gfs/gfs_edit/hexedit.c | 820 ------------------------------------------------ gfs/gfs_edit/hexedit.h | 180 ----------- gfs/man/gfs_edit.8 | 129 +-------- gfs2/man/gfs2_edit.8 | 2 +- 8 files changed, 7 insertions(+), 1513 deletions(-) delete mode 100644 gfs/gfs_edit/Makefile delete mode 100644 gfs/gfs_edit/gfshex.c delete mode 100644 gfs/gfs_edit/gfshex.h delete mode 100644 gfs/gfs_edit/hexedit.c delete mode 100644 gfs/gfs_edit/hexedit.h diff --git a/gfs/Makefile b/gfs/Makefile index 0eaa171..510e181 100644 --- a/gfs/Makefile +++ b/gfs/Makefile @@ -1,6 +1,6 @@ include ../make/defines.mk -SUBDIRS=libgfs gfs_debug gfs_edit gfs_fsck gfs_grow gfs_jadd gfs_mkfs gfs_quota gfs_tool man init.d +SUBDIRS=libgfs gfs_debug gfs_fsck gfs_grow gfs_jadd gfs_mkfs gfs_quota gfs_tool man init.d all: ${SUBDIRS} @@ -13,7 +13,11 @@ all: ${SUBDIRS} mkdir -p ${DESTDIR}/sbin; \ cd ${DESTDIR}/sbin; \ ln -sf mount.gfs2 mount.gfs; \ + mkdir -p ${sbindir}; \ + cd ${sbindir}; \ + ln -sf gfs2_edit gfs_edit; \ fi; \ if [ "$@" = "uninstall" ]; then \ cd ${DESTDIR}/sbin; rm -f mount.gfs; \ + cd ${sbindir}; rm -f gfs_edit; \ fi diff --git a/gfs/gfs_edit/Makefile b/gfs/gfs_edit/Makefile deleted file mode 100644 index 64308c7..0000000 --- a/gfs/gfs_edit/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -TARGET= gfs_edit - -SBINDIRT=$(TARGET) - -all: ${TARGET} - -include ../../make/defines.mk -include $(OBJDIR)/make/cobj.mk -include $(OBJDIR)/make/clean.mk -include $(OBJDIR)/make/install.mk -include $(OBJDIR)/make/uninstall.mk - -OBJS= gfshex.o \ - hexedit.o - -CFLAGS += -DHELPER_PROGRAM -D_FILE_OFFSET_BITS=64 -CFLAGS += -I${gfskincdir} -I${ncursesincdir} -CFLAGS += -I$(S)/../include -CFLAGS += -I${incdir} - -LDFLAGS += -L${ncurseslibdir} -lncurses - - -${TARGET}: ${OBJS} - $(CC) -o $@ $^ $(LDFLAGS) - -clean: generalclean - --include $(OBJS:.o=.d) diff --git a/gfs/gfs_edit/gfshex.c b/gfs/gfs_edit/gfshex.c deleted file mode 100644 index 5af084c..0000000 --- a/gfs/gfs_edit/gfshex.c +++ /dev/null @@ -1,344 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <unistd.h> -#include <errno.h> -#include <curses.h> - -#include "global.h" -#include "hexedit.h" -#include "linux_endian.h" - -#define WANT_GFS_CONVERSION_FUNCTIONS -#include "gfs_ondisk.h" -#include "gfshex.h" - -extern int line; -extern struct gfs_sb sb; -extern char *buf; -extern struct gfs_dinode di; -extern uint64 bufsize; - -/****************************************************************************** -******************************************************************************* -** -** do_dinode_extended() -** -** Description: -** -** Input(s): -** -** Output(s): -** -** Returns: -** -******************************************************************************* -******************************************************************************/ - -void do_dinode_extended(struct gfs_dinode *di, char *buf) -{ - unsigned int x, y, count; - struct gfs_dirent de; - uint64 p, last; - - indirect_blocks = 0; - memset(indirect_block, 0, sizeof(indirect_block)); - if (di->di_height > 0) { - /* Indirect pointers */ - for (x = sizeof(struct gfs_dinode), y = 0; - x < bufsize; - x += sizeof(uint64), y++) { - p = gfs64_to_cpu(*(uint64 *)(buf + x)); - if (p) - indirect_block[indirect_blocks++] = p; - } - } - else if (di->di_type == GFS_FILE_DIR && - !(di->di_flags & GFS_DIF_EXHASH)) { - /* Directory Entries: */ - for (x = sizeof(struct gfs_dinode); x < bufsize && - de.de_rec_len > sizeof(struct gfs_dirent) && - de.de_rec_len < 256; x += de.de_rec_len) { - gfs_dirent_in(&de, buf + x); - if (de.de_inum.no_formal_ino) - indirect_block[indirect_blocks++] = de.de_inum.no_formal_ino; - } - } - else if (di->di_type == GFS_FILE_DIR && - (di->di_flags & GFS_DIF_EXHASH) && - di->di_height == 0) { - /* Leaf Pointers: */ - - last = gfs64_to_cpu(*(uint64 *)(buf + sizeof(struct gfs_dinode))); - count = 0; - - for (x = sizeof(struct gfs_dinode), y = 0; - y < (1 << di->di_depth); - x += sizeof(uint64), y++) { - p = gfs64_to_cpu(*(uint64 *)(buf + x)); - - if (p != last) { - indirect_block[indirect_blocks++] = last; - /*printf(" %u: %"PRIu64"\n", count, last);*/ - last = p; - count = 1; - } - else - count++; - - if ((y + 1) * sizeof(uint64) == di->di_size) - indirect_block[indirect_blocks++] = last; - ; /*printf(" %u: %"PRIu64"\n", count, last);*/ - } - } -} - - -/****************************************************************************** -******************************************************************************* -** -** do_indirect_extended() -** -** Description: -** -** Input(s): -** -** Output(s): -** -** Returns: -** -******************************************************************************* -******************************************************************************/ - -void do_indirect_extended(char *buf) -{ - unsigned int x, y; - uint64 p; - - printf("\nPointers\n\n"); - - for (x = sizeof(struct gfs_indirect), y = 0; x < bufsize; x += 8, y++) - { - p = gfs64_to_cpu(*(uint64 *)(buf + x)); - - if (p) - printf(" %u -> %"PRIu64"\n", y, p); - } -} - - -/****************************************************************************** -******************************************************************************* -** -** do_leaf_extended() -** -** Description: -** -** Input(s): -** -** Output(s): -** -** Returns: -** -******************************************************************************* -******************************************************************************/ - -void do_leaf_extended(char *buf) -{ - struct gfs_dirent de; - unsigned int x; - - - printf("\nDirectory Entries:\n"); - - for (x = sizeof(struct gfs_leaf); x < bufsize; x += de.de_rec_len) - { - printf("\n"); - gfs_dirent_in(&de, buf + x); - if (de.de_inum.no_formal_ino) - gfs_dirent_print(&de, buf + x + sizeof(struct gfs_dirent)); - } -} - - -/****************************************************************************** -******************************************************************************* -** -** do_eattr_extended() -** -** Description: -** -** Input(s): -** -** Output(s): -** -** Returns: -** -******************************************************************************* -******************************************************************************/ - -void do_eattr_extended(char *buf) -{ - struct gfs_ea_header ea; - unsigned int x; - - - printf("\nEattr Entries:\n"); - - for (x = sizeof(struct gfs_meta_header); x < bufsize; x += ea.ea_rec_len) - { - printf("\n"); - gfs_ea_header_in(&ea, buf + x); - gfs_ea_header_print(&ea, buf + x + sizeof(struct gfs_ea_header)); - } -} - -void gfs_inum_print2(const char *title,struct gfs_inum *no) -{ - move(line,2); - printw(title); - pv2(no, no_formal_ino, "%"PRIX64); - pv2(no, no_addr, "%"PRIX64); -} - -/** - * gfs_sb_print2 - Print out a superblock - * @sb: the cpu-order buffer - */ -void gfs_sb_print2(struct gfs_sb *sb) -{ - gfs_meta_header_print(&sb->sb_header); - - pv(sb, sb_fs_format, "%u"); - pv(sb, sb_multihost_format, "%u"); - pv(sb, sb_flags, "%u"); - - pv(sb, sb_bsize, "%u"); - pv(sb, sb_bsize_shift, "%u"); - pv(sb, sb_seg_size, "%u"); - - gfs_inum_print2("jindex inode",&sb->sb_jindex_di); - gfs_inum_print2("rindex inode",&sb->sb_rindex_di); - gfs_inum_print2("root inode",&sb->sb_root_di); - - pv(sb, sb_lockproto, "%s"); - pv(sb, sb_locktable, "%s"); - - gfs_inum_print2("quota inode",&sb->sb_quota_di); - gfs_inum_print2("license inode",&sb->sb_license_di); - - pa(sb, sb_reserved, 96); -} - -/****************************************************************************** -******************************************************************************* -** -** int display_gfs() -** -** Description: -** This routine... -** -** Input(s): -** *buffer - -** extended - -** -** Returns: -** 0 if OK, 1 on error. -** -******************************************************************************* -******************************************************************************/ -int display_gfs(void) -{ - struct gfs_meta_header mh; - struct gfs_rgrp rg; - struct gfs_leaf lf; - struct gfs_log_header lh; - struct gfs_log_descriptor ld; - - uint32 magic; - - magic = gfs32_to_cpu(*(uint32 *)buf); - - switch (magic) - { - case GFS_MAGIC: - gfs_meta_header_in(&mh, buf); - - switch (mh.mh_type) - { - case GFS_METATYPE_SB: - printw("Superblock:\n\n"); - gfs_sb_in(&sb, buf); - gfs_sb_print2(&sb); - break; - - case GFS_METATYPE_RG: - printw("Resource Group Header:\n\n"); - gfs_rgrp_in(&rg, buf); - gfs_rgrp_print(&rg); - break; - - case GFS_METATYPE_RB: - printw("Resource Group Bitmap:\n\n"); - gfs_meta_header_print(&mh); - break; - - case GFS_METATYPE_DI: - printw("Dinode:\n\n"); - gfs_dinode_print(&di); - break; - - case GFS_METATYPE_LF: - printw("Leaf:\n\n"); - gfs_leaf_in(&lf, buf); - gfs_leaf_print(&lf); - break; - - case GFS_METATYPE_IN: - printw("Indirect Block:\n\n"); - gfs_meta_header_print(&mh); - break; - - case GFS_METATYPE_JD: - printf("Journaled File Block:\n\n"); - gfs_meta_header_print(&mh); - break; - - case GFS_METATYPE_LH: - printw("Log Header:\n\n"); - gfs_log_header_in(&lh, buf); - gfs_log_header_print(&lh); - break; - - - case GFS_METATYPE_LD: - printw("Log Descriptor:\n\n"); - gfs_desc_in(&ld, buf); - gfs_desc_print(&ld); - break; - - case GFS_METATYPE_EA: - printw("Eattr Block:\n\n"); - gfs_meta_header_print(&mh); - break; - - case GFS_METATYPE_ED: - printw("Eattr Data Block:\n\n"); - gfs_meta_header_print(&mh); - break; - - default: - printw("Unknown metadata type\n"); - break; - } - break; - - default: - printw("Unknown block type\n"); - break; - }; - return(0); -} diff --git a/gfs/gfs_edit/gfshex.h b/gfs/gfs_edit/gfshex.h deleted file mode 100644 index 9e09f75..0000000 --- a/gfs/gfs_edit/gfshex.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __GFSHEX_DOT_H__ -#define __GFSHEX_DOT_H__ - - -int display_gfs(void); -int edit_gfs(void); -void do_dinode_extended(struct gfs_dinode *di, char *buf); - - -#endif /* __GFSHEX_DOT_H__ */ diff --git a/gfs/gfs_edit/hexedit.c b/gfs/gfs_edit/hexedit.c deleted file mode 100644 index 29eb345..0000000 --- a/gfs/gfs_edit/hexedit.c +++ /dev/null @@ -1,820 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <ctype.h> -#include <string.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <unistd.h> -#include <errno.h> -#include <curses.h> -#include <term.h> -#include <signal.h> -#include <sys/ioctl.h> -#include <sys/mount.h> - -#include "global.h" -#include "copyright.cf" - -#define EXTERN -#include "hexedit.h" -#include "gfshex.h" -#include "gfs_ondisk.h" -#include "linux_endian.h" - -#include <syslog.h> - -#define TITLE1 "gfs_edit - Global File System Editor (use with extreme caution)" -#define TITLE2 "Copyright (C) 2006 Red Hat, Inc. - Press H for help" - -int display(void); - -/* ------------------------------------------------------------------------ */ -/* UpdateSize - screen size changed, so update it */ -/* ------------------------------------------------------------------------ */ -void UpdateSize(int sig) -{ - static char term_buffer[2048]; - int rc; - - termlines=30; - termtype=getenv("TERM"); - if (termtype==NULL) - return; - rc=tgetent(term_buffer,termtype); - if (rc>=0) { - termlines=tgetnum("li"); - if (termlines<10) - termlines=30; - } - else - perror("Error: tgetent failed."); - termlines--; /* last line is number of lines -1 */ - display(); - signal(SIGWINCH, UpdateSize); -} - -/* ------------------------------------------------------------------------- */ -/* display_title_lines */ -/* ------------------------------------------------------------------------- */ -void display_title_lines(void) -{ - clear(); - attrset(COLOR_PAIR(1)); - move(0, 0); - printw("%-80s",TITLE1); - move(termlines, 0); - printw("%-79s",TITLE2); - attrset(COLOR_PAIR(2)); -} - -/* ------------------------------------------------------------------------- */ -/* bobgets - get a string */ -/* returns: 1 if user exited by hitting enter */ -/* 0 if user exited by hitting escape */ -/* ------------------------------------------------------------------------- */ -int bobgets(char string[],int x,int y,int sz) -{ - int done,ch,runningy,rc; - - move(x,y); - done=FALSE; - attrset(COLOR_PAIR(3)); - move(x,y); - addstr(string); - move(x,y); - curs_set(2); - refresh(); - runningy=y; - rc=0; - while (!done) { - ch=getch(); - - if(ch < 0x0100 && isprint(ch)) { - char *p=string+strlen(string); // end of the string - *(p+1)='\0'; - while (insert && p > &string[runningy-y]) { - *p=*(p-1); - p--; - } - string[runningy-y]=ch; - runningy++; - move(x,y); - addstr(string); - } - else { - // special character, is it one we recognize? - switch(ch) - { - case(KEY_ENTER): - case('\n'): - case('\r'): - rc=1; - done=TRUE; - break; - case(KEY_CANCEL): - case(0x01B): - rc=0; - done=TRUE; - break; - case(KEY_LEFT): - if (runningy>y) - runningy--; - break; - case(KEY_RIGHT): - runningy++; - break; - case(KEY_DC): - case(0x07F): - if (runningy>=y) { - char *p; - p = &string[runningy-y]; - while (*p) { - *p = *(p+1); - p++; - } - *p='\0'; - runningy--; - // remove the character from the string - move(x,y); - addstr(string); - attrset(COLOR_PAIR(2)); - addstr(" "); - attrset(COLOR_PAIR(3)); - runningy++; - } - break; - case(KEY_BACKSPACE): - if (runningy>y) { - char *p; - - p = &string[runningy-y-1]; - while (*p) { - *p = *(p+1); - p++; - } - *p='\0'; - runningy--; - // remove the character from the string - move(x,y); - addstr(string); - attrset(COLOR_PAIR(2)); - addstr(" "); - attrset(COLOR_PAIR(3)); - } - break; - case KEY_DOWN: // Down - rc=0x5000U; - done=TRUE; - break; - case KEY_UP: // Up - rc=0x4800U; - done=TRUE; - break; - case 0x014b: - insert=!insert; - move(0,68); - if (insert) - printw("insert "); - else - printw("replace"); - break; - default: - move(0,70); - printw("%08X",ch); - // ignore all other characters - break; - } // end switch on non-printable character - } // end non-printable character - move(x,runningy); - refresh(); - } // while !done - if (sz>0) - string[sz]='\0'; - attrset(COLOR_PAIR(2)); - return rc; -}/* bobgets */ - -/****************************************************************************** -******************************************************************************* -** -** void print_usage() -** -** Description: -** This routine prints out the appropriate commands for this application. -** -******************************************************************************* -******************************************************************************/ - -void print_usage(void) -{ - int ch; - - line = 2; - clear(); - display_title_lines(); - move(line++,0); - printw("Supported commands: (roughly conforming to the rules of 'less')"); - line++; - move(line++,0); - printw(" b - Backward one 4K block"); - move(line++,0); - printw(" f - Forward one 4K block"); - move(line++,0); - printw(" g - Goto a given block in hex"); - move(line++,0); - printw(" h - This Help display"); - move(line++,0); - printw(" j - Jump to the highlighted 64-bit block number."); - move(line++,0); - printw(" m - Switch display mode: hex -> GFS structure -> Extended"); - move(line++,0); - printw(" q - Quit (same as hitting <escape> key)"); - move(line++,0); - printw("<space> - Forward one 4K block (same as 'f')"); - move(line++,0); - printw("<pg up>/<down> - move up or down one screen full"); - move(line++,0); - printw("<up>/<down> - move up or down one line"); - move(line++,0); - printw("<left>/<right> - move left or right one byte"); - move(line++,0); - printw("<home> - return to the superblock."); - move(line++,0); - printw("<enter> - edit a value (enter to save, esc to discard)"); - move(line++,0); - printw("<backspace> - return to previous block"); - move(line++,0); - printw("<escape> - Quit the program"); - move(line++,0); - move(line++,0); - printw("Notes: Areas shown in red are outside the bounds of the struct."); - move(line++,0); - printw(" Fields shown in green are selected for edit on <enter>."); - move(line++,0); - move(line++,0); - printw("Press any key to return."); - refresh(); - while ((ch=getch()) == 0); // wait for input - clear(); -} - -/* ------------------------------------------------------------------------ */ -/* display_block_type */ -/* returns: metatype if block is a GFS structure block type */ -/* 0 if block is not a GFS structure */ -/* ------------------------------------------------------------------------ */ -int display_block_type(const char *lpBuffer) -{ - int ret_type = 0; /* return type */ - - /* first, print out the kind of GFS block this is */ - line = 1; - move(line, 0); - printw("Block #"); - if (edit_row[display_mode] == -1) - attrset(COLOR_PAIR(5));; - printw("%"PRIX64,block); - if (edit_row[display_mode] == -1) - attrset(COLOR_PAIR(2)); - move(line,25); - printw("of %"PRIX64,max_block); - move(line, 45); - - if (*(lpBuffer+0)==0x01 && *(lpBuffer+1)==0x16 && *(lpBuffer+2)==0x19 && - *(lpBuffer+3)==0x70 && *(lpBuffer+4)==0x00 && *(lpBuffer+5)==0x00 && - *(lpBuffer+6)==0x00) { /* If magic number appears at the start */ - ret_type = *(lpBuffer+7); - switch (*(lpBuffer+7)) { - case GFS_METATYPE_SB: /* 1 */ - printw("(superblock)"); - struct_len = sizeof(struct gfs_sb); - break; - case GFS_METATYPE_RG: /* 2 */ - printw("(rsrc grp hdr)"); - struct_len = sizeof(struct gfs_rgrp); - break; - case GFS_METATYPE_RB: /* 3 */ - printw("(rsrc grp bitblk)"); - struct_len = 512; - break; - case GFS_METATYPE_DI: /* 4 */ - printw("(disk inode)"); - struct_len = sizeof(struct gfs_dinode); - break; - case GFS_METATYPE_IN: /* 5 */ - printw("(indir inode blklst)"); - struct_len = sizeof(struct gfs_indirect); - break; - case GFS_METATYPE_LF: /* 6 */ - printw("(leaf dinode blklst)"); - struct_len = sizeof(struct gfs_leaf); - break; - case GFS_METATYPE_JD: - printw("(journal data)"); - struct_len = sizeof(struct gfs_meta_header); - break; - case GFS_METATYPE_LH: - printw("(log header)"); - struct_len = sizeof(struct gfs_log_header); - break; - case GFS_METATYPE_LD: - printw("(log descriptor)"); - struct_len = sizeof(struct gfs_log_descriptor); - break; - case GFS_METATYPE_EA: - printw("(extended attr hdr)"); - struct_len = sizeof(struct gfs_ea_header); - break; - case GFS_METATYPE_ED: - printw("(extended attr data)"); - struct_len = 512; - break; - default: - printw("(wtf?)"); - struct_len = 512; - break; - } - } - else - struct_len = 512; - line++; - move(line, 0); - if (display_mode == HEX_MODE) { - /* calculate how much of the buffer we can fit on screen */ - screen_chunk_size = ((termlines - 4) * 16) >> 8 << 8; - if (!screen_chunk_size) - screen_chunk_size = 256; - printw("(%d of %d)", (offset / screen_chunk_size) + 1, - (bufsize % screen_chunk_size) > 0 ? - bufsize / screen_chunk_size + 1 : bufsize / screen_chunk_size); - } - move(line, 9); - if (block == sb.sb_jindex_di.no_addr) - printw("----------------- Journal Index file -----------------"); - else if (block == sb.sb_rindex_di.no_addr) - printw("-------------- Resource Group Index file -------------"); - else if (block == sb.sb_quota_di.no_addr) - printw("---------------------- Quota file --------------------"); - else if (block == sb.sb_root_di.no_addr) - printw("-------------------- Root direcory -------------------"); - else if (block == sb.sb_license_di.no_addr) - printw("--------------------- License file -------------------"); - line++; - return ret_type; -} - -/* ------------------------------------------------------------------------ */ -/* hexdump - hex dump the filesystem block to the screen */ -/* ------------------------------------------------------------------------ */ -int hexdump(uint64 startaddr, const char *lpBuffer, int len) -{ - const unsigned char *pointer,*ptr2; - int i; - uint64 l; - - strcpy(edit_fmt,"%02X"); - pointer = (unsigned char *)lpBuffer + offset; - ptr2 = (unsigned char *)lpBuffer + offset; - l = offset; - while (line < termlines && - line <= ((screen_chunk_size / 16) + 2) && - l < bufsize) { - move(line, 0); - attrset(COLOR_PAIR(6)); /* yellow for offsets */ - if (startaddr < 0xffffffff) - printw("%.8"PRIX64,startaddr + l); - else - printw("%.16"PRIX64,startaddr + l); - if (l < struct_len) - attrset(COLOR_PAIR(2)); /* normal part of the structure */ - else - attrset(COLOR_PAIR(4)); /* beyond the end of the structure */ - for (i=0; i<16; i++) { /* first print it in hex */ - if (l+i < struct_len) - attrset(COLOR_PAIR(2)); /* normal part of the structure */ - else - attrset(COLOR_PAIR(4)); /* beyond the end of the structure */ - if (i%4 == 0) - printw(" "); - if (line == edit_row[display_mode] + 3 && - i == edit_col[display_mode]) { - attrset(COLOR_PAIR(5)); /* normal part of the structure */ - memset(edit_string,0,3); - sprintf(edit_string,"%02X",*pointer); - } - printw("%02X",*pointer); - if (line == edit_row[display_mode] + 3 && - i == edit_col[display_mode]) { - if (l < struct_len + offset) - attrset(COLOR_PAIR(2)); /* normal part of the structure */ - else - attrset(COLOR_PAIR(4)); /* beyond end of the structure */ - } - pointer++; - } - printw(" ["); - for (i=0; i<16; i++) { /* now print it in character format */ - if ((*ptr2 >=' ') && (*ptr2 <= '~')) - printw("%c",*ptr2); - else - printw("."); - ptr2++; - } - printw("] "); - if (line - 3 > edit_last[display_mode]) - edit_last[display_mode] = line - 3; - line++; - l+=16; - } - return (offset+len); -} - -/* ------------------------------------------------------------------------ */ -/* display_extended */ -/* ------------------------------------------------------------------------ */ -int display_extended(void) -{ - int e; - - edit_last[display_mode] = 0; - move(line++, 0); - if (indirect_blocks) { - printw("This inode contains %d indirect blocks", indirect_blocks); - line++; - move(line++, 0); - printw("Indirect blocks for this inode:"); - for (e = 0; e < termlines && e < indirect_blocks; e++) { - if (line - 6 == edit_row[display_mode]) - attrset(COLOR_PAIR(5)); - move(line, 5); - printw("%d => %"PRIX64, e + 1, indirect_block[e]); - if (line - 6 == edit_row[display_mode]) { - sprintf(edit_string, "%"PRIX64, indirect_block[e]); - strcpy(edit_fmt, "%"PRIX64); - edit_size[display_mode] = strlen(edit_string); - attrset(COLOR_PAIR(2)); - } - line++; - } - if (line >= 7) /* 7 because it was bumped at the end */ - edit_last[display_mode] = line - 7; - } - else - printw("This block does not have indirect blocks."); - return 0; -} - -/* ------------------------------------------------------------------------ */ -/* display */ -/* ------------------------------------------------------------------------ */ -int display(void) -{ - display_title_lines(); - move(2,0); - if (block_in_mem != block) { /* If we changed blocks from the last read */ - dev_offset = block * bufsize; - ioctl(fd, BLKFLSBUF, 0); - do_lseek(fd, dev_offset); - do_read(fd, buf, bufsize); /* read in the desired block */ - block_in_mem = block; /* remember which block is in memory */ - } - line = 1; - gfs_struct_type = display_block_type(buf); - indirect_blocks = 0; - if (gfs_struct_type == GFS_METATYPE_SB || block == 0x10) - gfs_sb_in(&sb, buf); /* parse it out into the sb structure */ - else if (gfs_struct_type == GFS_METATYPE_DI) { - gfs_dinode_in(&di, buf); /* parse disk inode into structure */ - do_dinode_extended(&di, buf); /* get extended data, if any */ - } - edit_last[display_mode] = 0; - if (display_mode == HEX_MODE) /* if hex display mode */ - hexdump(dev_offset, buf, 256); /* show the block in hex */ - else if (display_mode == GFS_MODE) /* if structure display */ - display_gfs(); /* display the gfs structure */ - else /* otherwise */ - display_extended(); /* display extended blocks */ - refresh(); - return(0); -} - - -/****************************************************************************** -******************************************************************************* -** -** main() -** -** Description: -** Do everything -** -******************************************************************************* -******************************************************************************/ -int main(int argc, char *argv[]) -{ - char device[STRLEN]; - char string[256]; - int i,ch, left_off; - int64 temp_blk; - - prog_name = argv[0]; - - if (argc < 2) - die("no device specified\n"); - - memset(edit_row, 0, sizeof(edit_row)); - memset(edit_col, 0, sizeof(edit_col)); - memset(edit_size, 0, sizeof(edit_size)); - memset(edit_last, 0, sizeof(edit_last)); - display_mode = HEX_MODE; - type_alloc(buf, char, bufsize); /* allocate/malloc a new 4K buffer */ - block = 0x10; - for (i = 1; i < argc; i++) { - if (!strcasecmp(argv[i], "-verbose")) - verbose = TRUE; - else if (!strcasecmp(argv[i], "-V")) { - printf("%s %s (built %s %s)\n", prog_name, RELEASE_VERSION, - __DATE__, __TIME__); - printf("%s\n", REDHAT_COPYRIGHT); - exit(0); - } - else { - strcpy(device,argv[i]); - } - } - fd = open(device, O_RDWR); - if (fd < 0) - die("can't open %s: %s\n", argv[1], strerror(errno)); - max_block = lseek(fd, 0, SEEK_END) / bufsize; - - if (initscr() == NULL) { - fprintf(stderr, "Error: unable to initialize screen.\n"); - exit(-1); - } - - signal(SIGWINCH, UpdateSize); /* handle the terminal resize signal */ - UpdateSize(0); /* update screen size based on terminal settings */ - clear(); - start_color(); - noecho(); - keypad(stdscr, TRUE); - raw(); - curs_set(0); - init_pair(1, COLOR_BLACK, COLOR_CYAN); /* title lines */ - init_pair(2, COLOR_WHITE, COLOR_BLACK); /* normal text */ - init_pair(3, COLOR_BLACK, COLOR_WHITE); /* inverse text */ - init_pair(4, COLOR_RED, COLOR_BLACK); /* special text */ - init_pair(5, COLOR_GREEN, COLOR_BLACK); /* highlighted text */ - init_pair(6, COLOR_CYAN, COLOR_BLACK); /* offsets */ - - while (!Quit) { - display(); - while ((ch=getch()) == 0); // wait for input - switch (ch) - { - /* -------------------------------------------------------------- */ - /* escape or 'q' */ - /* -------------------------------------------------------------- */ - case 0x1b: - case 0x03: - case 'q': - Quit=TRUE; - break; - /* -------------------------------------------------------------- */ - /* home - return to the superblock */ - /* -------------------------------------------------------------- */ - case KEY_HOME: - previous_block = block; - block = 0x10; - offset = 0; - break; - /* -------------------------------------------------------------- */ - /* backspace - return to the previous block */ - /* -------------------------------------------------------------- */ - case KEY_BACKSPACE: - case 0x7f: - temp_blk = block; - block = previous_block; - previous_block = temp_blk; - offset = 0; - break; - /* -------------------------------------------------------------- */ - /* arrow up */ - /* -------------------------------------------------------------- */ - case KEY_UP: - if (edit_row[display_mode] >= 0) /* -1 means change block number */ - edit_row[display_mode]--; - break; - /* -------------------------------------------------------------- */ - /* arrow down */ - /* -------------------------------------------------------------- */ - case KEY_DOWN: - if (edit_row[display_mode] < edit_last[display_mode]) - edit_row[display_mode]++; - break; - /* -------------------------------------------------------------- */ - /* arrow left */ - /* -------------------------------------------------------------- */ - case KEY_LEFT: - if (display_mode == HEX_MODE) { - if (edit_col[display_mode] > 0) - edit_col[display_mode]--; - else - edit_col[display_mode] = 15; - } - break; - /* -------------------------------------------------------------- */ - /* arrow right */ - /* -------------------------------------------------------------- */ - case KEY_RIGHT: - if (display_mode == HEX_MODE) { - if (edit_col[display_mode] < 15) - edit_col[display_mode]++; - else - edit_col[display_mode] = 0; - } - break; - /* -------------------------------------------------------------- */ - /* m - change display mode key */ - /* -------------------------------------------------------------- */ - case 'm': - display_mode = ((display_mode + 1) % DISPLAY_MODES); - break; - /* -------------------------------------------------------------- */ - /* J - Jump to highlighted block number */ - /* -------------------------------------------------------------- */ - case 'j': - if (display_mode == HEX_MODE) { - unsigned int col2; - uint64 *b; - - col2 = edit_col[display_mode] & 0x08;/* thus 0-7->0, 8-15->8 */ - b = (uint64 *)&buf[edit_row[display_mode]*16 + offset + col2]; - temp_blk=gfs64_to_cpu(*b); - } - else - sscanf(edit_string, "%"SCNx64, &temp_blk);/* retrieve in hex */ - if (temp_blk < max_block) { /* if the block number is valid */ - offset = 0; - display_mode = HEX_MODE; - previous_block = block; - block = temp_blk; - } - break; - /* -------------------------------------------------------------- */ - /* g - goto block */ - /* -------------------------------------------------------------- */ - case 'g': - memset(string, 0, sizeof(string)); - sprintf(string,"%"PRIX64, block); - if (bobgets(string, 1, 7, 16)) - sscanf(string, "%"SCNx64, &temp_blk); /* retrieve in hex */ - if (temp_blk < max_block) { - offset = 0; - previous_block = block; - block = temp_blk; - } - break; - /* -------------------------------------------------------------- */ - /* h - help key */ - /* -------------------------------------------------------------- */ - case 'h': - print_usage(); - break; - /* -------------------------------------------------------------- */ - /* b - Back one 4K block */ - /* -------------------------------------------------------------- */ - case 'b': - edit_row[display_mode] = 0; - if (block > 0) { - previous_block = block; - block--; - } - offset = 0; - break; - /* -------------------------------------------------------------- */ - /* page up key */ - /* -------------------------------------------------------------- */ - case 0x19: // ctrl-y for vt100 - case KEY_PPAGE: // PgUp - case 0x15: // ctrl-u for vi compat. - case 0x02: // ctrl-b for less compat. - edit_row[display_mode] = 0; - if (display_mode == GFS_MODE || offset==0) { - previous_block = block; - block--; - if (display_mode == HEX_MODE) - offset = (bufsize % screen_chunk_size) > 0 ? - screen_chunk_size * (bufsize / screen_chunk_size) : - bufsize - screen_chunk_size; - else - offset = 0; - } - else - offset -= screen_chunk_size; - break; - /* -------------------------------------------------------------- */ - /* f - Forward one 4K block */ - /* -------------------------------------------------------------- */ - case 'f': - case ' ': /* space for less/more compat. */ - previous_block = block; - edit_row[display_mode] = 0; - block++; - offset = 0; - break; - /* -------------------------------------------------------------- */ - /* page down key */ - /* -------------------------------------------------------------- */ - case 0x16: // ctrl-v for vt100 - case KEY_NPAGE: // PgDown - case 0x04: // ctrl-d for vi compat. - edit_row[display_mode] = 0; - if (display_mode == GFS_MODE || - offset + screen_chunk_size >= bufsize) { - previous_block = block; - block++; - offset = 0; - } - else - offset += screen_chunk_size; - break; - /* -------------------------------------------------------------- */ - /* enter key - change a value */ - /* -------------------------------------------------------------- */ - case(KEY_ENTER): - case('\n'): - case('\r'): - if (edit_row[display_mode] == -1) { - memset(string, 0, sizeof(string)); - sprintf(string,"%"PRIX64, block); - if (bobgets(string, 1, 7, 16)) - sscanf(string, "%"SCNx64, &temp_blk); /* retrieve in hex */ - if (temp_blk < max_block) { - offset = 0; - previous_block = block; - block = temp_blk; - } - } - else { - if (display_mode == HEX_MODE) { - left_off = ((block * bufsize) < 0xffffffff) ? 9 : 17; - /* 8 and 16 char addresses on screen */ - - if (bobgets(edit_string, edit_row[display_mode] + 3, - (edit_col[display_mode] * 2) + - (edit_col[display_mode] / 4) + left_off, 2)) { - if (strstr(edit_fmt,"X") || strstr(edit_fmt,"x")) { - int hexoffset; - unsigned char ch; - - hexoffset = (edit_row[display_mode] * 16) + - edit_col[display_mode]; - ch = 0x00; - if (isdigit(edit_string[0])) - ch = (edit_string[0] - '0') * 0x10; - else if (edit_string[0] >= 'a' && - edit_string[0] <= 'f') - ch = (edit_string[0] - 'a' + 0x0a) * 0x10; - else if (edit_string[0] >= 'A' && - edit_string[0] <= 'F') - ch = (edit_string[0] - 'A' + 0x0a) * 0x10; - if (isdigit(edit_string[1])) - ch += (edit_string[1] - '0'); - else if (edit_string[1] >= 'a' && - edit_string[1] <= 'f') - ch += (edit_string[1] - 'a' + 0x0a); - else if (edit_string[1] >= 'A' && - edit_string[1] <= 'F') - ch += (edit_string[1] - 'A' + 0x0a); - buf[offset + hexoffset] = ch; - do_lseek(fd, dev_offset); - do_write(fd, buf, bufsize); - fsync(fd); - } - } - } - else if (display_mode == GFS_MODE) - bobgets(edit_string, edit_row[display_mode] + 3, 24, - edit_size[display_mode]); - else - bobgets(edit_string, edit_row[display_mode] + 6, 24, - edit_size[display_mode]); - } - break; - default: - move(termlines - 1, 0); - printw("Keystroke not understood: %02X",ch); - refresh(); - sleep(2); - break; - } /* switch */ - } /* while !Quit */ - clear(); - refresh(); - endwin(); - close(fd); - if (buf) - free(buf); - exit(EXIT_SUCCESS); -} diff --git a/gfs/gfs_edit/hexedit.h b/gfs/gfs_edit/hexedit.h deleted file mode 100644 index 2089d84..0000000 --- a/gfs/gfs_edit/hexedit.h +++ /dev/null @@ -1,180 +0,0 @@ -#ifndef __HEXVIEW_DOT_H__ -#define __HEXVIEW_DOT_H__ - - -#ifndef TRUE -#define TRUE 1 -#endif -#ifndef FALSE -#define FALSE 0 -#endif - -/* Extern Macro */ - -#ifndef EXTERN -#define EXTERN extern -#define INIT(X) -#else -#undef EXTERN -#define EXTERN -#define INIT(X) =X -#endif - -#define DISPLAY_MODES 3 -enum dsp_mode { HEX_MODE = 0, GFS_MODE = 1, EXTENDED_MODE = 2 }; - -EXTERN char *prog_name; -EXTERN int fd; -EXTERN int64 block INIT(0); -EXTERN int64 previous_block INIT(0); -EXTERN int64 block_in_mem INIT(-1); -EXTERN int edit_mode INIT(0); -EXTERN int line, termlines; -EXTERN char edit_fmt[80]; -EXTERN char edit_string[1024]; -EXTERN int verbose INIT(FALSE); -EXTERN uint64 dev_offset INIT(0); -EXTERN uint64 max_block INIT(0); -EXTERN char *buf INIT(NULL); -EXTERN uint64 bufsize INIT(4096); -EXTERN int Quit INIT(FALSE); -EXTERN int termlines INIT(30); -EXTERN int insert INIT(0); -EXTERN const char *termtype; -EXTERN int line INIT(1); -EXTERN int struct_len INIT(0); -EXTERN unsigned int offset; -EXTERN int edit_row[DISPLAY_MODES], edit_col[DISPLAY_MODES]; -EXTERN int edit_size[DISPLAY_MODES], edit_last[DISPLAY_MODES]; -EXTERN char edit_string[1024], edit_fmt[80]; -EXTERN struct gfs_sb sb; -EXTERN struct gfs_dinode di; -EXTERN int screen_chunk_size INIT(512); /* how much of the 4K can fit on screen */ -EXTERN int gfs_struct_type; -EXTERN uint64 indirect_block[512]; /* more than the most indirect ptrs possible - for any given 4K block */ -EXTERN int indirect_blocks INIT(0); /* count of indirect blocks */ -EXTERN enum dsp_mode display_mode INIT(HEX_MODE); - -#define STRLEN (256) -#define SCREEN_HEIGHT (16) -#define SCREEN_WIDTH (16) - -#define die(fmt, args...) \ -{ \ - fprintf(stderr, "%s: ", prog_name); \ - fprintf(stderr, fmt, ## args); \ - exit(EXIT_FAILURE); \ -} - -/* I/O macros */ - -#define do_lseek(fd, off) \ -{ \ - if (lseek((fd), (off), SEEK_SET) != (off)) \ - die("bad seek: %s on line %d of file %s\n", \ - strerror(errno),__LINE__, __FILE__); \ -} - -#define do_read(fd, buff, len) \ -{ \ - if (read((fd), (buff), (len)) != (len)) \ - die("bad read: %s on line %d of file %s\n", \ - strerror(errno), __LINE__, __FILE__); \ -} - -#define do_write(fd, buff, len) \ -{ \ - if (write((fd), (buff), (len)) != (len)) \ - die("bad write: %s on line %d of file %s\n", \ - strerror(errno), __LINE__, __FILE__); \ -} - - - -/* Memory macros */ - -#define type_zalloc(ptr, type, count) \ -{ \ - (ptr) = (type *)malloc(sizeof(type) * (count)); \ - if ((ptr)) \ - memset((char *)(ptr), 0, sizeof(type) * (count)); \ - else \ - die("unable to allocate memory on line %d of file %s\n", \ - __LINE__, __FILE__); \ -} - -#define type_alloc(ptr, type, count) \ -{ \ - (ptr) = (type *)malloc(sizeof(type) * (count)); \ - if (!(ptr)) \ - die("unable to allocate memory on line %d of file %s\n", \ - __LINE__, __FILE__); \ -} - -#define pa(struct, member, count) print_array(#member, struct->member, count); -#define printk printw -#define pv(struct, member, fmt) do { \ - if (line < termlines) { \ - if (line == edit_row[display_mode] + 3) { \ - attrset(COLOR_PAIR(5)); \ - } \ - move(line,0); \ - printw(" "#member":"); \ - move(line,24); \ - printw(fmt, struct->member); \ - move(line, 50); \ - if (strstr(fmt,"X") || strstr(fmt,"x")) \ - printw("(hex)"); \ - else if (strstr(fmt,"s")) \ - printw("(string)"); \ - else \ - printw("(decimal)"); \ - refresh(); \ - if (line == edit_row[display_mode] + 3) { \ - sprintf(edit_string, fmt, struct->member); \ - strcpy(edit_fmt, fmt); \ - edit_size[display_mode] = strlen(edit_string); \ - attrset(COLOR_PAIR(2)); \ - } \ - if (line - 3 > edit_last[display_mode]) \ - edit_last[display_mode] = line - 3; \ - line++; \ - move(line,0); /* this seemingly redundant move needed */ \ - } \ - } while (FALSE); - -#define pv2(struct, member, fmt) do { \ - if (line < termlines) { \ - if (line == edit_row[display_mode] + 3) { \ - attrset(COLOR_PAIR(5)); \ - } \ - move(line,24); \ - printw(fmt, struct->member); \ - move(line, 50); \ - if (strstr(fmt,"X") || strstr(fmt,"x")) \ - printw("(hex)"); \ - else if (strstr(fmt,"s")) \ - printw("(string)"); \ - else \ - printw("(decimal)"); \ - refresh(); \ - if (line == edit_row[display_mode] + 3) { \ - sprintf(edit_string, fmt, struct->member); \ - strcpy(edit_fmt, fmt); \ - edit_size[display_mode] = strlen(edit_string); \ - attrset(COLOR_PAIR(2)); \ - } \ - if (line - 3 > edit_last[display_mode]) \ - edit_last[display_mode] = line - 3; \ - line++; \ - move(line,0); /* this seemingly redundant move needed */ \ - } \ - } while (FALSE); - - -/* Divide x by y. Round up if there is a remainder. */ -#define DIV_RU(x, y) (((x) + (y) - 1) / (y)) - - -#endif /* __HEXVIEW_DOT_H__ */ diff --git a/gfs/man/gfs_edit.8 b/gfs/man/gfs_edit.8 index c7c2b41..0a53b8b 100644 --- a/gfs/man/gfs_edit.8 +++ b/gfs/man/gfs_edit.8 @@ -1,128 +1 @@ -.TH gfs_edit 8 - -.SH NAME -gfs_edit - Display or edit GFS internal structures. - -.SH SYNOPSIS -.B gfs_edit -[\fIOPTION\fR]... \fIDEVICE\fR - -.SH DESCRIPTION -The gfs_edit command is a tool used to examine, edit or display internal -data structures of a GFS filesystem. Use at your own risk. - -.SH OPTIONS -.TP -\fB-V\fP -Print program version information only. - -.SH INTERACTIVE MODE -There are three display modes: hex mode, structure mode and pointers mode. -You use the m key to switch between the modes, as described below. -The modes are as follows: -.TP -Hex mode (default) -Display or edit blocks of the file system in hexadecimal and ascii. - -Lines at the top indicate the currently displayed block number in hex. -If the block contains a GFS data structure, the name of that -structure will appear in the upper right corner of the display. -If the block is a well-known block, such as the superblock or rindex, -there will be a line to indicate what it is. - -In hex mode, you can edit blocks by pressing \fB<enter>\fP and entering -hexadecimal digits to replace the highlighted hex digits. Do NOT precede -the numbers with "0x". For example, if you want to change the value at -offset 0x60 from a 0x12 to 0xef, position your cursor to offset 0x60, -so that the 12 is highlighted, then press \fB<enter>\fP and type in "ef". -You will automatically be returned to display mode (Unlike gfs2_edit, -you may only edit one byte at a time.) - -In hex mode, different colors indicate different things. -For example, an inode will appear white, block offsets will be light -blue, and actual data (anything after the gfs data structure) will be red. - -.TP -Structure mode -Decode the file system block into its GFS structure and -display the values of that structure. This mode is most useful for -jumping around the file system. For example, you can use the arrow -keys to position down to a pointer and press \fBJ\fP to jump to that block. - -.TP -Pointers mode -Display any additional information appearing on the block. -For example, if an inode has block pointers, this will display them and -allow you to scroll through them. You can also position to one of them -and press \fBJ\fP to jump to that block. - -.SH Interactive mode command keys: -.TP -\fBq\fP or \fB<esc>\fP -The \fBq\fP or \fB<escape>\fP keys are used to exit gfs_edit. - -.TP -\fB<arrow/movement keys>\fP up, down, right, left, pg-up, pg-down, home, end -The arrow keys are used to highlight an area of the display. The \fBJ\fP -key may be used to jump to the block that is highlighted. - -.TP -\fBm\fP - Mode switch -The \fBm\fP key is used to switch between the three display modes. -The initial mode is hex mode. Pressing the \fBm\fP key once switches to -structure mode. Pressing it a second time switches from structure mode -to pointers mode. Pressing it a third time takes you back to hex mode again. - -.TP -\fBj\fP - Jump to block -The \fBj\fP key jumps to the block number that is currently highlighted. -In hex mode, hitting J will work when any byte of the pointer is highlighted. - -.TP -\fBg\fP - Goto block -The \fBg\fP key asks for a block number, then jumps there. Note that -in many cases, you can also arrow up so that the current block number -is highlighted, then press \fB<enter>\fP to enter a block number to jump to -in hexadecimal, with no leading "0x". - -.TP -\fBh\fP - Help display -The \fBh\fP key causes the interactive help display to be shown. - -.TP -\fBf\fP or \fB<space>\fP - Forward block -The \fBf\fP key causes you to scroll forward one block. - -.TP -\fBb\fP - Backward block -The \fBb\fP key causes you to scroll backward one block. - -.TP -\fB<home>\fP - Return to superblock -The \fB<home>\fP key takes you back to the superblock. - -.TP -\fB<backspace>\fP -This takes you back to the block you were displaying previously. -Unlike gfs2_edit, gfs_edit only remembers the one block you previously viewed. - -.SH EXAMPLES -.TP -gfs_edit /dev/vg0/lvol0 -This will display the superblock of the gfs file system located on -/dev/vg0/lvol0 and allow you to edit. - -.SH KNOWN LIMITATIONS -.TP -Shortcomings compared to gfs2_edit -Unlike gfs2_edit, gfs_edit cannot print data structures. There is no -alternate color scheme. It does not remember multiple block jumps, -and it can not parse the rindex file and other data structures. -It only operates on file systems with the default 4K block size. -It does not work with gfs2 file systems. - -Since this is primarily a debugging tool and since gfs2_edit can do -more than gfs_edit can, we have no plans at this time to enhance gfs_edit. - -.SH SEE ALSO -gfs2_edit(8) +.so man8/gfs2_edit.8 diff --git a/gfs2/man/gfs2_edit.8 b/gfs2/man/gfs2_edit.8 index 0be8bf8..ef2d931 100644 --- a/gfs2/man/gfs2_edit.8 +++ b/gfs2/man/gfs2_edit.8 @@ -1,7 +1,7 @@ .TH gfs2_edit 8 .SH NAME -gfs2_edit - Display, print or edit GFS2 internal structures. +gfs2_edit - Display, print or edit GFS2 or GFS internal structures. .SH SYNOPSIS .B gfs2_edit hooks/post-receive -- Cluster Project