From 89e25cfdbf206d6840dc92385ee839dd850294db Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Thu, 8 Nov 2001 17:56:12 -0700 Subject: [PATCH] Support very large files with debugfs (first pass). If a file is created with "dd if=/dev/zero of= bs=1k skip=2047M" it is created properly by the kernel, but fails to be seen properly by debugfs - the blocks are not shown by stat , nor can they be found by icheck. This change fixes that. --- debugfs/debugfs.c | 17 +++++++++-------- debugfs/icheck.c | 20 +++++++++++--------- debugfs/lsdel.c | 2 +- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c index 6b14edd..1f69a75 100644 --- a/debugfs/debugfs.c +++ b/debugfs/debugfs.c @@ -322,11 +322,11 @@ void do_dirty_filesys(int argc, char **argv) } struct list_blocks_struct { - FILE *f; - int total; - blk_t first_block, last_block; - int first_bcnt, last_bcnt; - int first; + FILE *f; + e2_blkcnt_t total; + blk_t first_block, last_block; + e2_blkcnt_t first_bcnt, last_bcnt; + e2_blkcnt_t first; }; static void finish_range(struct list_blocks_struct *lb) @@ -345,8 +345,9 @@ static void finish_range(struct list_blocks_struct *lb) lb->first_block = 0; } -static int list_blocks_proc(ext2_filsys fs, blk_t *blocknr, int blockcnt, - void *private) +static int list_blocks_proc(ext2_filsys fs, blk_t *blocknr, + e2_blkcnt_t blockcnt, blk_t ref_block, + int ref_offset, void *private) { struct list_blocks_struct *lb = (struct list_blocks_struct *) private; @@ -397,7 +398,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_iterate(current_fs, inode, 0, NULL, + ext2fs_block_iterate2(current_fs, inode, 0, NULL, list_blocks_proc, (void *)&lb); finish_range(&lb); if (lb.total) diff --git a/debugfs/icheck.c b/debugfs/icheck.c index 33daa3b..fa065c6 100644 --- a/debugfs/icheck.c +++ b/debugfs/icheck.c @@ -25,18 +25,20 @@ struct block_info { struct block_walk_struct { struct block_info *barray; - int blocks_left; - int num_blocks; + e2_blkcnt_t blocks_left; + e2_blkcnt_t num_blocks; ext2_ino_t inode; }; static int icheck_proc(ext2_filsys fs, blk_t *block_nr, - int blockcnt, + e2_blkcnt_t blockcnt, + blk_t ref_block, + int ref_offset, void *private) { struct block_walk_struct *bw = (struct block_walk_struct *) private; - int i; + e2_blkcnt_t i; for (i=0; i < bw->num_blocks; i++) { if (bw->barray[i].blk == *block_nr) { @@ -84,7 +86,7 @@ void do_icheck(int argc, char **argv) } for (i=1; i < argc; i++) { - bw.barray[i-1].blk = strtol(argv[i], &tmp, 0); + bw.barray[i-1].blk = strtoul(argv[i], &tmp, 0); if (*tmp) { com_err(argv[0], 0, "Bad block - %s", argv[i]); return; @@ -120,12 +122,12 @@ void do_icheck(int argc, char **argv) goto next; bw.inode = ino; - - retval = ext2fs_block_iterate(current_fs, ino, 0, block_buf, - icheck_proc, &bw); + + retval = ext2fs_block_iterate2(current_fs, ino, 0, block_buf, + icheck_proc, &bw); if (retval) { com_err("icheck", retval, - "while calling ext2_block_iterate"); + "while calling ext2fs_block_iterate"); goto next; } diff --git a/debugfs/lsdel.c b/debugfs/lsdel.c index 0165676..6100434 100644 --- a/debugfs/lsdel.c +++ b/debugfs/lsdel.c @@ -130,7 +130,7 @@ void do_lsdel(int argc, char **argv) lsdel_proc, &lsd); if (retval) { com_err("ls_deleted_inodes", retval, - "while calling ext2_block_iterate"); + "while calling ext2fs_block_iterate"); goto next; } if (lsd.free_blocks && !lsd.bad_blocks) { -- 1.8.3.1