EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Understanding Open/Close contexts and CallAllOpenCloseCallbacks

Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.
#19504
Posted: 03/16/2012 11:25:08
by Ivan P (Priority Standard support level)
Joined: 04/11/2011
Posts: 66

Hi,

I have a question about contexts returned by OnOpenFile() callback when CallAllOpenCloseCallbacks is set to TRUE.

The "File and Search Contexts" in help file says
For file operations contexts live from file open to file close calls. Contexts are stored with other information, related to opened file. Context is the same for all file open/create operations that overlap. For example, if process A opens the file, then process B opens the file, one context will be used until both A and B close the file.

Is it true for the situation when CallAllOpenCloseCallbacks is TRUE?

I get the situation when OnCloseFile() callback is closed twice with the same context. Is it expected?

The directory '\testdir' was opened 2 times by OnOpenFile(), and then closed 2 times by OnClose() callback.
And it doesn't matter whether 2 different context were returned from OnOpenFile() or the same, OnClose() is called twice with the last returned:


1. Returning same context in OnOpenFlie callback
Open: '\testdir' , ctx:00000000, access/share:[00100080:0007]
Open ready: '\testdir' (ctx:00322F20)
Open: '\testdir' , ctx:00322F20, access/share:[00000080:0007]
Open ready: '\testdir' (ctx:00322F20)
Close: '\testdir', (ctx:00322F20,attr:Directory, Archive)
Close: '\testdir', (ctx:00322F20,attr:Directory, Archive)

(but here I can understand the situation)

2. Returning different contexts in OnOpenFile callback:
Open: '\testdir' , ctx:00000000, access/share:[00100080:0007]
Open ready: '\testdir' (ctx:003C3128)
Open: '\testdir' , ctx:003C3128, access/share:[00000080:0007]
Open ready: '\testdir' (ctx:003C30D8) <-- renew context
Close: '\testdir', (ctx:003C30D8,attr:Directory, Archive)
Close: '\testdir', (ctx:003C30D8,attr:Directory, Archive)

Is it expected behavior?
How should I determine what resources allocated on OnOpenFile to free up when I call OnClose?
Is it somehow related to CallAllOpenCloseCallbacks?

Thanks,
IP
#19506
Posted: 03/16/2012 11:54:48
by Volodymyr Zinin (EldoS Corp.)

Quote
Ivan P wrote:
Is it true for the situation when CallAllOpenCloseCallbacks is TRUE?

It's true.

Quote
Ivan P wrote:
I get the situation when OnCloseFile() callback is closed twice with the same context. Is it expected?

Yes.

Quote
Ivan P wrote:
Is it expected behavior?

Yes. The newer context just replaces the older one. Inside CallbackFS it's just a pointer that holds your context.

Quote
Ivan P wrote:
How should I determine what resources allocated on OnOpenFile to free up when I call OnClose?

Just allocate the context once and use it till the last OnClose callback for the file.

Quote
Ivan P wrote:
Is it somehow related to CallAllOpenCloseCallbacks?

No.


A little theory about it:
Usually file systems have two contexts (and CallbackFS internally has the same) - FCB (file control block) and CCB (context control block). The names can differ but the idea is the same. FCB is what you are talking about. It represents all file/directory openings and exists until the last file closing. But CCB is created for each file/folder opening and represents exactly this opening. After the associated OnClose callback it's deleted. This context isn't visible now and can't be used in the callbacks, but we are going to add it in the next version.

Reply

Statistics

Topic viewed 822 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!