A new user interface for you! Read more...

File gfs2_edit_move_more_functions_to_extended_c.patch of Package cluster

commit 32006042aa08858de53aada5f8e0120b2d6e6864
Author: Bob Peterson <bob@ganesha.(none)>
Date:   Fri Oct 1 23:03:41 2010 -0500

    gfs2_edit: Move more functions to extended.c
    
    This patch moves more code to the new extended.c source.
    
    rhbz#634623

diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index fbd0080..c95593c 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -247,6 +247,134 @@ static int display_indirect(struct iinfo *ind, int indblocks, int level,
 }
 
 /* ------------------------------------------------------------------------ */
+/* print_inode_type                                                         */
+/* ------------------------------------------------------------------------ */
+static void print_inode_type(__be16 de_type)
+{
+	if (gfs1) {
+		switch(de_type) {
+		case GFS_FILE_NON:
+			print_gfs2("Unknown");
+			break;
+		case GFS_FILE_REG:
+			print_gfs2("File   ");
+			break;
+		case GFS_FILE_DIR:
+			print_gfs2("Dir    ");
+			break;
+		case GFS_FILE_LNK:
+			print_gfs2("Symlink");
+			break;
+		case GFS_FILE_BLK:
+			print_gfs2("BlkDev ");
+			break;
+		case GFS_FILE_CHR:
+			print_gfs2("ChrDev ");
+			break;
+		case GFS_FILE_FIFO:
+			print_gfs2("Fifo   ");
+			break;
+		case GFS_FILE_SOCK:
+			print_gfs2("Socket ");
+			break;
+		default:
+			print_gfs2("%04x   ", de_type);
+			break;
+		}
+		return;
+	}
+	switch(de_type) {
+	case DT_UNKNOWN:
+		print_gfs2("Unknown");
+		break;
+	case DT_REG:
+		print_gfs2("File   ");
+		break;
+	case DT_DIR:
+		print_gfs2("Dir    ");
+		break;
+	case DT_LNK:
+		print_gfs2("Symlink");
+		break;
+	case DT_BLK:
+		print_gfs2("BlkDev ");
+		break;
+	case DT_CHR:
+		print_gfs2("ChrDev ");
+		break;
+	case DT_FIFO:
+		print_gfs2("Fifo   ");
+		break;
+	case DT_SOCK:
+		print_gfs2("Socket ");
+		break;
+	default:
+		print_gfs2("%04x   ", de_type);
+		break;
+	}
+}
+
+/* ------------------------------------------------------------------------ */
+/* display_leaf - display directory leaf                                    */
+/* ------------------------------------------------------------------------ */
+static int display_leaf(struct iinfo *ind)
+{
+	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("Directory block: lf_depth:%d, lf_entries:%d,"
+			   "fmt:%d next=0x%llx (%d dirents).",
+			   ind->ii[0].lf_depth, ind->ii[0].lf_entries,
+			   ind->ii[0].lf_dirent_format,
+			   ind->ii[0].lf_next,
+			   ind->ii[0].dirents);
+
+	start_line = line;
+	for (d = start_row[dmode]; d < ind->ii[0].dirents; d++) {
+		if (termlines && d >= termlines - start_line - 2
+		    + start_row[dmode])
+			break;
+		total_dirents++;
+		if (ind->ii[0].dirents >= 1) {
+			eol(5);
+			if (termlines) {
+				if (edit_row[dmode] >=0 &&
+				    line - start_line - 1 ==
+				    edit_row[dmode] - start_row[dmode]) {
+					COLORS_HIGHLIGHT;
+					sprintf(estring, "%"PRIx64,
+						ind->ii[0].dirent[d].block);
+					strcpy(edit_fmt, "%"PRIx64);
+				}
+			}
+			print_gfs2("%d. (%d). %lld (0x%llx): ",
+				   total_dirents, d + 1,
+				   ind->ii[0].dirent[d].block,
+				   ind->ii[0].dirent[d].block);
+		}
+		print_inode_type(ind->ii[0].dirent[d].dirent.de_type);
+		print_gfs2(" %s", ind->ii[0].dirent[d].filename);
+		if (termlines) {
+			if (edit_row[dmode] >= 0 &&
+			    line - start_line - 1 == edit_row[dmode] -
+			    start_row[dmode])
+				COLORS_NORMAL;
+		}
+	}
+	if (line >= 4)
+		last_entry_onscreen[dmode] = line - 4;
+	eol(0);
+	end_row[dmode] = ind->ii[0].dirents;
+	if (end_row[dmode] < last_entry_onscreen[dmode])
+		end_row[dmode] = last_entry_onscreen[dmode];
+	return 0;
+}
+
+/* ------------------------------------------------------------------------ */
 /* print_block_details                                                      */
 /* ------------------------------------------------------------------------ */
 static void print_block_details(struct iinfo *ind, int level, int cur_height,
diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index 2d78f5b..0f8a84a5 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -27,7 +27,6 @@
 		print_it("  ", fmt, fmt2, struct->member);		\
 	} while (FALSE);
 
-
 struct gfs2_sb sb;
 struct gfs2_buffer_head *bh;
 struct gfs2_dinode di;
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index da07198..8080683 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -548,8 +548,7 @@ int display_block_type(int from_restore)
 			struct_len = sbd.bsize;
 			break;
 		}
-	}
-	else
+	} else
 		struct_len = sbd.bsize;
 	eol(0);
 	if (from_restore)
@@ -948,134 +947,6 @@ int has_indirect_blocks(void)
 }
 
 /* ------------------------------------------------------------------------ */
