Commit c62b6015 authored by root's avatar root
Browse files

update

parent d00c5127
......@@ -631,6 +631,100 @@ deps_/home/user/Team_Safdar/extractmd/extractmd.o := \
$(wildcard include/config/amd/iommu.h) \
include/linux/pm_wakeup.h \
include/linux/mount.h \
arch/x86/include/asm/uaccess.h \
$(wildcard include/config/x86/intel/usercopy.h) \
$(wildcard include/config/debug/strict/user/copy/checks.h) \
arch/x86/include/asm/smap.h \
$(wildcard include/config/x86/smap.h) \
arch/x86/include/asm/uaccess_64.h \
include/linux/buffer_head.h \
include/linux/pagemap.h \
include/linux/mm.h \
$(wildcard include/config/ppc.h) \
$(wildcard include/config/parisc.h) \
$(wildcard include/config/metag.h) \
$(wildcard include/config/stack/growsup.h) \
$(wildcard include/config/ksm.h) \
$(wildcard include/config/shmem.h) \
$(wildcard include/config/debug/vm/rb.h) \
$(wildcard include/config/debug/pagealloc.h) \
$(wildcard include/config/hugetlbfs.h) \
include/linux/debug_locks.h \
$(wildcard include/config/debug/locking/api/selftests.h) \
include/linux/resource.h \
include/uapi/linux/resource.h \
arch/x86/include/uapi/asm/resource.h \
include/asm-generic/resource.h \
include/uapi/asm-generic/resource.h \
include/linux/page_ext.h \
$(wildcard include/config/page/owner.h) \
include/linux/stacktrace.h \
$(wildcard include/config/stacktrace.h) \
$(wildcard include/config/user/stacktrace/support.h) \
arch/x86/include/asm/pgtable.h \
$(wildcard include/config/have/arch/soft/dirty.h) \
arch/x86/include/asm/pgtable_64.h \
include/asm-generic/pgtable.h \
include/linux/page-flags.h \
$(wildcard include/config/pageflags/extended.h) \
$(wildcard include/config/arch/uses/pg/uncached.h) \
$(wildcard include/config/memory/failure.h) \
$(wildcard include/config/swap.h) \
include/linux/huge_mm.h \
include/linux/vmstat.h \
$(wildcard include/config/vm/event/counters.h) \
$(wildcard include/config/debug/tlbflush.h) \
$(wildcard include/config/debug/vm/vmacache.h) \
include/linux/vm_event_item.h \
$(wildcard include/config/memory/balloon.h) \
$(wildcard include/config/balloon/compaction.h) \
include/linux/highmem.h \
$(wildcard include/config/debug/highmem.h) \
include/linux/uaccess.h \
include/linux/hardirq.h \
include/linux/ftrace_irq.h \
$(wildcard include/config/ftrace/nmi/enter.h) \
include/linux/vtime.h \
$(wildcard include/config/virt/cpu/accounting/native.h) \
$(wildcard include/config/virt/cpu/accounting/gen.h) \
$(wildcard include/config/virt/cpu/accounting.h) \
$(wildcard include/config/irq/time/accounting.h) \
include/linux/context_tracking_state.h \
include/linux/static_key.h \
arch/x86/include/asm/hardirq.h \
$(wildcard include/config/x86/thermal/vector.h) \
$(wildcard include/config/x86/mce/threshold.h) \
$(wildcard include/config/hyperv.h) \
include/linux/irq.h \
$(wildcard include/config/irq/domain/hierarchy.h) \
$(wildcard include/config/generic/pending/irq.h) \
$(wildcard include/config/hardirqs/sw/resend.h) \
$(wildcard include/config/generic/irq/legacy/alloc/hwirq.h) \
$(wildcard include/config/generic/irq/legacy.h) \
include/linux/irqhandler.h \
include/linux/irqreturn.h \
include/linux/irqnr.h \
include/uapi/linux/irqnr.h \
include/linux/io.h \
arch/x86/include/asm/irq.h \
arch/x86/include/asm/irq_regs.h \
include/linux/irqdesc.h \
$(wildcard include/config/irq/preflow/fasteoi.h) \
$(wildcard include/config/sparse/irq.h) \
$(wildcard include/config/handle/domain/irq.h) \
arch/x86/include/asm/hw_irq.h \
$(wildcard include/config/irq/remap.h) \
include/linux/profile.h \
$(wildcard include/config/profiling.h) \
arch/x86/include/asm/sections.h \
$(wildcard include/config/debug/rodata.h) \
include/asm-generic/sections.h \
arch/x86/include/asm/cacheflush.h \
$(wildcard include/config/debug/rodata/test.h) \
include/asm-generic/cacheflush.h \
arch/x86/include/asm/kmap_types.h \
include/asm-generic/kmap_types.h \
include/linux/hugetlb_inline.h \
/home/user/Team_Safdar/extractmd/extractmd.h \
/home/user/Team_Safdar/extractmd/linux-4.0.9/fs/ext4/ext4.h \
include/linux/blkdev.h \
......@@ -645,7 +739,6 @@ deps_/home/user/Team_Safdar/extractmd/extractmd.o := \
$(wildcard include/config/detect/hung/task.h) \
$(wildcard include/config/core/dump/default/elf/headers.h) \
$(wildcard include/config/sched/autogroup.h) \
$(wildcard include/config/virt/cpu/accounting/native.h) \
$(wildcard include/config/bsd/process/acct.h) \
$(wildcard include/config/taskstats.h) \
$(wildcard include/config/audit.h) \
......@@ -662,7 +755,6 @@ deps_/home/user/Team_Safdar/extractmd/extractmd.o := \
$(wildcard include/config/rt/group/sched.h) \
$(wildcard include/config/cgroup/sched.h) \
$(wildcard include/config/compat/brk.h) \
$(wildcard include/config/virt/cpu/accounting/gen.h) \
$(wildcard include/config/sysvipc.h) \
$(wildcard include/config/auditsyscall.h) \
$(wildcard include/config/rt/mutexes.h) \
......@@ -674,9 +766,7 @@ deps_/home/user/Team_Safdar/extractmd/extractmd.o := \
$(wildcard include/config/function/graph/tracer.h) \
$(wildcard include/config/bcache.h) \
$(wildcard include/config/have/unstable/sched/clock.h) \
$(wildcard include/config/irq/time/accounting.h) \
$(wildcard include/config/no/hz/full.h) \
$(wildcard include/config/stack/growsup.h) \
include/uapi/linux/sched.h \
include/linux/sched/prio.h \
include/linux/plist.h \
......@@ -684,7 +774,6 @@ deps_/home/user/Team_Safdar/extractmd/extractmd.o := \
include/linux/cputime.h \
arch/x86/include/generated/asm/cputime.h \
include/asm-generic/cputime.h \
$(wildcard include/config/virt/cpu/accounting.h) \
include/asm-generic/cputime_jiffies.h \
include/linux/sem.h \
include/uapi/linux/sem.h \
......@@ -724,11 +813,6 @@ deps_/home/user/Team_Safdar/extractmd/extractmd.o := \
arch/x86/include/generated/asm/unistd_32_ia32.h \
include/linux/rtmutex.h \
$(wildcard include/config/debug/rt/mutexes.h) \
include/linux/resource.h \
include/uapi/linux/resource.h \
arch/x86/include/uapi/asm/resource.h \
include/asm-generic/resource.h \
include/uapi/asm-generic/resource.h \
include/linux/hrtimer.h \
$(wildcard include/config/high/res/timers.h) \
$(wildcard include/config/timerfd.h) \
......@@ -761,89 +845,6 @@ deps_/home/user/Team_Safdar/extractmd/extractmd.o := \
$(wildcard include/config/debug/kmemleak.h) \
include/linux/kasan.h \
$(wildcard include/config/kasan/shadow/offset.h) \
include/linux/pagemap.h \
include/linux/mm.h \
$(wildcard include/config/ppc.h) \
$(wildcard include/config/parisc.h) \
$(wildcard include/config/metag.h) \
$(wildcard include/config/ksm.h) \
$(wildcard include/config/shmem.h) \
$(wildcard include/config/debug/vm/rb.h) \
$(wildcard include/config/debug/pagealloc.h) \
$(wildcard include/config/hugetlbfs.h) \
include/linux/debug_locks.h \
$(wildcard include/config/debug/locking/api/selftests.h) \
include/linux/page_ext.h \
$(wildcard include/config/page/owner.h) \
include/linux/stacktrace.h \
$(wildcard include/config/stacktrace.h) \
$(wildcard include/config/user/stacktrace/support.h) \
arch/x86/include/asm/pgtable.h \
$(wildcard include/config/have/arch/soft/dirty.h) \
arch/x86/include/asm/pgtable_64.h \
include/asm-generic/pgtable.h \
include/linux/page-flags.h \
$(wildcard include/config/pageflags/extended.h) \
$(wildcard include/config/arch/uses/pg/uncached.h) \
$(wildcard include/config/memory/failure.h) \
$(wildcard include/config/swap.h) \
include/linux/huge_mm.h \
include/linux/vmstat.h \
$(wildcard include/config/vm/event/counters.h) \
$(wildcard include/config/debug/tlbflush.h) \
$(wildcard include/config/debug/vm/vmacache.h) \
include/linux/vm_event_item.h \
$(wildcard include/config/memory/balloon.h) \
$(wildcard include/config/balloon/compaction.h) \
include/linux/highmem.h \
$(wildcard include/config/debug/highmem.h) \
include/linux/uaccess.h \
arch/x86/include/asm/uaccess.h \
$(wildcard include/config/x86/intel/usercopy.h) \
$(wildcard include/config/debug/strict/user/copy/checks.h) \
arch/x86/include/asm/smap.h \
$(wildcard include/config/x86/smap.h) \
arch/x86/include/asm/uaccess_64.h \
include/linux/hardirq.h \
include/linux/ftrace_irq.h \
$(wildcard include/config/ftrace/nmi/enter.h) \
include/linux/vtime.h \
include/linux/context_tracking_state.h \
include/linux/static_key.h \
arch/x86/include/asm/hardirq.h \
$(wildcard include/config/x86/thermal/vector.h) \
$(wildcard include/config/x86/mce/threshold.h) \
$(wildcard include/config/hyperv.h) \
include/linux/irq.h \
$(wildcard include/config/irq/domain/hierarchy.h) \
$(wildcard include/config/generic/pending/irq.h) \
$(wildcard include/config/hardirqs/sw/resend.h) \
$(wildcard include/config/generic/irq/legacy/alloc/hwirq.h) \
$(wildcard include/config/generic/irq/legacy.h) \
include/linux/irqhandler.h \
include/linux/irqreturn.h \
include/linux/irqnr.h \
include/uapi/linux/irqnr.h \
include/linux/io.h \
arch/x86/include/asm/irq.h \
arch/x86/include/asm/irq_regs.h \
include/linux/irqdesc.h \
$(wildcard include/config/irq/preflow/fasteoi.h) \
$(wildcard include/config/sparse/irq.h) \
$(wildcard include/config/handle/domain/irq.h) \
arch/x86/include/asm/hw_irq.h \
$(wildcard include/config/irq/remap.h) \
include/linux/profile.h \
$(wildcard include/config/profiling.h) \
arch/x86/include/asm/sections.h \
$(wildcard include/config/debug/rodata.h) \
include/asm-generic/sections.h \
arch/x86/include/asm/cacheflush.h \
$(wildcard include/config/debug/rodata/test.h) \
include/asm-generic/cacheflush.h \
arch/x86/include/asm/kmap_types.h \
include/asm-generic/kmap_types.h \
include/linux/hugetlb_inline.h \
include/linux/backing-dev.h \
$(wildcard include/config/debug/fs.h) \
include/linux/flex_proportions.h \
......@@ -865,7 +866,6 @@ deps_/home/user/Team_Safdar/extractmd/extractmd.o := \
$(wildcard include/config/arch/has/fast/multiplier.h) \
include/linux/jbd2.h \
$(wildcard include/config/jbd2/debug.h) \
include/linux/buffer_head.h \
include/linux/journal-head.h \
include/crypto/hash.h \
include/linux/crypto.h \
......
obj-m += extractmd.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules -Wall -Wformat=0
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
No preview for this file type
......@@ -4,6 +4,13 @@
#include <linux/fs.h>
#include <linux/device.h>
#include <linux/mount.h>
#include <linux/string.h>
#include <asm/segment.h>
#include <asm/uaccess.h>
#include <linux/buffer_head.h>
#include "extractmd.h"
#include "linux-4.0.9/fs/ext4/ext4.h"
......@@ -22,8 +29,8 @@ ext4_fsblk_t extractmd_inode_table(struct super_block *, struct ext4_group_desc
ext4_fsblk_t extractmd_inode_bitmap(struct super_block *, struct ext4_group_desc *);
__u32 extractmd_itable_unused_count(struct super_block *, struct ext4_group_desc *);
static struct ext4_inode *extractmd_get_ext4_inode(struct super_block *, unsigned long);
static struct extractmd_group_desc_list *make_group_desc_list(struct super_block *);
static int copy_group_desc_list(struct extractmd_group_desc_list *, struct extractmd_group_desc_list *, ext4_group_t);
long extractmd_write_file(struct file* file, char* data, unsigned long);
#define DEVICE_NAME "extractmd" /* Dev name as it appears in /proc/devices */
#define MAJOR_NUM 199 /* Device MAJOR number */
......@@ -62,22 +69,34 @@ static int extractmd_ioctl(struct inode *inode, struct file *f, struct extractmd
{
struct file *fp = filp_open("/mnt", O_RDONLY, 0);
struct file *super_block_fp = filp_open(p->path_super_block, O_WRONLY | O_APPEND | O_CREAT, 0777);
struct file *group_descriptor_fp = filp_open(p->path_group_descriptor, O_WRONLY | O_APPEND | O_CREAT, 0777);
struct file *reserved_gdt_fp = filp_open(p->path_reserved_gdt, O_WRONLY | O_APPEND | O_CREAT, 0777);
struct file *inode_datablock_bitmap_fp = filp_open(p->path_inode_datablock_bitmap, O_WRONLY | O_APPEND | O_CREAT, 0777);
struct file *inode_table_fp = filp_open(p->path_inode_table, O_WRONLY | O_APPEND | O_CREAT, 0777);
/*
* Super block part.
*/
struct super_block *sb = fp->f_inode->i_sb; // get super_block of vfs
//struct super_block *sb = fp->f_path.mnt->mnt_sb;
struct ext4_sb_info *sbi = EXT4_SB(sb); // get ext4_sb_info
struct ext4_super_block *sbt = sbi->s_es; // get ext4_super_block
/*
* Goup desc part.
*/
//struct ext4_group_desc *gdp = extractmd_get_group_desc(sb,0);
ext4_group_t nr_group = sbi->s_groups_count;
unsigned int i;
ext4_group_t nr_group = sbi->s_groups_count;
struct ext4_group_desc *gdp[nr_group];
//__le32 bitmaps[nr_group*2];
for (i = 0; i < nr_group; i++)
{
gdp[i] = extractmd_get_group_desc(sb,i);
//bitmaps[2*i] = gdp[i]->bg_block_bitmap_lo;
//bitmaps[2*i + 1] = gdp[i]->bg_inode_bitmap_lo;
}
/*
......@@ -88,20 +107,39 @@ static int extractmd_ioctl(struct inode *inode, struct file *f, struct extractmd
//struct ext4_inode *raw_inode = ext4_raw_inode(&iloc);
printk("ddd: %s\n", p->path);
/*
* EXCTRACTING SECTION!
*/
printk(KERN_INFO "Extractmd start!\n");
freeze_super(sb);
// Super blocks //
struct ext4_super_block *super_block_buffer = sbt;
unsigned long super_block_size = sizeof(*sbt);
// 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);
thaw_super(sb);
printk(KERN_INFO "Extractmd finish!\n");
extractmd_write_file(super_block_fp, super_block_buffer, super_block_size);
extractmd_write_file(group_descriptor_fp, group_descriptor_buffer, group_descriptor_size);
printk(KERN_INFO "Write file finish!\n");
filp_close(fp, NULL);
filp_close(super_block_fp, NULL);
filp_close(group_descriptor_fp, NULL);
filp_close(reserved_gdt_fp, NULL);
filp_close(inode_datablock_bitmap_fp, NULL);
filp_close(inode_table_fp, NULL);
return 0;
}
......@@ -288,42 +326,19 @@ static struct ext4_inode *extractmd_get_ext4_inode(struct super_block *sb, unsig
return ret;
}
struct file* file_open(const char* path, int flags, int rights)
{
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;
}
void file_close(struct file* file) {
filp_close(file, NULL);
}
int file_write(struct file* file, unsigned long long offset, unsigned char* data, unsigned int size)
long extractmd_write_file(struct file* file, char* data, unsigned long size)
{
mm_segment_t oldfs;
int ret;
long ret;
mm_segment_t fs;
fs = get_fs();
set_fs(KERNEL_DS);
ret = vfs_write(file, data, size, &file->f_pos);
set_fs(fs);
oldfs = get_fs();
set_fs(get_ds());
ret = vfs_write(file, data, size, &offset);
set_fs(oldfs);
return ret;
}
module_init(init_extractmd);
module_exit(cleanup_extractmd);
......
......@@ -211,5 +211,9 @@ struct extractmd_inode {
struct extractmd_path
{
char *path;
char *path_super_block;
char *path_group_descriptor;
char *path_reserved_gdt;
char *path_inode_datablock_bitmap;
char *path_inode_table;
};
\ No newline at end of file
No preview for this file type
No preview for this file type
File added
#include <stdio.h>
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <linux/fs.h>
#include "extractmd.h"
int main()
{
FILE *fp;
char buffer[5120];
struct extractmd_group_desc *gd;
unsigned int i;
fp = fopen("/home/user/md/group_descriptor", "r");
fgets(buffer, 5120, (FILE*)fp);
gd = (struct extractmd_group_desc *)buffer;
// printf("block bitmap : %hu\n",gd[4].bg_block_bitmap_lo);
// printf("block bitmap : %hu\n",gd[5].bg_block_bitmap_lo);
for (i =0; i<80; i++)
{
printf("block bitmap : %lu\n",gd[i].bg_block_bitmap_lo);
//printf("inode bitmap : %lu\n",gd[i].bg_inode_bitmap_lo);
}
fclose(fp);
}
\ No newline at end of file
......@@ -8,10 +8,17 @@
int main()
{
int fd = open("/dev/extractmd", O_RDWR);
struct extractmd_path p;
p.path = "/home/user/md";
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_inode_datablock_bitmap = "/home/user/md/inode_datablock_bitmap";
p.path_inode_table = "/home/user/md/inode_table";
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