LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to know whether a dev file has been opened or not? (http://www.linuxquestions.org/questions/linux-software-2/how-to-know-whether-a-dev-file-has-been-opened-or-not-534698/)

asahlot 03-05-2007 06:31 AM

How to know whether a dev file has been opened or not?
 
Hi All

Inside my driver init code I want to know whether a dev file like /dev/video has been opened by some application or not?
How can I do that?
Could any body please help? I need to know urgently.
Thanks in advance.

ASAHLOT

akudewan 03-05-2007 06:59 AM

I think the "lsof" bash command can do this.

For instance, when I run: lsof /dev/snd/* I get this output:
Code:

akudewan@ranjan404:~ $ lsof /dev/snd/*
COMMAND  PID    USER  FD  TYPE DEVICE SIZE NODE NAME
kicker  5660 akudewan  13u  CHR  116,8      7874 /dev/snd/controlC0
gkrellm 5701 akudewan    9u  CHR  116,8      7874 /dev/snd/controlC0

Edit: Note that kicker and gkrellm have volume control applets

asahlot 03-06-2007 12:02 AM

But I cannot run any command inside module init code.


All times are GMT -5. The time now is 01:28 AM.