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