0
我在Android中有一个自编码的内核模块,我用O_RDONLY|O_NONBLOCK
打开。C&Android内核模块:在这里发生了什么f_flags?
O_NONBLOCK
在用户程序和内核模块中均为2048
。
我检查与
print..("O_NONBLOCK is %d", O_NONBLOCK)
在用户&内核空间
。
但现在,当我尝试检查,如果O_NONBLOCK
设置,我有一个非常奇怪的问题:
static int my_open(struct inode *inode, struct file *filp) {
if (filp->f_flags & O_NONBLOCK) {
printk("O_NONBLOCK");
} else {
printk("NOT O_NONBLOCK");
printk("O_NONBLOCK in my_open is: %d", O_NONBLOCK); // -> prints 2048
printk("filp->f_flags in my_open is: %d", filp->f_flags); // -> prints 1, not 2048 or larger
}
..
}
我尝试别的东西:
cat my_device
但同样,filp->f_flags
是1
。
我假设0
为O_RDONLY
而不是1
这意味着O_WRONLY
。
任何想法或解释?
编辑:
我也不指望cat
beeing O_NONBLOCK
,但O_WRONLY
是完全错误的。
我开这样说:
pcm->dfd=open(fname, O_RDONLY|O_NONBLOCK);
而且也没有fcntl
后(这不应该影响my_open
在所有 但是,当然,我也试图“重新设置” O_NONBLOCK
与fcntl
没有。运气
嘿,感谢您的回答。我将在我的问题上添加更多信息。 – 2012-07-12 19:12:07