Skip to contentSkip to conversation

cluster/gfs2 edit/gfs2hex.c edit/hexedit.c edi ...

Cluster-devel [email protected] 1 participant 1 message Nov 16, 2007

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL5
Changes by: rpeterso at sourceware.org 2007-11-16 19:42:35

Modified files:
gfs2/edit : gfs2hex.c hexedit.c hexedit.h savemeta.c
gfs2/libgfs2 : ondisk.c ondisk.h

Log message:
Resolves: bz 369771: GFS2: bring RHEL gfs2_edit up to date

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/edit/gfs2hex.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.5.2.3&r2=1.5.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/edit/hexedit.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.6.2.3&r2=1.6.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/edit/hexedit.h.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.4.2.5&r2=1.4.2.6
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/edit/savemeta.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.1.2.2&r2=1.1.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/libgfs2/ondisk.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.5.2.3&r2=1.5.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/libgfs2/ondisk.h.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.2&r2=1.2.2.1

gfs2/edit/gfs2hex.c +79 -32
@@ -192,6 +192,7 @@
 		memcpy(&indir->dirent[d].dirent, &de, sizeof(struct gfs2_dirent));
 		memcpy(&indir->dirent[d].filename,
 			   ptr + sizeof(struct gfs2_dirent), de.de_name_len);
+		indir->dirent[d].filename[de.de_name_len] = '\0';
 		indir->dirent[d].block = de.de_inum.no_addr;
 		indir->is_dir = TRUE;
 		indir->dirents++;
@@ -222,7 +223,7 @@
 		(gfs1 && di->__pad1 == GFS_FILE_DIR);
 
 	indirect_blocks = 0;
-	memset(&indirect, 0, sizeof(indirect));
+	memset(indirect, 0, sizeof(indirect));
 	if (di->di_height > 0) {
 		/* Indirect pointers */
 		for (x = sizeof(struct gfs2_dinode), y = 0;
@@ -230,21 +231,23 @@
 			 x += sizeof(uint64_t), y++) {
 			p = be64_to_cpu(*(uint64_t *)(buf + x));
 			if (p) {
-				indirect[indirect_blocks].block = p;
-				indirect[indirect_blocks].is_dir = FALSE;
+				indirect->ii[indirect_blocks].block = p;
+				indirect->ii[indirect_blocks].is_dir = FALSE;
 				indirect_blocks++;
 			}
 		}
 	}
