EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Opening and closing files

Also by EldoS: RawDisk
Access locked and protected files in Windows, read and write disks and partitions and more.
#5685
Posted: 03/31/2008 11:59:09
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

Hello, again :D

My application, which is based upon your VDisk sample, is moving along well, but there are still a lot of things that I do not understand about the Callback File System.

One thing I have a question about is the opening and closinmg of files. When I open a file using WordPad (or any other Windows Application), I get a call to the CbFsOpenFile Callback that is in my application, as I would expect. Also, when WordPad reads or writes to the file the appropriate callbacks get called, again as I would expect. But, when I close the file in WordPad by exiting WordPad, I do not get a call to the CbFsCloseFile Callback, as I would expect. The call to that callback routine doesn't seem to come until I close my application completely. This is not what I would have expected, could you please explain it to me?
#5686
Posted: 03/31/2008 12:02:19
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

Just a quick follow-up to the previous message, the call to the open callback also seems to come at a strange time. Instead of when WordPad opens the file, it comes when in Windows Explorer I click my mouse over the file that I am about to open.
#5689
Posted: 03/31/2008 12:09:13
by Eugene Mayevski (EldoS Corp.)

Quote
Sid Schipper wrote:
The call to that callback routine doesn't seem to come until I close my application completely. This is not what I would have expected, could you please explain it to me?


Set AllowDelayedClose property to false.

Quote
Sid Schipper wrote:
Just a quick follow-up to the previous message, the call to the open callback also seems to come at a strange time. Instead of when WordPad opens the file, it comes when in Windows Explorer I click my mouse over the file that I am about to open.


In your code you can call GetOriginatorProcess to find out what process opens the file. It can be that Explorer reads some data from the file. If you have CallAllOpenCloseCallbacks property set to false, then this call to OnOpenFile is the only call that you will see. If CallAllOpenCloseCallbacks is set to true, then OnOpenFile is called several times (once for each open operation).


Sincerely yours
Eugene Mayevski
#5692
Posted: 03/31/2008 13:04:10
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

Thank you, Eugene, this information really helped. I'm sorry if my questions seem too elementary.
#5693
Posted: 03/31/2008 13:12:35
by Eugene Mayevski (EldoS Corp.)

It's always good to repeat them (reasonable number of times :) so that other users could easily find and read this information in the forum.


Sincerely yours
Eugene Mayevski
#5707
Posted: 04/01/2008 12:57:32
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

:)
I have another question on this particular topic.

If the CallAllOpenCloseCallbacks property is set to false and I am a user who never turns off his machine and comes to work every day and access's 1000 new files daily. Since you never call the OnClose callback for these files, wouldn't the internal structures that your system uses to keep track of all these files grow to an intolerably large amount?

Is there some timeout value that you use to say that if a file has not been accessed for a certain amount of time then you go ahead and call the OnClose callback as if it were the last close call on that file?
#5708
Posted: 04/01/2008 14:12:25
by Volodymyr Zinin (EldoS Corp.)

Hello,

At the first the operating system (to be more precise - it's the system cache manager) holds references to the files which were opened (in hope that these files will be opened again soon and their contents will be already in the system cash). That's why the close callbacks are not called for a long time. Sure, the operating system removes the most unnecessary files from the cache when some limits are expired (it depends on the system settings).
But you can forcibly close the system's references using the function ReleaseUnusedFiles from the CallbackFS api. Also if the property UseSystemCache is set to TRUE, that means that in the user callbacks the buffered (i.e. cached) I/O is used, then the CallbackFS driver don't use the system mechanism for files caching (because there is a possibility of a deadlock in the system), so the described above don't happen.

Also internally the CallbackFS driver delays closing of files in hope that these files will be opened again soon and data structures that were created internally by the driver for the files will be reused. Sure there is some limit based on the number of the latest opened files. This limit depends on the amount of memory in the system (maximum this limit is 256 files).
The ReleaseUnusedFiles function also releases these files. Also using the function AllowDelayedClose you can disable this mechanism.

By means of CallAllOpenCloseCallbacks­ you can ask CallbackFS not to call OnOpen/OnClose callbacks for nested openings of a file. For example some file can be opened by one program and when it's still opened another process opens it too. In this case if CallAllOpenCloseCallbacks is set to FALSE then only the first OnOpen callback is called and when the both programs close the file then OnClose is called.
Also by EldoS: CallbackDisk
Create virtual disks backed by memory or custom location, expose disk images as disks and more.

Reply

Statistics

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