iterating through dir
parent
55f3fa2c01
commit
0007290747
|
@ -36,6 +36,18 @@
|
|||
|
||||
const char *program_name = "realloc-inodes";
|
||||
|
||||
int change_inode_numbers(ext2_ino_t dir, int entry,
|
||||
struct ext2_dir_entry *dirent, int offset,
|
||||
int blocksize, char *buf, void *priv_data)
|
||||
{
|
||||
unsigned int *i_per_g = priv_data;
|
||||
char name[EXT2_NAME_LEN+1];
|
||||
strncpy(name, dirent->name, dirent->name_len & 0xff);
|
||||
name[dirent->name_len & 0xff] = 0;
|
||||
printf("%s: old %d, new %d\n", name, dirent->inode, 1 + (dirent->inode-1)/i_per_g[0]*i_per_g[1] + (dirent->inode-1)%i_per_g[0]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// try to read out all directory inodes?
|
||||
void test(ext2_filsys fs)
|
||||
{
|
||||
|
@ -43,6 +55,9 @@ void test(ext2_filsys fs)
|
|||
blk64_t blk;
|
||||
void *buf;
|
||||
struct ext2_inode *inode;
|
||||
unsigned int old_new_i_per_g[2];
|
||||
old_new_i_per_g[0] = fs->super->s_inodes_per_group;
|
||||
old_new_i_per_g[1] = fs->super->s_inodes_per_group/2;
|
||||
retval = ext2fs_get_mem(fs->blocksize * fs->inode_blocks_per_group, &buf);
|
||||
for (i = 0; i < fs->group_desc_count; i++)
|
||||
{
|
||||
|
@ -58,7 +73,9 @@ void test(ext2_filsys fs)
|
|||
inode = (struct ext2_inode*)(buf + EXT2_INODE_SIZE(fs->super) * j);
|
||||
if (inode->i_mode & S_IFDIR)
|
||||
{
|
||||
|
||||
printf("Directory %d\n", 1+j+i*fs->super->s_inodes_per_group);
|
||||
ext2fs_dir_iterate2(fs, 1+j+i*fs->super->s_inodes_per_group, 0, 0, change_inode_numbers, old_new_i_per_g);
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue