Linux Kernel Modda Dosya Okumak

#include <linux/module.h>  
#include <linux/kernel.h>  
#include <linux/fs.h>      
#include <asm/uaccess.h>   
#include <linux/syscalls.h>

SYSCALL_DEFINE2(deneme_syscall, int, a, int, b) 
{
struct file *f;

    char buf[2048];

    mm_segment_t fs;
    int i;

    for(i=0;i<128;i++)
        buf[i] = 0;
 
    f = filp_open("/proc/cpuinfo", O_RDONLY, 0);

    if(f == NULL)
        printk(KERN_ALERT "filp_open error!!.\n");
    else{
        fs = get_fs();
        set_fs(get_ds());
        f->f_op->read(f, buf, 128, &f->f_pos);
        set_fs(fs);

        printk(KERN_INFO "buf:%s\n",buf);
    }

    filp_close(f,NULL);

    return 0;
} 

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *