Commit 8686b96f authored by root's avatar root
Browse files

reserved GDT extraction

parent 1d0f3af5
......@@ -72,12 +72,12 @@ static int extractmd_ioctl(struct inode *inode, struct file *f, struct extractmd
char path_block_bitmap[255] = {0};
char path_inode_bitmap[255] = {0};
char path_inode_table[255] = {0};
char path_reserved_gdt[255] = {0};
int i = 0;
unsigned long nr_gd; // number of groupd descriptors
unsigned long nr_inode_table_block; // number of inode table blocks
//unsigned long nr_reserved_gdt; // number of reserved gdts in a group;
struct buffer_head *bh_sb;
struct super_block *sb = fp->f_inode->i_sb; // get super_block of vfs
//struct super_block *sb = fp->f_path.mnt->mnt_sb;
......@@ -88,17 +88,13 @@ static int extractmd_ioctl(struct inode *inode, struct file *f, struct extractmd
nr_gd = sbi->s_gdb_count * sbi->s_desc_per_block;
nr_inode_table_block = sbi->s_itb_per_group;
/*****************************************************/
//nr_reserved_gdt = sbi->s_es->s_reserved_gdt_blocks;
/*****************************************************/
/* set path and filenames */
sprintf(path_super_block, "%s/super_block", p->path);
sprintf(path_group_descriptor, "%s/group_descriptor", p->path);
sprintf(path_block_bitmap, "%s/block_bitmap", p->path);
sprintf(path_inode_bitmap, "%s/inode_bitmap", p->path);
sprintf(path_inode_table, "%s/inode_table", p->path);
sprintf(path_reserved_gdt, "%s/reserved_GDT", p->path);
/* sync */
freeze_super(sb);
......@@ -181,6 +177,21 @@ static int extractmd_ioctl(struct inode *inode, struct file *f, struct extractmd
extractmd_write_file_per_group(path_inode_table , bh_inode_table->b_data, EXT4_BLOCK_SIZE(sb) * nr_inode_table_block, i);
}
/* reserved GDT, if not flexible block group, extract reserved GDT */
if ((sbi->s_es->s_feature_incompat & 0x200) != 0x200)
{
unsigned long nr_reserved_gdt = sbi->s_es->s_reserved_gdt_blocks;
for(i = 0; i < nr_group; i++)
{
struct buffer_head *bh_reserved_gdt = __bread(bdev, extractmd_group_first_block_no(sb, i) + 2, EXT4_BLOCK_SIZE(sb) * nr_reserved_gdt);
extractmd_write_file_per_group(path_reserved_gdt, bh_reserved_gdt->b_data, EXT4_BLOCK_SIZE(sb) * nr_reserved_gdt, i);
}
}
/* journal */
/*
* external journal : On the journal device there will be an ext4 super block in the usual place, with a matching UUID.
* this module extracts uuid of the journal devices and write them on a file name "external_journal".
......@@ -198,6 +209,9 @@ static int extractmd_ioctl(struct inode *inode, struct file *f, struct extractmd
extractmd_write_file(path_external_journal, (char *)j_buff, sizeof(unsigned long) * 16);
}
filp_close(fp, NULL);
filp_close(fp_dev, NULL);
......@@ -301,6 +315,25 @@ long extractmd_write_file_per_group(char * path, char* data, unsigned long size,
return ret;
}
long extractmd_append_file(char *path, char* data, unsigned long size)
{
long ret;
struct file *fp;
mm_segment_t fs;
fs = get_fs();
set_fs(KERNEL_DS);
fp = filp_open(path, O_APPEND | O_CREAT, 0777);
ret = vfs_write(fp, data, size, &fp->f_pos);
set_fs(fs);
filp_close(fp, NULL);
return ret;
}
module_init(init_extractmd);
module_exit(cleanup_extractmd);
......
......@@ -235,10 +235,6 @@ struct extractmd_redundant_super_block {
__le32 s_checksum; /* crc32c(superblock) */
};
/*
* Structure of a blocks group descriptor
*/
......@@ -328,6 +324,18 @@ struct extractmd_inode {
__le32 i_version_hi; /* high 32 bits for 64-bit version */
};
struct extractmd_path
{
char *path_device;
......
No preview for this file type
No preview for this file type
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment