* [Cluster-devel] cluster/gfs2/edit hexedit.c
@ 2007-03-28 22:10 rpeterso
0 siblings, 0 replies; 6+ messages in thread
From: rpeterso @ 2007-03-28 22:10 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: rpeterso at sourceware.org 2007-03-28 23:10:30
Modified files:
gfs2/edit : hexedit.c
Log message:
Jump from RG index was broken.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/edit/hexedit.c.diff?cvsroot=cluster&r1=1.11&r2=1.12
--- cluster/gfs2/edit/hexedit.c 2007/02/28 21:58:46 1.11
+++ cluster/gfs2/edit/hexedit.c 2007/03/28 22:10:29 1.12
@@ -576,6 +576,7 @@
int error, start_line;
struct gfs2_rindex ri;
char buf[sizeof(struct gfs2_rindex)];
+ char highlighted_addr[32];
start_line = line;
error = 0;
@@ -583,6 +584,7 @@
di->i_di.di_size / sizeof(struct gfs2_rindex));
eol(0);
lines_per_row[dmode] = 6;
+ memset(highlighted_addr, 0, sizeof(highlighted_addr));
for (print_entry_ndx=0; ; print_entry_ndx++) {
error = gfs2_readi(di, (void *)&buf,
print_entry_ndx * sizeof(struct gfs2_rindex),
@@ -596,7 +598,8 @@
termlines - start_line - 2)) {
if (edit_row[dmode] == print_entry_ndx) {
COLORS_HIGHLIGHT;
- sprintf(estring, "%" PRIx64, ri.ri_addr);
+ sprintf(highlighted_addr, "%" PRIx64,
+ ri.ri_addr);
}
print_gfs2("RG #%d", print_entry_ndx);
eol(0);
@@ -606,6 +609,7 @@
last_entry_onscreen[dmode] = print_entry_ndx;
}
}
+ strcpy(estring, highlighted_addr);
end_row[dmode] = print_entry_ndx;
return error;
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Cluster-devel] cluster/gfs2/edit hexedit.c
@ 2007-04-24 3:19 rpeterso
0 siblings, 0 replies; 6+ messages in thread
From: rpeterso @ 2007-04-24 3:19 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: rpeterso at sourceware.org 2007-04-24 04:19:11
Modified files:
gfs2/edit : hexedit.c
Log message:
Horrible kludge to allow display/print of the rgs themselves
(but not yet the bitmaps) for easier debugging of bz 223893.
Example: gfs2_edit -p rgs /dev/trin_vg/trin_lv
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/edit/hexedit.c.diff?cvsroot=cluster&r1=1.12&r2=1.13
--- cluster/gfs2/edit/hexedit.c 2007/03/28 22:10:29 1.12
+++ cluster/gfs2/edit/hexedit.c 2007/04/24 03:19:11 1.13
@@ -42,6 +42,8 @@
#include <syslog.h>
+#define RGLIST_DUMMY_BLOCK -2
+
int display(int identify_only);
extern void eol(int col);
extern void do_indirect_extended(char *buf);
@@ -341,7 +343,10 @@
if (edit_row[dmode] == -1)
COLORS_HIGHLIGHT;
}
- print_gfs2("%lld (0x%"PRIx64")", block, block);
+ if (block == RGLIST_DUMMY_BLOCK)
+ print_gfs2("RG List ");
+ else
+ print_gfs2("%lld (0x%"PRIx64")", block, block);
if (termlines) {
if (edit_row[dmode] == -1)
COLORS_NORMAL;
@@ -355,9 +360,14 @@
else
printf(" ");
- if (*(lpBuffer+0)==0x01 && *(lpBuffer+1)==0x16 && *(lpBuffer+2)==0x19 &&
- *(lpBuffer+3)==0x70 && *(lpBuffer+4)==0x00 && *(lpBuffer+5)==0x00 &&
- *(lpBuffer+6)==0x00) { /* If magic number appears at the start */
+ if (block == RGLIST_DUMMY_BLOCK) {
+ ret_type = GFS2_METATYPE_RG;
+ struct_len = sizeof(struct gfs2_rgrp);
+ }
+ else if (*(lpBuffer+0)==0x01 && *(lpBuffer+1)==0x16 &&
+ *(lpBuffer+2)==0x19 && *(lpBuffer+3)==0x70 &&
+ *(lpBuffer+4)==0x00 && *(lpBuffer+5)==0x00 &&
+ *(lpBuffer+6)==0x00) { /* If magic number appears at the start */
ret_type = *(lpBuffer+7);
switch (*(lpBuffer+7)) {
case GFS2_METATYPE_SB: /* 1 */
@@ -431,6 +441,8 @@
print_gfs2("-------------------- Root directory ------------------");
else if (!gfs1 && block == sbd.sd_sb.sb_master_dir.no_addr)
print_gfs2("------------------- Master directory -----------------");
+ else if (!gfs1 && block == RGLIST_DUMMY_BLOCK)
+ print_gfs2("----------------------- RG List ----------------------");
else {
if (gfs1) {
if (block == sbd1->sb_rindex_di.no_addr)
@@ -569,9 +581,9 @@
}
/* ------------------------------------------------------------------------ */
-/* print_rindex - print the rgindex file. */
+/* parse_rindex - print the rgindex file. */
/* ------------------------------------------------------------------------ */
-int print_rindex(struct gfs2_inode *di)
+int parse_rindex(struct gfs2_inode *di, int print_rindex)
{
int error, start_line;
struct gfs2_rindex ri;
@@ -587,8 +599,8 @@
memset(highlighted_addr, 0, sizeof(highlighted_addr));
for (print_entry_ndx=0; ; print_entry_ndx++) {
error = gfs2_readi(di, (void *)&buf,
- print_entry_ndx * sizeof(struct gfs2_rindex),
- sizeof(struct gfs2_rindex));
+ print_entry_ndx * sizeof(struct gfs2_rindex),
+ sizeof(struct gfs2_rindex));
gfs2_rindex_in(&ri, buf);
if (!error) /* end of file */
break;
@@ -602,10 +614,23 @@
ri.ri_addr);
}
print_gfs2("RG #%d", print_entry_ndx);
+ if (!print_rindex)
+ print_gfs2(" located at: %llu (0x%llx)",
+ ri.ri_addr, ri.ri_addr);
eol(0);
if (edit_row[dmode] == print_entry_ndx)
COLORS_NORMAL;
- gfs2_rindex_print(&ri);
+ if(print_rindex)
+ gfs2_rindex_print(&ri);
+ else {
+ struct gfs2_rgrp rg;
+ struct gfs2_buffer_head *tmp_bh;
+
+ tmp_bh = bread(&sbd, ri.ri_addr);
+ gfs2_rgrp_in(&rg, tmp_bh->b_data);
+ gfs2_rgrp_print(&rg);
+ brelse(tmp_bh, not_updated);
+ }
last_entry_onscreen[dmode] = print_entry_ndx;
}
}
@@ -978,6 +1003,18 @@
}
/* ------------------------------------------------------------------------ */
+/* block_is_rglist - there's no such block as the rglist. This is a */
+/* special case meant to parse the rindex and follow the */
+/* blocks to the real rgs. */
+/* ------------------------------------------------------------------------ */
+int block_is_rglist(void)
+{
+ if (block == RGLIST_DUMMY_BLOCK)
+ return TRUE;
+ return FALSE;
+}
+
+/* ------------------------------------------------------------------------ */
/* block_is_jindex */
/* ------------------------------------------------------------------------ */
int block_is_jindex(void)
@@ -1025,6 +1062,7 @@
{
if (has_indirect_blocks() ||
block_is_rindex() ||
+ block_is_rglist() ||
block_is_jindex() ||
block_is_inum_file() ||
block_is_statfs_file() ||
@@ -1047,7 +1085,13 @@
else if (block_is_rindex()) {
tmp_bh = bread(&sbd, block);
tmp_inode = inode_get(&sbd, tmp_bh);
- print_rindex(tmp_inode);
+ parse_rindex(tmp_inode, TRUE);
+ brelse(tmp_bh, not_updated);
+ }
+ else if (block_is_rglist()) {
+ tmp_bh = bread(&sbd, masterblock("rindex"));
+ tmp_inode = inode_get(&sbd, tmp_bh);
+ parse_rindex(tmp_inode, FALSE);
brelse(tmp_bh, not_updated);
}
else if (block_is_jindex()) {
@@ -1136,16 +1180,22 @@
/* ------------------------------------------------------------------------ */
int display(int identify_only)
{
+ uint64_t blk;
+
+ if (block == RGLIST_DUMMY_BLOCK)
+ blk = masterblock("rindex");
+ else
+ blk = block;
if (termlines) {
display_title_lines();
move(2,0);
}
- if (block_in_mem != block) { /* If we changed blocks from the last read */
- dev_offset = block * bufsize;
+ if (block_in_mem != blk) { /* If we changed blocks from the last read */
+ dev_offset = blk * bufsize;
ioctl(fd, BLKFLSBUF, 0);
do_lseek(fd, dev_offset);
do_read(fd, buf, bufsize); /* read in the desired block */
- block_in_mem = block; /* remember which block is in memory */
+ block_in_mem = blk; /* remember which block is in memory */
}
line = 1;
gfs2_struct_type = display_block_type(buf);
@@ -1153,7 +1203,7 @@
return 0;
indirect_blocks = 0;
lines_per_row[dmode] = 1;
- if (gfs2_struct_type == GFS2_METATYPE_SB || block == 0x10) {
+ if (gfs2_struct_type == GFS2_METATYPE_SB || blk == 0x10) {
gfs2_sb_in(&sbd.sd_sb, buf); /* parse it out into the sb structure */
memset(&indirect, 0, sizeof(indirect));
indirect[0].block = sbd.sd_sb.sb_master_dir.no_addr;
@@ -1307,15 +1357,19 @@
else if (!strcmp(string, "quota"))
temp_blk = gfs1_quota_di.no_addr;
}
- else
- temp_blk = masterblock(string);
+ else {
+ if (!strcmp(string, "rgs"))
+ temp_blk = RGLIST_DUMMY_BLOCK;
+ else
+ temp_blk = masterblock(string);
+ }
}
else if (string[0] == '0' && string[1] == 'x')
sscanf(string, "%"SCNx64, &temp_blk); /* retrieve in hex */
else
sscanf(string, "%" PRIu64, &temp_blk); /* retrieve decimal */
- if (temp_blk < max_block) {
+ if (temp_blk == RGLIST_DUMMY_BLOCK || temp_blk < max_block) {
offset = 0;
block = temp_blk;
push_block(block);
@@ -1760,6 +1814,7 @@
fprintf(stderr," inum - prints the inum file.\n");
fprintf(stderr," statfs - prints the statfs file.\n");
fprintf(stderr," rindex - prints the rindex file.\n");
+ fprintf(stderr," rgs - prints all the resource groups (rgs).\n");
fprintf(stderr," quota - prints the quota file.\n");
fprintf(stderr,"-x print in hexmode.\n");
fprintf(stderr,"-h prints this help.\n\n");
@@ -1856,6 +1911,10 @@
else
push_block(masterblock("rindex"));
}
+ else if (!strcmp(argv[i], "rgs")) {
+ if (!gfs1)
+ push_block(RGLIST_DUMMY_BLOCK);
+ }
else if (!strcmp(argv[i], "quota")) {
if (gfs1)
push_block(gfs1_quota_di.no_addr);
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Cluster-devel] cluster/gfs2/edit hexedit.c
@ 2007-06-21 22:15 rpeterso
0 siblings, 0 replies; 6+ messages in thread
From: rpeterso @ 2007-06-21 22:15 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: rpeterso at sourceware.org 2007-06-21 22:15:34
Modified files:
gfs2/edit : hexedit.c
Log message:
Make gfs2_edit handle small different block sizes.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/edit/hexedit.c.diff?cvsroot=cluster&r1=1.13&r2=1.14
--- cluster/gfs2/edit/hexedit.c 2007/04/24 03:19:11 1.13
+++ cluster/gfs2/edit/hexedit.c 2007/06/21 22:15:34 1.14
@@ -1130,7 +1130,7 @@
sbd1 = (struct gfs_sb *)&sbd.sd_sb;
ioctl(fd, BLKFLSBUF, 0);
- do_lseek(fd, 0x10 * bufsize);
+ do_lseek(fd, 0x10 * 4096);
do_read(fd, buf, bufsize); /* read in the desired block */
memset(&sbd, 0, sizeof(struct gfs2_sbd));
sbd.device_fd = fd;
@@ -1160,6 +1160,8 @@
}
else
gfs1 = FALSE;
+ bufsize = sbd.sd_sb.sb_bsize;
+ block = 0x10 * (4096 / bufsize);
}
/* ------------------------------------------------------------------------ */
@@ -1203,7 +1205,7 @@
return 0;
indirect_blocks = 0;
lines_per_row[dmode] = 1;
- if (gfs2_struct_type == GFS2_METATYPE_SB || blk == 0x10) {
+ if (gfs2_struct_type == GFS2_METATYPE_SB || blk == 0x10 * (4096 / bufsize)) {
gfs2_sb_in(&sbd.sd_sb, buf); /* parse it out into the sb structure */
memset(&indirect, 0, sizeof(indirect));
indirect[0].block = sbd.sd_sb.sb_master_dir.no_addr;
@@ -1608,7 +1610,7 @@
edit_row[dmode] = 0;
}
else {
- block = 0x10;
+ block = 0x10 * (4096 / bufsize);
push_block(block);
offset = 0;
}
@@ -1882,7 +1884,7 @@
max_block, max_block);
else if (!strcmp(argv[i], "sb") ||
!strcmp(argv[i], "superblock"))
- push_block(0x10); /* superblock */
+ push_block(0x10 * (4096 / bufsize)); /* superblock */
else if (!strcmp(argv[i], "root") ||
!strcmp(argv[i], "rootdir"))
push_block(sbd.sd_sb.sb_root_dir.no_addr);
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Cluster-devel] cluster/gfs2/edit hexedit.c
@ 2007-06-25 19:57 rpeterso
0 siblings, 0 replies; 6+ messages in thread
From: rpeterso @ 2007-06-25 19:57 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: rpeterso at sourceware.org 2007-06-25 19:57:12
Modified files:
gfs2/edit : hexedit.c
Log message:
Fix a place where indirect offsets were calculated incorrectly.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/edit/hexedit.c.diff?cvsroot=cluster&r1=1.14&r2=1.15
--- cluster/gfs2/edit/hexedit.c 2007/06/21 22:15:34 1.14
+++ cluster/gfs2/edit/hexedit.c 2007/06/25 19:57:11 1.15
@@ -610,8 +610,7 @@
termlines - start_line - 2)) {
if (edit_row[dmode] == print_entry_ndx) {
COLORS_HIGHLIGHT;
- sprintf(highlighted_addr, "%" PRIx64,
- ri.ri_addr);
+ sprintf(highlighted_addr, "%llx", (unsigned long long)ri.ri_addr);
}
print_gfs2("RG #%d", print_entry_ndx);
if (!print_rindex)
@@ -825,7 +824,7 @@
{
int start_line, total_dirents, indir_blocks;
int i, cur_height = -1;
- uint64_t factor[5];
+ uint64_t factor[5]={0,0,0,0,0};
int offsets[5];
last_entry_onscreen[dmode] = 0;
@@ -872,12 +871,22 @@
}
}
if (cur_height >= 0) {
+ int diptrs, inptrs;
+
+ if (gfs1) {
+ diptrs = 483;
+ inptrs = 501;
+ } else {
+ diptrs = (bufsize - sizeof(sizeof(struct gfs2_dinode))) / sizeof(uint64_t);
+ inptrs = (bufsize - sizeof(sizeof(struct gfs2_meta_header))) /
+ sizeof(uint64_t);
+ }
/* Multiply out the max factor based on inode height.*/
/* This is how much data is represented by each */
/* indirect pointer at each height. */
factor[0] = 1ull;
for (i = 0; i < di.di_height; i++)
- factor[i + 1] = factor[i] * (gfs1 ? 501 : 509);
+ factor[i + 1] = factor[i] * inptrs;
}
print_gfs2(" (at height=%d)", cur_height);
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Cluster-devel] cluster/gfs2/edit hexedit.c
@ 2007-11-07 15:07 rpeterso
0 siblings, 0 replies; 6+ messages in thread
From: rpeterso @ 2007-11-07 15:07 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: rpeterso at sourceware.org 2007-11-07 15:07:08
Modified files:
gfs2/edit : hexedit.c
Log message:
Fix a divide by zero if the target isn't a gfs or gfs2 file system.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/edit/hexedit.c.diff?cvsroot=cluster&r1=1.22&r2=1.23
--- cluster/gfs2/edit/hexedit.c 2007/10/18 19:56:41 1.22
+++ cluster/gfs2/edit/hexedit.c 2007/11/07 15:07:07 1.23
@@ -1322,7 +1322,9 @@
else
gfs1 = FALSE;
bufsize = sbd.sd_sb.sb_bsize;
- block = 0x10 * (4096 / bufsize);
+ if (!bufsize)
+ bufsize = GFS2_DEFAULT_BSIZE;
+ block = 0x10 * (GFS2_DEFAULT_BSIZE / bufsize);
}
/* ------------------------------------------------------------------------ */
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Cluster-devel] cluster/gfs2/edit hexedit.c
@ 2007-11-08 18:10 rpeterso
0 siblings, 0 replies; 6+ messages in thread
From: rpeterso @ 2007-11-08 18:10 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: rpeterso at sourceware.org 2007-11-08 18:10:09
Modified files:
gfs2/edit : hexedit.c
Log message:
Printing the quota file wasn't printing its contents due to a bug.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/gfs2/edit/hexedit.c.diff?cvsroot=cluster&r1=1.23&r2=1.24
--- cluster/gfs2/edit/hexedit.c 2007/11/07 15:07:07 1.23
+++ cluster/gfs2/edit/hexedit.c 2007/11/08 18:10:09 1.24
@@ -1247,8 +1247,6 @@
parse_rindex(tmp_inode, TRUE);
brelse(tmp_bh, not_updated);
}
- else if (display_indirect(indirect, indirect_blocks, 0, 0) == 0)
- return -1;
else if (block_is_rglist()) {
tmp_bh = bread(&sbd, masterblock("rindex"));
tmp_inode = inode_get(&sbd, tmp_bh);
@@ -1279,6 +1277,8 @@
print_quota(tmp_inode);
brelse(tmp_bh, not_updated);
}
+ else if (display_indirect(indirect, indirect_blocks, 0, 0) == 0)
+ return -1;
return 0;
}
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-11-08 18:10 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-24 3:19 [Cluster-devel] cluster/gfs2/edit hexedit.c rpeterso
-- strict thread matches above, loose matches on Subject: below --
2007-11-08 18:10 rpeterso
2007-11-07 15:07 rpeterso
2007-06-25 19:57 rpeterso
2007-06-21 22:15 rpeterso
2007-03-28 22:10 rpeterso
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 NNTP newsgroup(s).