Skip to contentSkip to conversation

debugfs.c extents display.

PATCH In review Nick Dokos 2 participants 3 messages Apr 8, 2009 – Apr 15, 2009

lore
Share & tools
lore

Nick Dokos

author
#0 lore raw

PATCH 4/5 debugfs.c extents display.

Change the first and last block numbers in the list_blocks_struct from blk_t to blk64_t.

Change the list_blocks_proc() to take a blk64_t *blocknr and use ext2fs_block_iterate3(), instead of ...iterate2().

Change fprintf formats to use %llu, instead of %u.

With these changes, it seems to produce the right block numbers: I spot-checked against the extents that my python script reported, but I have not done an exhaustive comparison.

---
 debugfs/debugfs.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
debugfs/debugfs.c +5 -5
index a71da89..6b75410 100644
@@ -378,7 +378,7 @@ void do_dirty_filesys(int argc EXT2FS_ATTR((unused)),
 struct list_blocks_struct {
 	FILE		*f;
 	e2_blkcnt_t	total;
-	blk_t		first_block, last_block;
+	blk64_t		first_block, last_block;
 	e2_blkcnt_t	first_bcnt, last_bcnt;
 	e2_blkcnt_t	first;
 };
@@ -392,17 +392,17 @@ static void finish_range(struct list_blocks_struct *lb)
 	else
 		fprintf(lb->f, ", ");
 	if (lb->first_block == lb->last_block)
-		fprintf(lb->f, "(%lld):%u",
+		fprintf(lb->f, "(%lld):%llu",
 			(long long)lb->first_bcnt, lb->first_block);
 	else
-		fprintf(lb->f, "(%lld-%lld):%u-%u",
+		fprintf(lb->f, "(%lld-%lld):%llu-%llu",
 			(long long)lb->first_bcnt, (long long)lb->last_bcnt,
 			lb->first_block, lb->last_block);
 	lb->first_block = 0;
 }
 
 static int list_blocks_proc(ext2_filsys fs EXT2FS_ATTR((unused)),
-			    blk_t *blocknr, e2_blkcnt_t blockcnt,
+			    blk64_t *blocknr, e2_blkcnt_t blockcnt,
 			    blk_t ref_block EXT2FS_ATTR((unused)),
 			    int ref_offset EXT2FS_ATTR((unused)),
 			    void *private)
@@ -523,7 +523,7 @@ static void dump_blocks(FILE *f, const char *prefix, ext2_ino_t inode)
 	lb.first_block = 0;
 	lb.f = f;
 	lb.first = 1;
-	ext2fs_block_iterate2(current_fs, inode, BLOCK_FLAG_READ_ONLY, NULL,
+	ext2fs_block_iterate3(current_fs, inode, BLOCK_FLAG_READ_ONLY, NULL,
 			      list_blocks_proc, (void *)&lb);
 	finish_range(&lb);
 	if (lb.total)
Signature · 1 line
1.6.0.6
#1 lore raw
Quoted 6 lines · Nick Dokos

Change the first and last block numbers in the list_blocks_struct from blk_t to blk64_t.

Change the list_blocks_proc() to take a blk64_t *blocknr and use ext2fs_block_iterate3(), instead of ...iterate2().

Quoted 7 lines

Change fprintf formats to use %llu, instead of %u.

With these changes, it seems to produce the right block numbers: I spot-checked against the extents that my python script reported, but I have not done an exhaustive comparison.

Quoted 50 lines
---
 debugfs/debugfs.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
debugfs/debugfs.c +5 -5
index a71da89..6b75410 100644
@@ -378,7 +378,7 @@ void do_dirty_filesys(int argc EXT2FS_ATTR((unused)),
 struct list_blocks_struct {
 	FILE		*f;
 	e2_blkcnt_t	total;
-	blk_t		first_block, last_block;
+	blk64_t		first_block, last_block;
 	e2_blkcnt_t	first_bcnt, last_bcnt;
 	e2_blkcnt_t	first;
 };
@@ -392,17 +392,17 @@ static void finish_range(struct list_blocks_struct *lb)
 	else
 		fprintf(lb->f, ", ");
 	if (lb->first_block == lb->last_block)
-		fprintf(lb->f, "(%lld):%u",
+		fprintf(lb->f, "(%lld):%llu",
 			(long long)lb->first_bcnt, lb->first_block);
 	else
-		fprintf(lb->f, "(%lld-%lld):%u-%u",
+		fprintf(lb->f, "(%lld-%lld):%llu-%llu",
 			(long long)lb->first_bcnt, (long long)lb->last_bcnt,
 			lb->first_block, lb->last_block);
 	lb->first_block = 0;
 }
 
 static int list_blocks_proc(ext2_filsys fs EXT2FS_ATTR((unused)),
-			    blk_t *blocknr, e2_blkcnt_t blockcnt,
+			    blk64_t *blocknr, e2_blkcnt_t blockcnt,
 			    blk_t ref_block EXT2FS_ATTR((unused)),
 			    int ref_offset EXT2FS_ATTR((unused)),
 			    void *private)
@@ -523,7 +523,7 @@ static void dump_blocks(FILE *f, const char *prefix, ext2_ino_t inode)
 	lb.first_block = 0;
 	lb.f = f;
 	lb.first = 1;
-	ext2fs_block_iterate2(current_fs, inode, BLOCK_FLAG_READ_ONLY, NULL,
+	ext2fs_block_iterate3(current_fs, inode, BLOCK_FLAG_READ_ONLY, NULL,
 			      list_blocks_proc, (void *)&lb);
 	finish_range(&lb);
 	if (lb.total)
Signature · 1 line
1.6.0.6
#2 lore raw
In reply to Nick Dokos
Quoted 41 lines · Nick Dokos

Change the first and last block numbers in the list_blocks_struct from blk_t to blk64_t.

Change the list_blocks_proc() to take a blk64_t *blocknr and use ext2fs_block_iterate3(), instead of ...iterate2().

Change fprintf formats to use %llu, instead of %u.

With these changes, it seems to produce the right block numbers: I spot-checked against the extents that my python script reported, but I have not done an exhaustive comparison.

---
 debugfs/debugfs.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
debugfs/debugfs.c +3 -3
index a71da89..6b75410 100644
@@ -378,7 +378,7 @@ void do_dirty_filesys(int argc EXT2FS_ATTR((unused)),
 struct list_blocks_struct {
 	FILE		*f;
 	e2_blkcnt_t	total;
-	blk_t		first_block, last_block;
+	blk64_t		first_block, last_block;
 	e2_blkcnt_t	first_bcnt, last_bcnt;
 	e2_blkcnt_t	first;
 };
@@ -392,17 +392,17 @@ static void finish_range(struct list_blocks_struct *lb)
 	else
 		fprintf(lb->f, ", ");
 	if (lb->first_block == lb->last_block)
-		fprintf(lb->f, "(%lld):%u",
+		fprintf(lb->f, "(%lld):%llu",
 			(long long)lb->first_bcnt, lb->first_block);
 	else
-		fprintf(lb->f, "(%lld-%lld):%u-%u",
+		fprintf(lb->f, "(%lld-%lld):%llu-%llu",
 			(long long)lb->first_bcnt, (long long)lb->last_bcnt,

debugfs/debugfs.c static void finish_range(struct list_blocks_struct *lb) · line 408

Quoted 10 lines
debugfs/debugfs.c +1 -1
 			lb->first_block, lb->last_block);
 	lb->first_block = 0;
 }
 
 static int list_blocks_proc(ext2_filsys fs EXT2FS_ATTR((unused)),
-			    blk_t *blocknr, e2_blkcnt_t blockcnt,
+			    blk64_t *blocknr, e2_blkcnt_t blockcnt,
 			    blk_t ref_block EXT2FS_ATTR((unused)),
 			    int ref_offset EXT2FS_ATTR((unused)),
 			    void *private)

Minor correction: ref_block should also be blk64_t. Pushed.

-VAL

Quoted 12 lines
debugfs/debugfs.c +1 -1
@@ -523,7 +523,7 @@ static void dump_blocks(FILE *f, const char *prefix, ext2_ino_t inode)
 	lb.first_block = 0;
 	lb.f = f;
 	lb.first = 1;
-	ext2fs_block_iterate2(current_fs, inode, BLOCK_FLAG_READ_ONLY, NULL,
+	ext2fs_block_iterate3(current_fs, inode, BLOCK_FLAG_READ_ONLY, NULL,
 			      list_blocks_proc, (void *)&lb);
 	finish_range(&lb);
 	if (lb.total)
Signature · 1 line
1.6.0.6