From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2041 invoked by alias); 1 Jun 2009 22:00:01 -0000 Received: (qmail 2023 invoked by alias); 1 Jun 2009 22:00:00 -0000 X-SWARE-Spam-Status: No, hits=-0.8 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_65,J_CHICKENPOX_66,SPF_HELO_PASS X-Spam-Status: No, hits=-0.8 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_65,J_CHICKENPOX_66,SPF_HELO_PASS X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bastion2.fedora.phx.redhat.com Subject: cluster: STABLE3 - gfs2_edit: Fix indirect block scrolling To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: cluster.git X-Git-Refname: refs/heads/STABLE3 X-Git-Reftype: branch X-Git-Oldrev: 561efc990f5098d8f3cef0623b1edd22aa68b130 X-Git-Newrev: 1f06d4db199d1394152f5551c12a8d3308b65fc5 From: Bob Peterson Message-Id: <20090601215935.2DF2C1201E2@lists.fedorahosted.org> Date: Mon, 01 Jun 2009 22:00:00 -0000 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2009-q2/txt/msg00458.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=1f06d4db199d1394152f5551c12a8d3308b65fc5 Commit: 1f06d4db199d1394152f5551c12a8d3308b65fc5 Parent: 561efc990f5098d8f3cef0623b1edd22aa68b130 Author: Bob Peterson AuthorDate: Mon Jun 1 16:44:30 2009 -0500 Committer: Bob Peterson CommitterDate: Mon Jun 1 16:57:46 2009 -0500 gfs2_edit: Fix indirect block scrolling bz 503485 - gfs2_edit segfault --- gfs2/edit/gfs2hex.c | 4 +++- gfs2/edit/hexedit.c | 38 +++++++++++++++++++------------------- gfs2/edit/hexedit.h | 1 + 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c index c3bc513..8de3bb8 100644 --- a/gfs2/edit/gfs2hex.c +++ b/gfs2/edit/gfs2hex.c @@ -69,6 +69,8 @@ int editing = 0; int insert = 0; const char *termtype; WINDOW *wind; +int dsplines = 0; + const char *block_type_str[15] = { "Clump", "Superblock", @@ -390,7 +392,7 @@ void do_leaf_extended(char *dlebuf, 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 c652472..d5d643d 100644 --- a/gfs2/edit/hexedit.c +++ b/gfs2/edit/hexedit.c @@ -1285,19 +1285,19 @@ static void print_inode_type(__be16 de_type) /* ------------------------------------------------------------------------ */ static 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++; @@ -1408,6 +1408,7 @@ static int display_indirect(struct iinfo *ind, int indblocks, int level, uint64_ 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; @@ -2328,16 +2329,14 @@ static void hex_edit(int *exitch) static 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; @@ -2362,15 +2361,16 @@ static void pageup(void) static 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; @@ -2725,7 +2725,8 @@ static 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]++; } @@ -2817,7 +2818,6 @@ static 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 11d4aa3..e53f72f 100644 --- a/gfs2/edit/hexedit.h +++ b/gfs2/edit/hexedit.h @@ -80,6 +80,7 @@ extern int editing; 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 */