Open file descriptor reference count implementation in driver

Sibananda Sahu sibananda.sahu at avagotech.com
Wed Nov 5 06:39:45 UTC 2014


Hi JD,



Thanks for the reply.



I have grepped the whole source code in head and did not find any driver
code is using the si_refcount or si_usecount.

Precisely I am working on <mrsas(4)> driver.



I have tested by using both the variables and observed that the si_refcount
shows how many times a file descriptor has been opened.

Looks like this variable is incremented when an FD is opened and
decremented when the same FD is closed.



But the si_usecount shows the number of open FD currently opened.



Let’s say some app has come and opened a file but did not closed and exited.

At this point the si_refcount shows 1 but the si_usecount shows 0.



These are my observations yet.

If you can point me some drivers using this reference count logic without
using the si_refcount and si_usecount variables, that would be a great help.





Thanks,

Sibananda Sahu



*From:* JD [mailto:jd1008 at gmail.com]
*Sent:* Wednesday, November 05, 2014 6:16 AM
*To:* Sibananda Sahu
*Subject:* Re: Open file descriptor reference count implementation in driver



Why dont you look at how other device drivers
are using the refcount and user count?

There plenty of examples in the source code.



On Mon, Nov 3, 2014 at 11:58 PM, Sibananda Sahu <
sibananda.sahu at avagotech.com> wrote:

Hi,



Can anybody suggest how can I implement the Open file descriptor reference
count in a freebsd driver???



I have looked up at certain places in the cdev structure(sys/conf.h) and
found two integer values:

Int          si_refcount;

Int          si_usecount;



I think these are the stuffs  useful for me.

Can somebody explain what are the significance of the above mentioned
integer values inside the cdev structure?



Any help would be greatly appreciated.





Thanks,

Sibananda Sahu
_______________________________________________
freebsd-questions at freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"


More information about the freebsd-questions mailing list