Commit 1ec4eee1 authored by root's avatar root
Browse files

path, READMD.md updated

parent 04f7ec60
11/25/2016 v3.0
Specifiy path : 1.mount point(e.q., "/mnt"), 2.target device(e.q., "/dev/sdb"), 3.where to store extracted meta data(e.q., "/home/user/md").
Example code : test.c
11/15/2016 v2.0
You can now extract inode of specific file.
To extract inode, you should specify path of file(e.q., "/mnt/testF")
......
No preview for this file type
......@@ -71,12 +71,18 @@ static int extractmd_ioctl(struct inode *inode, struct file *f, struct extractmd
struct file *fp = filp_open(p->path_mount_point, O_RDONLY, 0);
struct file *fp_dev = filp_open(p->path_device, O_RDONLY, 0);
//struct file *super_block_fp = filp_open(p->path_super_block, O_WRONLY | O_CREAT, 0777);
//struct file *group_descriptor_fp = filp_open(p->path_group_descriptor, O_WRONLY | O_CREAT, 0777);
//struct file *reserved_gdt_fp = filp_open(p->path_reserved_gdt, O_WRONLY | O_CREAT, 0777);
//struct file *block_bitmap_fp = filp_open(p->path_block_bitmap, O_WRONLY | O_CREAT, 0777);
//struct file *inode_bitmap_fp = filp_open(p->path_inode_bitmap, O_WRONLY | O_CREAT, 0777);
//struct file *inode_table_fp = filp_open(p->path_inode_table, O_WRONLY | O_CREAT, 0777);
// set path and filenames
char path_super_block[255] = {0};
char path_group_descriptor[255] = {0};
char path_block_bitmap[255] = {0};
char path_inode_bitmap[255] = {0};
char path_inode_table[255] = {0};
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);
int i = 0;
unsigned long nr_gd; // number of groupd descriptors
......@@ -103,7 +109,7 @@ static int extractmd_ioctl(struct inode *inode, struct file *f, struct extractmd
/* super block in Group 0 */
bh_sb = __bread(bdev, 0, EXT4_BLOCK_SIZE(sb));
extractmd_write_file(p->path_super_block, bh_sb->b_data, EXT4_BLOCK_SIZE(sb));
extractmd_write_file(path_super_block, bh_sb->b_data, EXT4_BLOCK_SIZE(sb));
//extractmd_write_file_per_group(p->path_super_block, bh_sb->b_data, EXT4_BLOCK_SIZE(sb), 0);
......@@ -117,48 +123,13 @@ static int extractmd_ioctl(struct inode *inode, struct file *f, struct extractmd
struct buffer_head *bh_inode_bitmap = __bread(bdev, extractmd_inode_bitmap(sb, group), EXT4_BLOCK_SIZE(sb));
struct buffer_head *bh_inode_table = __bread(bdev, extractmd_inode_table(sb, group), EXT4_BLOCK_SIZE(sb) * nr_inode_table_block);
extractmd_write_file_per_group(p->path_group_descriptor, bh_group_descriptor->b_data, EXT4_DESC_SIZE(sb) * nr_gd, i);
extractmd_write_file_per_group(p->path_block_bitmap, bh_block_bitmap->b_data, EXT4_BLOCK_SIZE(sb), i);
extractmd_write_file_per_group(p->path_inode_bitmap, bh_inode_bitmap->b_data, EXT4_BLOCK_SIZE(sb), i);
extractmd_write_file_per_group(p->path_inode_table , bh_inode_table->b_data, EXT4_BLOCK_SIZE(sb) * nr_inode_table_block, i);
extractmd_write_file_per_group(path_group_descriptor, bh_group_descriptor->b_data, EXT4_DESC_SIZE(sb) * nr_gd, i);
extractmd_write_file_per_group(path_block_bitmap, bh_block_bitmap->b_data, EXT4_BLOCK_SIZE(sb), i);
extractmd_write_file_per_group(path_inode_bitmap, bh_inode_bitmap->b_data, EXT4_BLOCK_SIZE(sb), i);
extractmd_write_file_per_group(path_inode_table , bh_inode_table->b_data, EXT4_BLOCK_SIZE(sb) * nr_inode_table_block, i);
}
//extractmd_write_file(inode_table_fp, inode_table_buffer, nr_group * EXT4_BLOCK_SIZE(sb) * nr_inode_table_block);
/* inode table */
// Super blocks //
//ext4_group_t nr_super_block = 0;
//struct ext4_super_block *super_block_buffer = (struct ext4_super_block *)bh->b_data;
//struct ext4_super_block *super_block_buffer;
//struct super_block *tmp = sb;
//unsigned long super_block_size = sizeof(struct ext4_super_block);
// Group descriptors //
//struct ext4_group_desc group_descriptor_buffer[nr_group];
// unsigned int k;
// for (k = 0; k < nr_group; k++)
// {
// group_descriptor_buffer[k] = *gdp[k];
// }
//unsigned long group_descriptor_size = sizeof(group_descriptor_buffer);
//extractmd_write_file(group_descriptor_fp, group_descriptor_buffer, group_descriptor_size);
filp_close(fp, NULL);
filp_close(fp_dev, NULL);
......
......@@ -213,10 +213,5 @@ struct extractmd_path
{
char *path_device;
char *path_mount_point;
char *path_super_block;
char *path_group_descriptor;
char *path_reserved_gdt;
char *path_inode_bitmap;
char *path_block_bitmap;
char *path_inode_table;
char *path;
};
\ No newline at end of file
No preview for this file type
No preview for this file type
......@@ -12,13 +12,7 @@ int main()
struct extractmd_path p;
p.path_device = "/dev/sdb";
p.path_mount_point = "/mnt";
p.path_super_block = "/home/user/md/super_block";
p.path_group_descriptor = "/home/user/md/group_descriptor";
p.path_reserved_gdt = "/home/user/md/reserved_gdt";
p.path_block_bitmap = "/home/user/md/block_bitmap";
p.path_inode_bitmap = "/home/user/md/inode_bitmap";
p.path_inode_table = "/home/user/md/inode_table";
p.path = "/home/user/md";
ioctl(fd,&p);
......
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