-/* print_inode_type                                                         */
-/* ------------------------------------------------------------------------ */
-static void print_inode_type(__be16 de_type)
-{
-	if (gfs1) {
-		switch(de_type) {
-		case GFS_FILE_NON:
-			print_gfs2("Unknown");
-			break;
-		case GFS_FILE_REG:
-			print_gfs2("File   ");
-			break;
-		case GFS_FILE_DIR:
-			print_gfs2("Dir    ");
-			break;
-		case GFS_FILE_LNK:
-			print_gfs2("Symlink");
-			break;
-		case GFS_FILE_BLK:
-			print_gfs2("BlkDev ");
-			break;
-		case GFS_FILE_CHR:
-			print_gfs2("ChrDev ");
-			break;
-		case GFS_FILE_FIFO:
-			print_gfs2("Fifo   ");
-			break;
-		case GFS_FILE_SOCK:
-			print_gfs2("Socket ");
-			break;
-		default:
-			print_gfs2("%04x   ", de_type);
-			break;
-		}
-		return;
-	}
-	switch(de_type) {
-	case DT_UNKNOWN:
-		print_gfs2("Unknown");
-		break;
-	case DT_REG:
-		print_gfs2("File   ");
-		break;
-	case DT_DIR:
-		print_gfs2("Dir    ");
-		break;
-	case DT_LNK:
-		print_gfs2("Symlink");
-		break;
-	case DT_BLK:
-		print_gfs2("BlkDev ");
-		break;
-	case DT_CHR:
-		print_gfs2("ChrDev ");
-		break;
-	case DT_FIFO:
-		print_gfs2("Fifo   ");
-		break;
-	case DT_SOCK:
-		print_gfs2("Socket ");
-		break;
-	default:
-		print_gfs2("%04x   ", de_type);
-		break;
-	}
-}
-
-/* ------------------------------------------------------------------------ */
-/* display_leaf - display directory leaf                                    */
-/* ------------------------------------------------------------------------ */
-int display_leaf(struct iinfo *ind)
-{
-	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("Directory block: lf_depth:%d, lf_entries:%d,"
-			   "fmt:%d next=0x%llx (%d dirents).",
-			   ind->ii[0].lf_depth, ind->ii[0].lf_entries,
-			   ind->ii[0].lf_dirent_format,
-			   ind->ii[0].lf_next,
-			   ind->ii[0].dirents);
-
-	start_line = line;
-	for (d = start_row[dmode]; d < ind->ii[0].dirents; d++) {
-		if (termlines && d >= termlines - start_line - 2
-		    + start_row[dmode])
-			break;
-		total_dirents++;
-		if (ind->ii[0].dirents >= 1) {
-			eol(5);
-			if (termlines) {
-				if (edit_row[dmode] >=0 &&
-				    line - start_line - 1 ==
-				    edit_row[dmode] - start_row[dmode]) {
-					COLORS_HIGHLIGHT;
-					sprintf(estring, "%"PRIx64,
-						ind->ii[0].dirent[d].block);
-					strcpy(edit_fmt, "%"PRIx64);
-				}
-			}
-			print_gfs2("%d. (%d). %lld (0x%llx): ",
-				   total_dirents, d + 1,
-				   ind->ii[0].dirent[d].block,
-				   ind->ii[0].dirent[d].block);
-		}
-		print_inode_type(ind->ii[0].dirent[d].dirent.de_type);
-		print_gfs2(" %s", ind->ii[0].dirent[d].filename);
-		if (termlines) {
-			if (edit_row[dmode] >= 0 &&
-			    line - start_line - 1 == edit_row[dmode] -
-			    start_row[dmode])
-				COLORS_NORMAL;
-		}
-	}
-	if (line >= 4)
-		last_entry_onscreen[dmode] = line - 4;
-	eol(0);
-	end_row[dmode] = ind->ii[0].dirents;
-	if (end_row[dmode] < last_entry_onscreen[dmode])
-		end_row[dmode] = last_entry_onscreen[dmode];
-	return 0;
-}
-
-/* ------------------------------------------------------------------------ */
 /* block_is_rindex                                                          */
 /* ------------------------------------------------------------------------ */
 int block_is_rindex(void)
@@ -1824,8 +1695,7 @@ static void pageup(void)
 					sbd.bsize - screen_chunk_size;
 			else
 				offset = 0;
-		}
-		else
+		} else
 			offset -= screen_chunk_size;
 	}
 }
@@ -1853,8 +1723,7 @@ static void pagedn(void)
 		    offset + screen_chunk_size >= sbd.bsize) {
 			block++;
 			offset = 0;
-		}
-		else
+		} else
 			offset += screen_chunk_size;
 	}
 }
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index db57abe..ee34c7d 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -86,6 +86,8 @@ extern uint64_t temp_blk;
 extern uint64_t starting_blk;
 extern const char *block_type_str[15];
 extern int dsplines;
+extern int dsp_lines[DMODES];
+extern int combined_display;
 
 struct gfs_jindex {
         uint64_t ji_addr;       /* starting block of the journal */
@@ -347,6 +349,5 @@ extern uint64_t masterblock(const char *fn);
 extern void gfs_rgrp_print(struct gfs_rgrp *rg);
 extern void gfs_rgrp_in(struct gfs_rgrp *rgrp, struct gfs2_buffer_head *rbh);
 extern int has_indirect_blocks(void);
-extern int display_leaf(struct iinfo *ind);
 
 #endif /* __HEXVIEW_DOT_H__ */