-	else if (isdir &&
-			 !(di->di_flags & GFS2_DIF_EXHASH)) {
+	else if (isdir && !(di->di_flags & GFS2_DIF_EXHASH)) {
 		int skip = 0;
+
 		/* Directory Entries: */
-		indirect[0].dirents = 0;
-		indirect[0].block = block;
-		indirect[0].is_dir = TRUE;
+		indirect->ii[0].dirents = 0;
+		indirect->ii[0].block = block;
+		indirect->ii[0].is_dir = TRUE;
 		for (x = sizeof(struct gfs2_dinode); x < bufsize; x += skip) {
-			skip = indirect_dirent(&indirect[0], buf + x, indirect[0].dirents);
+			skip = indirect_dirent(indirect->ii,
+					       buf + x,
+					       indirect->ii[0].dirents);
 			if (skip <= 0)
 				break;
 		}
@@ -267,20 +270,22 @@
 				struct gfs2_leaf leaf;
 				unsigned int bufoffset;
 
+				if (last >= max_block)
+					break;
 				tmp_bh = bread(&sbd, last);
 				gfs2_leaf_in(&leaf, tmp_bh->b_data);
-				indirect[indirect_blocks].dirents = 0;
+				indirect->ii[indirect_blocks].dirents = 0;
 				for (direntcount = 0, bufoffset = sizeof(struct gfs2_leaf);
 					 bufoffset < bufsize;
 					 direntcount++, bufoffset += skip) {
-					skip = indirect_dirent(&indirect[indirect_blocks],
+					skip = indirect_dirent(&indirect->ii[indirect_blocks],
 										   tmp_bh->b_data + bufoffset,
 										   direntcount);
 					if (skip <= 0)
 						break;
 				}
 				brelse(tmp_bh, not_updated);
-				indirect[indirect_blocks].block = last;
+				indirect->ii[indirect_blocks].block = last;
 				indirect_blocks++;
 				last = p;
 			} /* if not duplicate pointer */
@@ -303,24 +308,26 @@
 **
 *******************************************************************************
 ******************************************************************************/
-void do_indirect_extended(char *buf)
+int do_indirect_extended(char *buf, struct iinfo *iinf)
 {
 	unsigned int x, y;
 	uint64_t p;
+	int i_blocks;
 
-	indirect_blocks = 0;
-	memset(&indirect, 0, sizeof(indirect));
+	i_blocks = 0;
+	memset(iinf, 0, sizeof(struct iinfo));
 	for (x = (gfs1 ? sizeof(struct gfs_indirect):
 			  sizeof(struct gfs2_meta_header)), y = 0;
 		 x < bufsize;
 		 x += sizeof(uint64_t), y++) {
 		p = be64_to_cpu(*(uint64_t *)(buf + x));
 		if (p) {
-			indirect[indirect_blocks].block = p;
-			indirect[indirect_blocks].is_dir = FALSE;
-			indirect_blocks++;
+			iinf->ii[i_blocks].block = p;
+			iinf->ii[i_blocks].is_dir = FALSE;
+			i_blocks++;
 		}
 	}
+	return i_blocks;
 }
 
 /******************************************************************************
@@ -338,20 +345,32 @@
 **
 *******************************************************************************
 ******************************************************************************/
-void do_leaf_extended(char *buf)
+void do_leaf_extended(char *buf, struct iinfo *indir)
 {
+	int x, i;
 	struct gfs2_dirent de;
-	unsigned int x;
 
-	eol(0);
-	print_gfs2("Directory Entries:");
-	eol(0);
-
-	for (x = sizeof(struct gfs2_leaf); x < bufsize; x += de.de_rec_len) {
-		eol(0);
-		gfs2_dirent_in(&de, buf + x);
-		if (de.de_inum.no_addr)
-			gfs2_dirent_print(&de, buf + x + sizeof(struct gfs2_dirent));
+	x = 0;
+	memset(indir, 0, sizeof(indir));
+	/* Directory Entries: */
+	for (i = sizeof(struct gfs2_leaf); i < bufsize;
+	     i += de.de_rec_len) {
+		gfs2_dirent_in(&de, buf + i);
+		if (de.de_inum.no_addr) {
+			indir->ii[0].block = de.de_inum.no_addr;
+			indir->ii[0].dirent[x].block = de.de_inum.no_addr;
+			memcpy(&indir->ii[0].dirent[x].dirent,
+			       &de, sizeof(struct gfs2_dirent));
+			memcpy(&indir->ii[0].dirent[x].filename,
+			       buf + i + sizeof(struct gfs2_dirent),
+			       de.de_name_len);
+			indir->ii[0].dirent[x].filename[de.de_name_len] = '\0';
+			indir->ii[0].is_dir = TRUE;
+			indir->ii[0].dirents++;
+			x++;
+		}
+		if (de.de_rec_len <= sizeof(struct gfs2_dirent))
+			break;
 	}
 }
 
@@ -456,7 +475,10 @@
 	struct gfs2_meta_header mh;
 	struct gfs2_rgrp rg;
 	struct gfs2_leaf lf;
+	struct gfs_log_header lh1;
 	struct gfs2_log_header lh;
+	struct gfs2_log_descriptor ld;
+	struct gfs2_quota_change qc;
 
 	uint32_t magic;
 
@@ -517,14 +539,26 @@
 		case GFS2_METATYPE_LH:
 			print_gfs2("Log Header:");
 			eol(0);
-			gfs2_log_header_in(&lh, buf);
-			gfs2_log_header_print(&lh);
+			if (gfs1) {
+				gfs_log_header_in(&lh1, buf);
+				gfs_log_header_print(&lh1);
+			} else {
+				gfs2_log_header_in(&lh, buf);
+				gfs2_log_header_print(&lh);
+			}
 			break;
 			
+		case GFS2_METATYPE_LD:
+			print_gfs2("Log descriptor");
+			eol(0);
+			gfs2_log_descriptor_in(&ld, buf);
+			gfs2_log_descriptor_print(&ld);
+			break;
+
 		case GFS2_METATYPE_EA:
 			print_gfs2("Eattr Block:");
 			eol(0);
-			gfs2_meta_header_print(&mh);
+			do_eattr_extended(buf);
 			break;
 			
 		case GFS2_METATYPE_ED:
@@ -533,6 +567,19 @@
 			gfs2_meta_header_print(&mh);
 			break;
 			
+		case GFS2_METATYPE_LB:
+			print_gfs2("Log Buffer");
+			eol(0);
+			gfs2_meta_header_print(&mh);
+			break;
+
+		case GFS2_METATYPE_QC:
+			print_gfs2("Quota Change");
+			eol(0);
+			gfs2_quota_change_in(&qc, buf);
+			gfs2_quota_change_print(&qc);
+			break;
+
 		default:
 			print_gfs2("Unknown metadata type");
 			eol(0);
gfs2/edit/hexedit.c +651 -198

1,139 lines not on this page · raw message

gfs2/edit/hexedit.h +55 -12

93 lines not on this page · raw message

gfs2/edit/savemeta.c +349 -70

601 lines not on this page · raw message

gfs2/libgfs2/ondisk.c +2 -2
@@ -386,7 +386,7 @@
 
 	memset(buf, 0, GFS2_FNAMESIZE + 1);
 	memcpy(buf, name, de->de_name_len);
-	printf("  name = %s\n", buf);
+	print_it("  name", "%s", NULL, buf);
 }
 
 void gfs2_leaf_in(struct gfs2_leaf *lf, char *buf)
@@ -462,7 +462,7 @@
 
 	memset(buf, 0, GFS2_EA_MAX_NAME_LEN + 1);
 	memcpy(buf, name, ea->ea_name_len);
-	printf("  name = %s\n", buf);
+	print_it("  name", "%s", NULL, buf);
 }
 
 void gfs2_log_header_in(struct gfs2_log_header *lh, char *buf)
gfs2/libgfs2/ondisk.h +2 -0
@@ -35,6 +35,8 @@
 extern void gfs2_ea_header_out(struct gfs2_ea_header *ea, char *buf);
 extern void gfs2_log_header_in(struct gfs2_log_header *lh, char *buf);
 extern void gfs2_log_header_out(struct gfs2_log_header *lh, char *buf);
+extern void gfs2_log_descriptor_in(struct gfs2_log_descriptor *ld, char *buf);
+extern void gfs2_log_descriptor_out(struct gfs2_log_descriptor *ld, char *buf);
 extern void gfs2_inum_range_in(struct gfs2_inum_range *ir, char *buf);
 extern void gfs2_inum_range_out(struct gfs2_inum_range *ir, char *buf);
 extern void gfs2_statfs_change_in(struct gfs2_statfs_change *sc, char *buf);