ext2_filsys current_fs = NULL;
ext2_ino_t root, cwd;
-static void open_filesystem(char *device, int open_flags, blk_t superblock,
- blk_t blocksize, int catastrophic,
+static void open_filesystem(char *device, int open_flags, blk64_t superblock,
+ blk64_t blocksize, int catastrophic,
char *data_filename)
{
int retval;
{
int c, err;
int catastrophic = 0;
- blk_t superblock = 0;
- blk_t blocksize = 0;
+ blk64_t superblock = 0;
+ blk64_t blocksize = 0;
int open_flags = EXT2_FLAG_SOFTSUPP_FEATURES;
char *data_filename = 0;
{
dgrp_t i;
FILE *out;
- struct ext2_group_desc *gdp;
int c, header_only = 0;
int numdirs = 0, first, gdt_csum;
list_super2(current_fs->super, out);
for (i=0; i < current_fs->group_desc_count; i++)
- numdirs += current_fs->group_desc[i].bg_used_dirs_count;
+ numdirs += ext2fs_bg_used_dirs_count(current_fs, i);
fprintf(out, "Directories: %d\n", numdirs);
if (header_only) {
gdt_csum = EXT2_HAS_RO_COMPAT_FEATURE(current_fs->super,
EXT4_FEATURE_RO_COMPAT_GDT_CSUM);
- gdp = ¤t_fs->group_desc[0];
- for (i = 0; i < current_fs->group_desc_count; i++, gdp++) {
- fprintf(out, " Group %2d: block bitmap at %u, "
- "inode bitmap at %u, "
- "inode table at %u\n"
- " %d free %s, "
- "%d free %s, "
- "%d used %s%s",
- i, gdp->bg_block_bitmap,
- gdp->bg_inode_bitmap, gdp->bg_inode_table,
- gdp->bg_free_blocks_count,
- gdp->bg_free_blocks_count != 1 ? "blocks" : "block",
- gdp->bg_free_inodes_count,
- gdp->bg_free_inodes_count != 1 ? "inodes" : "inode",
- gdp->bg_used_dirs_count,
- gdp->bg_used_dirs_count != 1 ? "directories"
- : "directory", gdt_csum ? ", " : "\n");
+ for (i = 0; i < current_fs->group_desc_count; i++) {
+ fprintf(out, " Group %2d: block bitmap at %llu, "
+ "inode bitmap at %llu, "
+ "inode table at %llu\n"
+ " %u free %s, "
+ "%u free %s, "
+ "%u used %s%s",
+ i, ext2fs_block_bitmap_loc(current_fs, i),
+ ext2fs_inode_bitmap_loc(current_fs, i),
+ ext2fs_inode_table_loc(current_fs, i),
+ ext2fs_bg_free_blocks_count(current_fs, i),
+ ext2fs_bg_free_blocks_count(current_fs, i) != 1 ?
+ "blocks" : "block",
+ ext2fs_bg_free_inodes_count(current_fs, i),
+ ext2fs_bg_free_inodes_count(current_fs, i) != 1 ?
+ "inodes" : "inode",
+ ext2fs_bg_used_dirs_count(current_fs, i),
+ ext2fs_bg_used_dirs_count(current_fs, i) != 1 ? "directories"
+ : "directory", gdt_csum ? ", " : "\n");
if (gdt_csum)
- fprintf(out, "%d unused %s\n",
- gdp->bg_itable_unused,
- gdp->bg_itable_unused != 1 ? "inodes":"inode");
+ fprintf(out, "%u unused %s\n",
+ ext2fs_bg_itable_unused(current_fs, i),
+ ext2fs_bg_itable_unused(current_fs, i) != 1 ?
+ "inodes" : "inode");
first = 1;
print_bg_opts(current_fs, i, EXT2_BG_INODE_UNINIT, "Inode not init",
&first, out);
&first, out);
if (gdt_csum) {
fprintf(out, "%sChecksum 0x%04x",
- first ? " [":", ", gdp->bg_checksum);
+ first ? " [":", ", ext2fs_bg_checksum(current_fs, i));
first = 0;
}
if (!first)
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;
};
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,
- blk_t ref_block EXT2FS_ATTR((unused)),
+ blk64_t *blocknr, e2_blkcnt_t blockcnt,
+ blk64_t ref_block EXT2FS_ATTR((unused)),
int ref_offset EXT2FS_ATTR((unused)),
void *private)
{
else
fprintf(lb->f, ", ");
if (blockcnt == -1)
- fprintf(lb->f, "(IND):%u", *blocknr);
+ fprintf(lb->f, "(IND):%llu", (unsigned long long) *blocknr);
else if (blockcnt == -2)
- fprintf(lb->f, "(DIND):%u", *blocknr);
+ fprintf(lb->f, "(DIND):%llu", (unsigned long long) *blocknr);
else if (blockcnt == -3)
- fprintf(lb->f, "(TIND):%u", *blocknr);
+ fprintf(lb->f, "(TIND):%llu", (unsigned long long) *blocknr);
return 0;
}
lb.first_block = 0;
lb.f = f;
lb.first = 1;
- ext2fs_block_iterate2(current_fs, inode, BLOCK_FLAG_READ_ONLY, NULL,
- list_blocks_proc, (void *)&lb);
+ ext2fs_block_iterate3(current_fs, inode, BLOCK_FLAG_READ_ONLY, NULL,
+ list_blocks_proc, (void *)&lb);
finish_range(&lb);
if (lb.total)
fprintf(f, "\n%sTOTAL: %lld\n", prefix, (long long)lb.total);
void do_freeb(int argc, char *argv[])
{
- blk_t block;
- blk_t count = 1;
+ blk64_t block;
+ blk64_t count = 1;
if (common_block_args_process(argc, argv, &block, &count))
return;
return;
while (count-- > 0) {
if (!ext2fs_test_block_bitmap2(current_fs->block_map,block))
- com_err(argv[0], 0, "Warning: block %u already clear",
+ com_err(argv[0], 0, "Warning: block %llu already clear",
block);
ext2fs_unmark_block_bitmap2(current_fs->block_map,block);
block++;
void do_setb(int argc, char *argv[])
{
- blk_t block;
- blk_t count = 1;
+ blk64_t block;
+ blk64_t count = 1;
if (common_block_args_process(argc, argv, &block, &count))
return;
return;
while (count-- > 0) {
if (ext2fs_test_block_bitmap2(current_fs->block_map,block))
- com_err(argv[0], 0, "Warning: block %u already set",
+ com_err(argv[0], 0, "Warning: block %llu already set",
block);
ext2fs_mark_block_bitmap2(current_fs->block_map,block);
block++;
void do_testb(int argc, char *argv[])
{
- blk_t block;
- blk_t count = 1;
+ blk64_t block;
+ blk64_t count = 1;
if (common_block_args_process(argc, argv, &block, &count))
return;
while (count-- > 0) {
if (ext2fs_test_block_bitmap2(current_fs->block_map,block))
- printf("Block %u marked in use\n", block);
+ printf("Block %llu marked in use\n", block);
else
- printf("Block %u not in use\n", block);
+ printf("Block %llu not in use\n", block);
block++;
}
}
make_link(argv[1], argv[2]);
}
-static int mark_blocks_proc(ext2_filsys fs, blk_t *blocknr,
- int blockcnt EXT2FS_ATTR((unused)),
+static int mark_blocks_proc(ext2_filsys fs, blk64_t *blocknr,
+ e2_blkcnt_t blockcnt EXT2FS_ATTR((unused)),
+ blk64_t ref_block EXT2FS_ATTR((unused)),
+ int ref_offset EXT2FS_ATTR((unused)),
void *private EXT2FS_ATTR((unused)))
{
- blk_t block;
+ blk64_t block;
block = *blocknr;
- ext2fs_block_alloc_stats(fs, block, +1);
+ ext2fs_block_alloc_stats2(fs, block, +1);
return 0;
}
if (debugfs_write_inode(ino, &inode, argv[0]))
return;
- ext2fs_block_iterate(current_fs, ino, BLOCK_FLAG_READ_ONLY, NULL,
- mark_blocks_proc, NULL);
+ ext2fs_block_iterate3(current_fs, ino, BLOCK_FLAG_READ_ONLY, NULL,
+ mark_blocks_proc, NULL);
ext2fs_inode_alloc_stats2(current_fs, ino, +1, 0);
void do_find_free_block(int argc, char *argv[])
{
- blk_t free_blk, goal, first_free = 0;
+ blk64_t free_blk, goal, first_free = 0;
int count;
errcode_t retval;
char *tmp;
printf("Free blocks found: ");
free_blk = goal - 1;
while (count-- > 0) {
- retval = ext2fs_new_block(current_fs, free_blk + 1, 0,
- &free_blk);
+ retval = ext2fs_new_block2(current_fs, free_blk + 1, 0,
+ &free_blk);
if (first_free) {
if (first_free == free_blk)
break;
com_err("ext2fs_new_block", retval, 0);
return;
} else
- printf("%u ", free_blk);
+ printf("%llu ", free_blk);
}
printf("\n");
}
}
-static int release_blocks_proc(ext2_filsys fs, blk_t *blocknr,
- int blockcnt EXT2FS_ATTR((unused)),
+static int release_blocks_proc(ext2_filsys fs, blk64_t *blocknr,
+ e2_blkcnt_t blockcnt EXT2FS_ATTR((unused)),
+ blk64_t ref_block EXT2FS_ATTR((unused)),
+ int ref_offset EXT2FS_ATTR((unused)),
void *private EXT2FS_ATTR((unused)))
{
- blk_t block;
+ blk64_t block;
block = *blocknr;
- ext2fs_block_alloc_stats(fs, block, -1);
+ ext2fs_block_alloc_stats2(fs, block, -1);
return 0;
}
if (!ext2fs_inode_has_valid_blocks(&inode_buf))
return;
- ext2fs_block_iterate(current_fs, inode, BLOCK_FLAG_READ_ONLY, NULL,
- release_blocks_proc, NULL);
+ ext2fs_block_iterate3(current_fs, inode, BLOCK_FLAG_READ_ONLY, NULL,
+ release_blocks_proc, NULL);
printf("\n");
ext2fs_inode_alloc_stats2(current_fs, inode, -1,
LINUX_S_ISDIR(inode_buf.i_mode));
void do_bmap(int argc, char *argv[])
{
ext2_ino_t ino;
- blk_t blk, pblk;
+ blk64_t blk, pblk;
int err;
errcode_t errcode;
return;
blk = parse_ulong(argv[2], argv[0], "logical_block", &err);
- errcode = ext2fs_bmap(current_fs, ino, 0, 0, 0, blk, &pblk);
+ errcode = ext2fs_bmap2(current_fs, ino, 0, 0, 0, blk, 0, &pblk);
if (errcode) {
com_err("argv[0]", errcode,
- "while mapping logical block %u\n", blk);
+ "while mapping logical block %llu\n", blk);
return;
}
- printf("%u\n", pblk);
+ printf("%llu\n", pblk);
}
void do_imap(int argc, char *argv[])
offset = ((ino - 1) % EXT2_INODES_PER_GROUP(current_fs->super)) *
EXT2_INODE_SIZE(current_fs->super);
block = offset >> EXT2_BLOCK_SIZE_BITS(current_fs->super);
- if (!current_fs->group_desc[(unsigned)group].bg_inode_table) {
+ if (!ext2fs_inode_table_loc(current_fs, (unsigned)group)) {
com_err(argv[0], 0, "Inode table for group %lu is missing\n",
group);
return;
}
- block_nr = current_fs->group_desc[(unsigned)group].bg_inode_table +
+ block_nr = ext2fs_inode_table_loc(current_fs, (unsigned)group) +
block;
offset &= (EXT2_BLOCK_SIZE(current_fs->super) - 1);
char *request = 0;
int exit_status = 0;
char *cmd_file = 0;
- blk_t superblock = 0;
- blk_t blocksize = 0;
+ blk64_t superblock = 0;
+ blk64_t blocksize = 0;
int catastrophic = 0;
char *data_filename = 0;
static void htree_dump_leaf_node(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode *inode,
struct ext2_dx_root_info * rootnode,
- blk_t blk, char *buf)
+ blk64_t blk, char *buf)
{
errcode_t errcode;
struct ext2_dir_entry *dirent;
unsigned int offset = 0;
char name[EXT2_NAME_LEN + 1];
char tmp[EXT2_NAME_LEN + 16];
- blk_t pblk;
+ blk64_t pblk;
ext2_dirhash_t hash, minor_hash;
unsigned int rec_len;
int hash_alg;
- errcode = ext2fs_bmap(fs, ino, inode, buf, 0, blk, &pblk);
+ errcode = ext2fs_bmap2(fs, ino, inode, buf, 0, blk, 0, &pblk);
if (errcode) {
com_err("htree_dump_leaf_node", errcode,
- "while mapping logical block %u\n", blk);
+ "while mapping logical block %llu\n", blk);
return;
}
- printf("Reading directory block %lu, phys %lu\n",
- (unsigned long) blk, (unsigned long) pblk);
+ printf("Reading directory block %llu, phys %llu\n", blk, pblk);
errcode = ext2fs_read_dir_block2(current_fs, pblk, buf, 0);
if (errcode) {
com_err("htree_dump_leaf_node", errcode,
- "while reading block %lu (%lu)\n",
- (unsigned long) blk, (unsigned long) pblk);
+ "while reading block %llu (%llu)\n",
+ blk, pblk);
return;
}
hash_alg = rootnode->hash_version;
(rec_len < 8) ||
((rec_len % 4) != 0) ||
((((unsigned) dirent->name_len & 0xFF)+8) > rec_len)) {
- fprintf(pager, "Corrupted directory block (%u)!\n", blk);
+ fprintf(pager, "Corrupted directory block (%llu)!\n",
+ blk);
break;
}
thislen = ((dirent->name_len & 0xFF) < EXT2_NAME_LEN) ?
static void htree_dump_int_block(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode *inode,
struct ext2_dx_root_info * rootnode,
- blk_t blk, char *buf, int level);
+ blk64_t blk, char *buf, int level);
static void htree_dump_int_node(ext2_filsys fs, ext2_ino_t ino,
static void htree_dump_int_block(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode *inode,
struct ext2_dx_root_info * rootnode,
- blk_t blk, char *buf, int level)
+ blk64_t blk, char *buf, int level)
{
char *cbuf;
errcode_t errcode;
- blk_t pblk;
+ blk64_t pblk;
cbuf = malloc(fs->blocksize);
if (!cbuf) {
return;
}
- errcode = ext2fs_bmap(fs, ino, inode, buf, 0, blk, &pblk);
+ errcode = ext2fs_bmap2(fs, ino, inode, buf, 0, blk, 0, &pblk);
if (errcode) {
com_err("htree_dump_int_block", errcode,
- "while mapping logical block %u\n", blk);
+ "while mapping logical block %llu\n", blk);
goto errout;
}
errcode = io_channel_read_blk64(current_fs->io, pblk, 1, buf);
if (errcode) {
com_err("htree_dump_int_block", errcode,
- "while reading block %u\n", blk);
+ "while reading block %llu\n", blk);
goto errout;
}
struct ext2_inode inode;
int c;
int long_opt = 0;
- blk_t blk;
+ blk64_t blk;
char *buf = NULL;
struct ext2_dx_root_info *rootnode;
struct ext2_dx_entry *ent;
goto errout;
}
- errcode = ext2fs_bmap(current_fs, ino, &inode, buf, 0, 0, &blk);
+ errcode = ext2fs_bmap2(current_fs, ino, &inode, buf, 0, 0, 0, &blk);
if (errcode) {
com_err("do_htree_block", errcode,
"while mapping logical block 0\n");
int len;
};
-static int search_dir_block(ext2_filsys fs, blk_t *blocknr,
- e2_blkcnt_t blockcnt, blk_t ref_blk,
+static int search_dir_block(ext2_filsys fs, blk64_t *blocknr,
+ e2_blkcnt_t blockcnt, blk64_t ref_blk,
int ref_offset, void *priv_data);
void do_dirsearch(int argc, char *argv[])
pb.search_name = argv[2];
pb.len = strlen(pb.search_name);
- ext2fs_block_iterate2(current_fs, inode, BLOCK_FLAG_READ_ONLY, 0,
+ ext2fs_block_iterate3(current_fs, inode, BLOCK_FLAG_READ_ONLY, 0,
search_dir_block, &pb);
free(pb.buf);
}
-static int search_dir_block(ext2_filsys fs, blk_t *blocknr,
+static int search_dir_block(ext2_filsys fs, blk64_t *blocknr,
e2_blkcnt_t blockcnt,
- blk_t ref_blk EXT2FS_ATTR((unused)),
+ blk64_t ref_blk EXT2FS_ATTR((unused)),
int ref_offset EXT2FS_ATTR((unused)),
void *priv_data)
{
strncmp(p->search_name, dirent->name,
p->len) == 0) {
printf("Entry found at logical block %lld, "
- "phys %u, offset %u\n", (long long)blockcnt,
+ "phys %llu, offset %u\n", (long long)blockcnt,
*blocknr, offset);
printf("offset %u\n", offset);
return BLOCK_ABORT;