Re: LDD3: opening a character device and counting the opens

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/24/07, Robert P. J. Day <rpjday@xxxxxxxxxxxxxx> wrote:

  question about the character device example used in the LDD3 book,
p. 59, which talks about the "release" method.  in suggesting that the
release method shut down the device on last close, this suggests that
the code is counting the number of open instances of the device.

  what's the best way to do that?  the open() routine would obviously
increment a counter, while release() would decrement it.  but where
would you keep that counter?  and you'd obviously need one per inode
(not one per filp).

  what's the cleanest way to do that?  thanks.
I guess kref is something you should use here. Isn't it? or am i
missing something here?

thanks
--psr

rday

--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ




--
play the game

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux