EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Identify CloseFile callback

Also by EldoS: SecureBlackbox
200+ components and classes for digital security, signing, encryption and secure networking.
#14973
Posted: 11/08/2010 04:39:28
by Robert Baer (Basic support level)
Joined: 11/08/2010
Posts: 46

Hello,

I am using Callback File System to display files which are stored inside a database. When a process opens a file in read-write mode, it gets checked out of the database so nobody else can change it. The file needs to be checked in again when it gets closed.

I have the problem to identify the CloseFileEvent which finishes the read-write mode. In OpenFileEvent I can check parameter DesiredAccess to identify read-write access. But how do I identify the corresponding close?

Example (property SetCallAllOpenCloseCallbacks is true):
Step 1) Process A: Open file x (read access) -> OpenFileEvent
Step 2) Process B: Open file x (read-write access) -> OpenFileEvent
Step 3) Process A: Close file x -> CloseFileEvent (read-write mode still active)
Step 4) Process B: Close file x -> CloseFileEvent (file can be checked in now)

The CloseFileEvents of step 3 and 4 could be called in a different sequence - so how can I identify the correct one?

Thanks!
#14975
Posted: 11/08/2010 05:29:53
by Eugene Mayevski (EldoS Corp.)

Thank you for contacting us.

Whatever information you want to carry from OnOpen/OnCreate to other file-related callbacks (such as file name, origin, access rights etc) -- you need to put all information into some structure / object and use UserData property to carry the reference to the structure / object. I.e. you create the structure or object in OnOpen callback and put a reference to UserData. Then the reference you've passed is passed back to you in other file-related callbacks including OnClose.

I believe we have the illustration of this in the samples.


Sincerely yours
Eugene Mayevski
#14976
Posted: 11/08/2010 06:46:26
by Robert Baer (Basic support level)
Joined: 11/08/2010
Posts: 46

Thanks for your reply! I am using the described method to pass over the required information (reference to UserData-object assigned to parameter FileHandleContext).
This context-object gets passed to all following file-related callbacks, which is a problem when the same file is opened by multiple applications. Please have a look at my example above: As there is only one context-object per file (even if opened by different threads), I cannot say if the write-mode is closed in step 3 or in step 4.

Regards,
Robert
#14977
Posted: 11/08/2010 07:40:09
by Eugene Mayevski (EldoS Corp.)

Yes, you are right, UserData is per-file context. Doing what you need is not possible at the moment. In version 3.1, which will be released pretty soon, we will have two different contexts - one for the file, and another one for each create/open operation


Sincerely yours
Eugene Mayevski
#14979
Posted: 11/08/2010 08:13:54
by Robert Baer (Basic support level)
Joined: 11/08/2010
Posts: 46

Thanks for your prompt reply! I am looking forward to version 3.1!

Regards,
Robert
#15048
Posted: 11/15/2010 10:20:02
by Eugene Mayevski (EldoS Corp.)

We started to implement an open context and faced the conceptual problem / limitation of Windows architecture. Open context exists only in some file operations, namely open/close/seek. It doesn't exist in read/write/setfilesize. This makes such context of very limited functionality and usability. Due to this we decided not to add the second context at least until CBFS 4.0 in order to keep API compatibility within version 3 of CBFS.


Your task can be addressed in the following way:

when the file is opened, you need to track (in FileContext) the number of open operations and the number of open-for-writing operations. Then in OnWrite callback you also track writes (to know that write actually occured). Then when the file is closed for the last time, you check that the file has been written to, and commit the changes to the server.


Sincerely yours
Eugene Mayevski
#15051
Posted: 11/16/2010 01:56:19
by Robert Baer (Basic support level)
Joined: 11/08/2010
Posts: 46

Thanks for your response. I am using the described way as a workaround now. As far as I can see, it seems to be a feasible way for the moment.

Nevertheless it would help to have the open context in the open and close callback (even if it doesn't exist in write callback). That way, it would be possible to detect the close command which closes the last open-for-writing operation.

Regards,
Robert
Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.

Reply

Statistics

Topic viewed 1486 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!