public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* cluster: STABLE2 - gfs2_edit: Fix indirect block scrolling
@ 2009-06-01 21:54 Bob Peterson
  0 siblings, 0 replies; only message in thread
From: Bob Peterson @ 2009-06-01 21:54 UTC (permalink / raw)
  To: cluster-cvs-relay

Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=88a4dbb59e5643e5dedcb223511cd2f91aeccce2
Commit:        88a4dbb59e5643e5dedcb223511cd2f91aeccce2
Parent:        ff19cfc65e74661e5b5bedff4455d50b40ba6a6e
Author:        Bob Peterson <rpeterso@redhat.com>
AuthorDate:    Mon Jun 1 16:15:41 2009 -0500
Committer:     Bob Peterson <rpeterso@redhat.com>
CommitterDate: Mon Jun 1 16:52:20 2009 -0500

gfs2_edit: Fix indirect block scrolling

bz 503485 - gfs2_edit segfault
---
 gfs2/edit/gfs2hex.c |    2 +-
 gfs2/edit/hexedit.c |   38 +++++++++++++++++++-------------------
 gfs2/edit/hexedit.h |    1 +
 3 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index f4eb681..b8414e2 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -356,7 +356,7 @@ void do_leaf_extended(char *buf, struct iinfo *indir)
 	struct gfs2_dirent de;
 
 	x = 0;
-	memset(indir, 0, sizeof(indir));
+	memset(indir, 0, sizeof(*indir));
 	/* Directory Entries: */
 	for (i = sizeof(struct gfs2_leaf); i < sbd.bsize;
 	     i += de.de_rec_len) {
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 8d3a21a..911f75d 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -1283,19 +1283,19 @@ void print_inode_type(__be16 de_type)
 /* ------------------------------------------------------------------------ */
 int display_leaf(struct iinfo *ind)
 {
-	int start_line, total_dirents = 0;
+	int start_line, total_dirents = start_row[dmode];
 	int d;
 
 	eol(0);
 	if (gfs2_struct_type == GFS2_METATYPE_SB)
 		print_gfs2("The superblock has 2 directories");
 	else
-		print_gfs2("This directory contains %d directory entries.",
+		print_gfs2("This directory block contains %d directory entries.",
 			   ind->ii[0].dirents);
 
 	start_line = line;
-	for (d = 0; d < ind->ii[0].dirents; d++) {
-		if (termlines && d >= termlines - start_line - 1
+	for (d = start_row[dmode]; d < ind->ii[0].dirents; d++) {
+		if (termlines && d >= termlines - start_line - 2
 		    + start_row[dmode])
 			break;
 		total_dirents++;
@@ -1406,6 +1406,7 @@ int display_indirect(struct iinfo *ind, int indblocks, int level, uint64_t start
 		eol(0);
 	}
 	start_line = line;
+	dsplines = termlines - line - 1;
 	for (pndx = start_row[dmode];
 		 (!termlines || pndx < termlines - start_line - 1
 		  + start_row[dmode]) && pndx < indblocks;
@@ -2315,16 +2316,14 @@ void hex_edit(int *exitch)
 void pageup(void)
 {
 	if (dmode == EXTENDED_MODE) {
-		int dsplines = termlines - 6;
-		
-		if (edit_row[dmode] - (dsplines / lines_per_row[dmode]) > 0) {
-			start_row[dmode] -= (dsplines / lines_per_row[dmode]);
+		if (edit_row[dmode] - (dsplines / lines_per_row[dmode]) > 0)
 			edit_row[dmode] -= (dsplines / lines_per_row[dmode]);
-		}
-		else {
-			start_row[dmode] = 0;
+		else
 			edit_row[dmode] = 0;
-		}
+		if (start_row[dmode] - (dsplines / lines_per_row[dmode]) > 0)
+			start_row[dmode] -= (dsplines / lines_per_row[dmode]);
+		else
+			start_row[dmode] = 0;
 	}
 	else {
 		start_row[dmode] = edit_row[dmode] = 0;
@@ -2349,15 +2348,16 @@ void pageup(void)
 void pagedn(void)
 {
 	if (dmode == EXTENDED_MODE) {
-		int dsplines = termlines - 6;
-
-		if ((edit_row[dmode] + dsplines) / lines_per_row[dmode] + 1 <
+		if ((edit_row[dmode] + dsplines) / lines_per_row[dmode] + 1 <=
 		    end_row[dmode]) {
 			start_row[dmode] += dsplines / lines_per_row[dmode];
 			edit_row[dmode] += dsplines / lines_per_row[dmode];
-		}
-		else
+		} else {
 			edit_row[dmode] = end_row[dmode] - 1;
+			while (edit_row[dmode] - start_row[dmode]
+			       + 1 > last_entry_onscreen[dmode])
+				start_row[dmode]++;
+		}
 	}
 	else {
 		start_row[dmode] = edit_row[dmode] = 0;
@@ -2712,7 +2712,8 @@ void interactive_mode(void)
 		case '+':
 			if (dmode == EXTENDED_MODE) {
 				if (edit_row[dmode] + 1 < end_row[dmode]) {
-					if (edit_row[dmode] >= last_entry_onscreen[dmode])
+					if (edit_row[dmode] - start_row[dmode]
+					    + 1 > last_entry_onscreen[dmode])
 						start_row[dmode]++;
 					edit_row[dmode]++;
 				}
@@ -2804,7 +2805,6 @@ void interactive_mode(void)
 		/* --------------------------------------------------------- */
 		case 0x168:
 			if (dmode == EXTENDED_MODE) {
-				int dsplines = termlines - 6;
 				int ents_per_screen = dsplines /
 					lines_per_row[dmode];
 
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index 4961062..9d1fdc8 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -93,6 +93,7 @@ EXTERN int editing INIT(0);
 EXTERN uint64_t temp_blk;
 EXTERN uint64_t starting_blk;
 EXTERN const char *block_type_str[15];
+EXTERN int dsplines;
 
 struct gfs_jindex {
         uint64_t ji_addr;       /* starting block of the journal */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-06-01 21:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-01 21:54 cluster: STABLE2 - gfs2_edit: Fix indirect block scrolling 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).