public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* cluster: RHEL5 - gfs2_edit: Display pointer numbers and use color changes to
@ 2009-03-25 15:10 Bob Peterson
0 siblings, 0 replies; only message in thread
From: Bob Peterson @ 2009-03-25 15:10 UTC (permalink / raw)
To: cluster-cvs-relay
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=9ee39052aa3655ea76b50a5805b30ceb0bb62983
Commit: 9ee39052aa3655ea76b50a5805b30ceb0bb62983
Parent: fc5f1f56f873b511196eba2d7b70ae959e98e290
Author: Bob Peterson <rpeterso@redhat.com>
AuthorDate: Wed Mar 25 10:06:21 2009 -0500
Committer: Bob Peterson <rpeterso@redhat.com>
CommitterDate: Wed Mar 25 10:06:21 2009 -0500
gfs2_edit: Display pointer numbers and use color changes to
differentiate between zero-data and valid pointers.
bz 483799
This patch does basically two things to improve debugging of
indirect pointer problems such as bug #490136 (for which I
developed it). First, I improved the color scheme and made
it differentiate zero-data from non-zero data for some
metadata block types. This allows you to easily see where a
pointer is located on the screen rather than staring into a
sea of zeroes. Second, I made gfs2_edit tell you what
pointer number your cursor is at for dinodes and indirect
blocks. That way, you can easily check your metapath
information against what's on disk. I transposed the "red"
and "pink" sections so that the cursor is red and therefore
easier to see.
---
gfs2/edit/hexedit.c | 98 +++++++++++++++++++++++++++++++++++++-------------
1 files changed, 72 insertions(+), 26 deletions(-)
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 2da61ce..df965ae 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -30,13 +30,11 @@
#include <sys/mount.h>
#include <dirent.h>
-#include "linux_endian.h"
#include <linux/gfs2_ondisk.h>
#include "copyright.cf"
#define EXTERN
#include "hexedit.h"
-#include "linux_endian.h"
#include "libgfs2.h"
#include "gfs2hex.h"
@@ -46,8 +44,7 @@
const char *mtypes[] = {"none", "sb", "rg", "rb", "di", "in", "lf", "jd",
"lh", "ld", "ea", "ed", "lb", "13", "qc"};
-const char *allocdesc[] = {"Free ", "Data ", "Unlnk",
- "Meta ", "Resrv"};
+const char *allocdesc[] = {"Free ", "Data ", "Unlnk", "Meta ", "Resrv"};
int display(int identify_only);
extern void eol(int col);
@@ -585,8 +582,11 @@ int display_block_type(const char *lpBuffer, int from_restore)
struct_len = sizeof(struct gfs2_dinode);
break;
case GFS2_METATYPE_IN: /* 5 */
- print_gfs2("(indir inode blklst)");
- struct_len = sizeof(struct gfs2_meta_header);
+ print_gfs2("(indir blklist)");
+ if (gfs1)
+ struct_len = sizeof(struct gfs_indirect);
+ else
+ struct_len = sizeof(struct gfs2_meta_header);
break;
case GFS2_METATYPE_LF: /* 6 */
print_gfs2("(directory leaf)");
@@ -628,17 +628,17 @@ int display_block_type(const char *lpBuffer, int from_restore)
break;
default:
print_gfs2("(wtf?)");
- struct_len = 512;
+ struct_len = sbd.bsize;
break;
}
}
else
- struct_len = 512;
+ struct_len = sbd.bsize;
eol(0);
if (from_restore)
return ret_type;
if (termlines && dmode == HEX_MODE) {
- int type;
+ int type, pgnum;
struct rgrp_list *rgd;
rgd = gfs2_blk2rgrpd(&sbd, block);
@@ -650,12 +650,27 @@ int display_block_type(const char *lpBuffer, int from_restore)
screen_chunk_size = ((termlines - 4) * 16) >> 8 << 8;
if (!screen_chunk_size)
screen_chunk_size = 256;
- print_gfs2("(p.%d of %d--%s)",
- (offset / screen_chunk_size) + 1,
+ pgnum = (offset / screen_chunk_size);
+ print_gfs2("(p.%d of %d--%s)", pgnum + 1,
(sbd.bsize % screen_chunk_size) > 0 ?
sbd.bsize / screen_chunk_size + 1 : sbd.bsize /
screen_chunk_size, allocdesc[type]);
/*eol(9);*/
+ if ((*(lpBuffer+7) == GFS2_METATYPE_IN) ||
+ (*(lpBuffer+7) == GFS2_METATYPE_DI &&
+ (*(lpBuffer + 0x8b) || *(lpBuffer + 0x8a)))) {
+ int ptroffset = edit_row[dmode] * 16 + edit_col[dmode];
+
+ if (ptroffset >= struct_len || pgnum) {
+ int pnum;
+
+ pnum = pgnum * screen_chunk_size;
+ pnum += (ptroffset - struct_len);
+ pnum /= sizeof(uint64_t);
+
+ print_gfs2(" pointer 0x%x", pnum);
+ }
+ }
}
if (block == sbd.sd_sb.sb_root_dir.no_addr)
print_gfs2("--------------- Root directory ------------------");
@@ -718,6 +733,8 @@ int hexdump(uint64_t startaddr, const char *lpBuffer, int len)
line <= ((screen_chunk_size / 16) + 2)) ||
(!termlines && l < len)) &&
l < sbd.bsize) {
+ int ptr_not_null = 0;
+
if (termlines) {
move(line, 0);
COLORS_OFFSETS; /* cyan for offsets */
@@ -728,28 +745,55 @@ int hexdump(uint64_t startaddr, const char *lpBuffer, int len)
print_gfs2("%.16"PRIX64, startaddr + l);
if (termlines) {
if (l < struct_len)
- COLORS_NORMAL; /* normal part of the structure */
- else if (gfs2_struct_type == GFS2_METATYPE_DI &&
+ COLORS_NORMAL; /* normal part of structure */
+ else if (gfs2_struct_type == GFS2_METATYPE_DI &&
l < struct_len + di.di_size)
COLORS_CONTENTS; /* after struct but not eof */
else
- COLORS_SPECIAL; /* beyond the end of the structure */
+ COLORS_SPECIAL; /* beyond end of the struct */
}
for (i = 0; i < 16; i++) { /* first print it in hex */
+ /* Figure out if we have a null pointer--for colors */
+ if (((gfs2_struct_type == GFS2_METATYPE_IN) ||
+ (gfs2_struct_type == GFS2_METATYPE_DI &&
+ l < struct_len + di.di_size &&
+ (di.di_height > 0 || !S_ISREG(di.di_mode)))) &&
+ (i==0 || i==8)) {
+ int j;
+
+ ptr_not_null = 0;
+ for (j = 0; j < 8; j++) {
+ if (*(pointer + j)) {
+ ptr_not_null = 1;
+ break;
+ }
+ }
+ }
if (termlines) {
if (l + i < struct_len)
- COLORS_NORMAL; /* normal part of the structure */
- else if (gfs2_struct_type == GFS2_METATYPE_DI &&
- l + i < struct_len + di.di_size)
- COLORS_CONTENTS; /* beyond structure but not eof */
- else
- COLORS_SPECIAL; /* past end of the structure */
+ COLORS_NORMAL; /* in the structure */
+ else if (gfs2_struct_type == GFS2_METATYPE_DI
+ && l + i < struct_len + di.di_size) {
+ if ((!di.di_height &&
+ S_ISREG(di.di_mode)) ||
+ !ptr_not_null)
+ COLORS_CONTENTS;/*stuff data */
+ else
+ COLORS_SPECIAL;/* non-null */
+ }
+ else if (gfs2_struct_type == GFS2_METATYPE_IN){
+ if (ptr_not_null)
+ COLORS_SPECIAL;/* non-null */
+ else
+ COLORS_CONTENTS;/* null */
+ } else
+ COLORS_SPECIAL; /* past the struct */
}
if (i%4 == 0)
print_gfs2(" ");
if (termlines && line == edit_row[dmode] + 3 &&
i == edit_col[dmode]) {
- COLORS_HIGHLIGHT; /* normal part of the structure */
+ COLORS_HIGHLIGHT; /* in the structure */
memset(estring,0,3);
sprintf(estring,"%02X",*pointer);
}
@@ -757,9 +801,9 @@ int hexdump(uint64_t startaddr, const char *lpBuffer, int len)
if (termlines && line == edit_row[dmode] + 3 &&
i == edit_col[dmode]) {
if (l < struct_len + offset)
- COLORS_NORMAL; /* normal part of the structure */
+ COLORS_NORMAL; /* in the structure */
else
- COLORS_SPECIAL; /* beyond end of the structure */
+ COLORS_SPECIAL; /* beyond structure */
}
pointer++;
}
@@ -2182,8 +2226,8 @@ void init_colors()
init_pair(COLOR_TITLE, COLOR_BLACK, COLOR_CYAN);
init_pair(COLOR_NORMAL, COLOR_BLACK, COLOR_WHITE);
init_pair(COLOR_INVERSE, COLOR_WHITE, COLOR_BLACK);
- init_pair(COLOR_SPECIAL, COLOR_RED, COLOR_WHITE);
- init_pair(COLOR_HIGHLIGHT, COLOR_MAGENTA, COLOR_WHITE);
+ init_pair(COLOR_SPECIAL, COLOR_MAGENTA, COLOR_WHITE);
+ init_pair(COLOR_HIGHLIGHT, COLOR_RED, COLOR_WHITE); /*cursor*/
init_pair(COLOR_OFFSETS, COLOR_CYAN, COLOR_WHITE);
init_pair(COLOR_CONTENTS, COLOR_BLUE, COLOR_WHITE);
}
@@ -3413,7 +3457,9 @@ int main(int argc, char *argv[])
read_superblock(fd);
max_block = lseek(fd, 0, SEEK_END) / sbd.bsize;
strcpy(sbd.device_name, device);
- if (!gfs1)
+ if (gfs1)
+ edit_row[GFS2_MODE]++;
+ else
read_master_dir();
block_in_mem = -1;
process_parameters(argc, argv, 1); /* get what to print from cmdline */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-03-25 15:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-25 15:10 cluster: RHEL5 - gfs2_edit: Display pointer numbers and use color changes to Bob Peterson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).