当前位置: 技术问答>linux和unix
内核中怎样读写文件
来源: 互联网 发布时间:2016-02-25
本文导语: unsigned int fw_hookfn_input(unsigned int hooknum, struct sk_buff **skb, const struct net_device *in, const struct net_device *out, int (*okfn)(struct sk_buff *)) { struct sk_buff *pskb =...
unsigned int fw_hookfn_input(unsigned int hooknum,
struct sk_buff **skb,
const struct net_device *in,
const struct net_device *out,
int (*okfn)(struct sk_buff *))
{
struct sk_buff *pskb = *skb;
char log[256];
memset(log,0,sizeof(log));
if(pskb->head == NULL)
{
printk("没有数据的包!n");
return NF_ACCEPT;
}
char counter[20];
counter_input_process++;
sprintf(counter,"%ld",counter_input_process);
strcat(log,"Have data packet: Accept!");
strcat(log,counter);
strcat(log,"n");
oldfs = get_fs();
set_fs(KERNEL_DS);
ret = ifile->f_op->write(ifile, buf, sizeof(buf), &ifile->f_pos);
set_fs(oldfs);
if(ret
struct sk_buff **skb,
const struct net_device *in,
const struct net_device *out,
int (*okfn)(struct sk_buff *))
{
struct sk_buff *pskb = *skb;
char log[256];
memset(log,0,sizeof(log));
if(pskb->head == NULL)
{
printk("没有数据的包!n");
return NF_ACCEPT;
}
char counter[20];
counter_input_process++;
sprintf(counter,"%ld",counter_input_process);
strcat(log,"Have data packet: Accept!");
strcat(log,counter);
strcat(log,"n");
oldfs = get_fs();
set_fs(KERNEL_DS);
ret = ifile->f_op->write(ifile, buf, sizeof(buf), &ifile->f_pos);
set_fs(oldfs);
if(ret