Commit d00c5127 authored by root's avatar root
Browse files

update

parent 73a3059b
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
No preview for this file type
......@@ -11,7 +11,7 @@
/* Prototypes */
static int __init init_extractmd(void);
static void __exit cleanup_extractmd(void);
static int extractmd_ioctl(struct inode *, struct file *, struct extractmd_meta_data *);
static int extractmd_ioctl(struct inode *, struct file *, struct extractmd_path *);
static int device_open(struct inode *, struct file *);
static int device_release(struct inode *, struct file *);
......@@ -58,13 +58,11 @@ static void __exit cleanup_extractmd(void)
printk(KERN_INFO "Cleaning up module.\n");
}
static int extractmd_ioctl(struct inode *inode, struct file *f, struct extractmd_meta_data *md_user)
static int extractmd_ioctl(struct inode *inode, struct file *f, struct extractmd_path *p)
{
unsigned int i = 0;
unsigned int k = 0;
struct file *fp = filp_open("/mnt", O_RDONLY, 0);
/*
* Super block part.
*/
......@@ -90,29 +88,7 @@ static int extractmd_ioctl(struct inode *inode, struct file *f, struct extractmd
//struct ext4_inode *raw_inode = ext4_raw_inode(&iloc);
struct extractmd_meta_data md;
md.gd_list = make_group_desc_list(sb);
struct extractmd_group_desc_list *p = md.gd_list;
// printk("%lu\n",(unsigned long)p->group_desc.bg_inode_table_lo);
// p = p->next;
// if(p == NULL)
// return 0;
// printk("%lu\n",(unsigned long)p->group_desc.bg_inode_table_lo);
// p = p->next;
// if(p == NULL)
// return 0;
// printk("%lu\n",(unsigned long)p->group_desc.bg_inode_table_lo);
//md.md_super_block = *(struct extractmd_super_block *)sbt;
//md.md_inode = *(struct extractmd_inode *)extractmd_get_ext4_inode(sb, md_user->md_ino);
printk("ddd: %s\n", p->path);
......@@ -120,14 +96,12 @@ static int extractmd_ioctl(struct inode *inode, struct file *f, struct extractmd
* EXCTRACTING SECTION!
*/
printk(KERN_INFO "Extractmd start!\n");
int ret = 0; // Result for extracing. If ret != 0, some data is not extract.
freeze_super(sb);
//ret += copy_group_desc_list(md_user->gd_list, md.gd_list, nr_group);
//ret += copy_to_user(md_user, &md, sizeof(struct extractmd_meta_data));
thaw_super(sb);
printk(KERN_INFO "%d left\n", ret);
return 0;
}
......@@ -314,61 +288,39 @@ static struct ext4_inode *extractmd_get_ext4_inode(struct super_block *sb, unsig
return ret;
}
// static struct ext4_group_desc *extractmd_get_group_desc_list(struct super_block *sb)
// {
// ext4_group_t i = 0;
// struct ext4_sb_info *sbi = EXT4_SB(sb);
// ext4_group_t group_count = sbi->s_groups_count;
// struct ext4_group_desc ret[group_count];
// for(i=0; i < group_count; i++)
// {
// ret[i] = *extractmd_get_group_desc(sb,i);
// }
// return ret;
// }
static struct extractmd_group_desc_list *make_group_desc_list(struct super_block *sb)
struct file* file_open(const char* path, int flags, int rights)
{
unsigned int i;
struct ext4_sb_info *sbi = EXT4_SB(sb);
ext4_group_t nr_group = sbi->s_groups_count;
struct extractmd_group_desc_list *head = NULL;
for(i = nr_group-1; ; i--)
{
struct extractmd_group_desc_list *p = (struct extractmd_group_desc_list *)kmalloc(sizeof(struct extractmd_group_desc_list), GFP_KERNEL);
p->group_desc = *(struct extractmd_group_desc *)extractmd_get_group_desc(sb, i);
p->group = i;
p->next = head;
head = p;
if (i == 0)
break;
}
struct file* filp = NULL;
mm_segment_t oldfs;
int err = 0;
oldfs = get_fs();
set_fs(get_ds());
filp = filp_open(path, flags, rights);
set_fs(oldfs);
if(IS_ERR(filp)) {
err = PTR_ERR(filp);
return NULL;
}
return filp;
}
return head;
void file_close(struct file* file) {
filp_close(file, NULL);
}
static int copy_group_desc_list(struct extractmd_group_desc_list *dst, struct extractmd_group_desc_list *src, ext4_group_t nr_group)
int file_write(struct file* file, unsigned long long offset, unsigned char* data, unsigned int size)
{
int ret = 0;
unsigned int i = 0;
struct extractmd_group_desc_list *current_dst = dst;
struct extractmd_group_desc_list *current_src = src;
for (i = 0; i < nr_group; i++)
{
ret += copy_to_user(current_dst, current_src, sizeof(struct extractmd_group_desc_list));
current_dst = current_dst->next;
current_src = current_src->next;
}
mm_segment_t oldfs;
int ret;
return ret;
oldfs = get_fs();
set_fs(get_ds());
ret = vfs_write(file, data, size, &offset);
set_fs(oldfs);
return ret;
}
......
......@@ -209,21 +209,7 @@ struct extractmd_inode {
__le32 i_version_hi; /* high 32 bits for 64-bit version */
};
struct extractmd_group_desc_list {
ext4_group_t group;
struct extractmd_group_desc group_desc;
struct extractmd_group_desc *next;
};
struct extractmd_meta_data {
struct extractmd_group_desc_list *gd_list;
struct extractmd_super_block_list *sb_list;
struct extractmd_inode_list *i_list;
//char *md_path;
//unsigned long md_ino;
//struct extractmd_super_block md_super_block;
//struct extractmd_inode md_inode;
struct extractmd_path
{
char *path;
};
\ No newline at end of file
No preview for this file type
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
No preview for this file type
File mode changed from 100644 to 100755
......@@ -8,17 +8,9 @@
int main()
{
int fd = open("/dev/extractmd", O_RDWR);
int i = 0;
struct extractmd_meta_data md;
//md.md_path = "/mnt";
//md.md_ino = 393217; // testE
ioctl(fd,&md);
// printf("%lu\n", (unsigned long)md.md_super_block.s_block_group_nr);
//printf("%lu\n", (unsigned long)md.md_group_desc_list[0].bg_inode_table_lo);
// printf("%lu\n", (unsigned long)md.md_inode.i_size_lo);
struct extractmd_path p;
p.path = "/home/user/md";
ioctl(fd,&p);
close(fd);
return 0;
......
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