sys_open调用.请!

sys_open调用.请!

sys_open调用……请高手指点! 在线等
sys_open不能被调用,代码如下:
我编译的时候显示:
***   Warning:   "sys_open "   [/home/lehuan/module/helloworld.ko]   undefined!
我觉得应该是在   syscalls.h里定义的,而且也找到了…

可是不能用…请高手指点

#include   <linux/module.h>
#include   <linux/types.h>
#include   <linux/syscalls.h>
#include   <linux/init.h>
#include   <linux/fcntl.h>
MODULE_LICENSE( "Dual   BSD/GPL ");
int   init_module(void)
{
                long   fs   =   0;

                printk( " <6>   init   module   n   ");

                fs   =   sys_open( "/home/lehuan/a ",O_CREAT|O_WRONLY   ,S_IRUSR|S_IWUSR);
                if(fs   <   0)   {
                                printk( " <6>   open   failed   n ");
                                return   1;
                }
                return   0;

}

void   cleanup_module()
{
                printk( " <6>   goodbye   n ");
}


自己写个sys_open试试

asmlinkage long sys_open(const char * filename, int flags, int mode)
{
char * tmp;
int fd, error;

#if BITS_PER_LONG != 32
flags |= O_LARGEFILE;
#endif
tmp = getname(filename);
fd = PTR_ERR(tmp);
if (!IS_ERR(tmp)) {
fd = get_unused_fd();
if (fd > = 0) {
struct file *f = filp_open(tmp, flags, mode);
error = PTR_ERR(f);
if (IS_ERR(f))
goto out_error;
fd_install(fd, f);
}
out:
putname(tmp);
}
return fd;

out_error:
put_unused_fd(fd);
fd = error;
goto out;
}

sys_open调用.请!

相关文章:

你感兴趣的文章:

标签云: