LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 3803|回复: 5

filp_open在哪个函数库中啊

[复制链接]
发表于 2005-7-13 10:13:11 | 显示全部楼层 |阅读模式
我想在常规程序(非内核或模块加载)中调用filp_open,请问在gcc编译时该加载哪个库啊
发表于 2005-7-16 16:17:06 | 显示全部楼层
埃,这么多人看了都不告诉你, 去查交叉索引吧  
http://lxr.linux.no/ident
回复 支持 反对

使用道具 举报

发表于 2005-7-17 02:27:22 | 显示全部楼层
问了这么多遍阿,从forum问到sir
没可能的,除非改内核
可以参考Linux Kernel Development中system call这一章

不过想问一句为什么一定要用filp_open
回复 支持 反对

使用道具 举报

发表于 2005-7-23 13:09:13 | 显示全部楼层
sys_open和进程紧密关联,往往不在内核模块中用。

给个filp_open的例子吧:
[code]
#include <linux/version.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/fcntl.h>

struct file* filp;

static int hello_init(void){
  filp = filp_open("/proc/modules",O_RDONLY,0);
  printk("filp->f_uid=%d\n",filp->f_uid);
  return 0;
}

static void hello_exit(void){
  filp_close(filp,NULL);
}

module_init(hello_init);
module_exit(hello_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Hellwolf Misty<hellwolf@seu.edu.cn>");
MODULE_DESCRIPTION("iptables HW_S5C_HELPER target module");
[/code]
回复 支持 反对

使用道具 举报

发表于 2008-5-21 11:11:13 | 显示全部楼层
Post by hellwolf;1217393
sys_open和进程紧密关联,往往不在内核模块中用。

给个filp_open的例子吧:
[code]
#include <linux/version.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/fcntl.h>

struct file* filp;

static int hello_init(void){
  filp = filp_open("/proc/modules",O_RDONLY,0);
  printk("filp->f_uid=%d\n",filp->f_uid);
  return 0;
}

static void hello_exit(void){
  filp_close(filp,NULL);
}

module_init(hello_init);
module_exit(hello_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Hellwolf Misty<hellwolf@seu.edu.cn>");
MODULE_DESCRIPTION("iptables HW_S5C_HELPER target module");
[/code]


请问读去文件的函数和写文件的函数是那个。相关的文件操作函数怎么查找呢,写了个模块很没头绪啊。
回复 支持 反对

使用道具 举报

发表于 2008-9-28 15:15:30 | 显示全部楼层
filp_open是内核的函数,不能在应用程序中调用。
应用程序中的调用的open是通过系统调用的方式调用的sys_open
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表