EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Test if file system in use

Also by EldoS: SecureBlackbox
200+ components and classes for digital security, signing, encryption and secure networking.
#25672
Posted: 07/14/2013 20:35:31
by Carsten Friedrich (Standard support level)
Joined: 05/23/2013
Posts: 7

How do I test if a callback filesystem is currently in use? By "in use" I mean if I click on "eject" in Windows Explorer, the eject would fail.

It seems more complicated than keeping track of open/close calls. E.g. if I open a text file in Notepad, the file gets opened and closed. However until I close Notepad Windows somehow knows that the file is still in use.
#25675
Posted: 07/15/2013 00:53:40
by Eugene Mayevski (EldoS Corp.)

We plan to extend the API with a function that tells you about opened files (so that you don't need to keep counters yourself) but if you say that closing all files doesn't work, then the function would not help either.

Did you check the Mapper sample - does it expose the same problem? If you didn't try it, please try to reproduce the issue with it.


Sincerely yours
Eugene Mayevski
#25676
Posted: 07/15/2013 02:13:52
by Volodymyr Zinin (EldoS Corp.)

In the case you need to protect a storage from unmounting if there are opened files on it - there is the ForceUnmount parameter in the UnmountMedia method. If this parameter is FALSE then this function fails if any files are still opened.
#25708
Posted: 07/17/2013 17:45:12
by Carsten Friedrich (Standard support level)
Joined: 05/23/2013
Posts: 7

Not sure how to check with the Mapper sample - It's not an unexpected behavior, and every disk device including ordinary USB sticks show this behavior.

I first thought that it may be connected to file locks, but this does not seem to be the case either as "unlocker" programs can't detect a lock on those files.

The reasons why I would like to be able to test this is that this (i.e. when a CBFS device could safely be unmounted) would be a good time for me to do some background clean-up / synchronization. I understand that this is no guarantee that the user might not access a file on the device shortly after, but it is a bit less likely. I can handle such an interruption, but it is costly and I would like to minimize the probability.
#25715
Posted: 07/18/2013 02:14:49
by Volodymyr Zinin (EldoS Corp.)

You can check whether any files are still opened by implementing a "HandleCounter" field in the FileInfo user context (for details see this parameter in the callbacks) and then increment it during processing of the OnCreateFile and OnOpenFile callbacks and decrement in the OnCleanupFile callback. If this "HandleCounter" is zero then there is no opened handles to the file.
Also you can use the ForceUnmount parameter in the UnmountMedia method (as I wrote above).
Also by EldoS: BizCrypto
Components for BizTalk® and SQL Server® Integration Services that let you securely store and transfer information in your business automation solutions.

Reply

Statistics

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