- 论坛徽章:
- 0
|
原帖由 youmin0 于 2008-12-19 16:10 发表 ![]()
又来发帖,都不好意思了,但我GOOGLE了半天,也按照里面的做法做了
但insmod的时候还是出现了这个问题unresolved symbol sys_mount
我的环境是2.4.20,自己写的一个模块,其中调用了sys_mount这个函数,也# ...
我以前写过一个在内核中调用sys_open的方法,不过是2.6的,不晓得2.4是否可行。你看看:
- #include<linux/kernel.h>
- #include<linux/module.h>
- #include<linux/init.h>
- #include<linux/fs.h>
- #include<linux/string.h>
- #include<linux/syscalls.h>
- #include<asm/unistd.h>
- #include<asm/uaccess.h>
- #include<linux/unistd.h>
- int fd;
- int errno;
- #define __NR_sys_open1 __NR_open
- static inline _syscall3(long, sys_open1, char __user*, s, int, flags, int, mode);
- #define __NR_sys_write1 __NR_write
- static inline _syscall3(long, sys_write1, unsigned int, fd, const char __user*, buf, size_t, count);
- #define __NR_sys_close1 __NR_close
- static inline _syscall1(long, sys_close1, unsigned int, fd);
- static int __init init(void)
- {
- char buf[10] = "hello";
- mm_segment_t old_fs = get_fs();
- set_fs(get_ds());
- fd = sys_open1("/root/myfile", O_RDWR|O_CREAT, 0644);
- if (fd < 0)
- {
- printk("error\n");
- return -1;
- }
- printk("open ok \n");
- sys_write1(fd, buf, sizeof(buf));
- set_fs(old_fs);
- return 0;
- }
- static void __exit exit(void)
- {
- if (fd != 0)
- sys_close1(fd);
- }
- module_init(init);
- module_exit(exit);
- MODULE_LICENSE("GPL");
复制代码
不过我觉得你可以再回到你问题的起点,看是否非得使用sys_mount这个函数。 |
|