EldoS | Feel safer!

Software components for data protection, secure storage and transfer

CbFsRenameOrMoveFileFunc sometimes fails to reopen the file

Posted: 07/04/2016 06:29:06
by Kunikazu Okada (Standard support level)
Joined: 05/12/2016
Posts: 3

We use CBFS with CallAllOpenCloseCallbacks = TRUE.

Basically,in our implementation ,
every OnOpenFile/OnCreateFile event opens a new file handle with CreateFile ,
and OnCleanupFile event closes the handle .

This works well with Microsoft Office Applications and file access sharing .
But there was a problem with opening certain powerpoint file .


MS-PowerPoint opens and closes a certain temporary file,
multiple times from multiple threads, and then
renames that tempoary file to the output file.

Handle1 opened for fileA(readWrite)

Somewhat OnCleanupFile event comes first for the temp file,
then CbfsRename renames the temp file to the dest file,
but OnCloseFile event for the temp file comes later,
after OnRenameFile is done.

ex. Handle1 closed for fileA
OnCleanupFile event fired for Handle1
event handler closes file handle of Handle1
Handle2 opened for fileA(readWrite)
OnOpenFile event opens file handle of Handle2

Inside CbFsRenameOrMoveFileFunc function
1) cbfs iterate through all open handles and closes them first,
(calling OnCleanupFile/OnCloseFile event with the handleInfo)

ex. OnCleanupFile event for Handle1 called again.( file handle for Handle1 already closed)
ex. OnCleanpuFile event for Handle2 called.
the event closes file handle of Handle2

2) OnRenameOrMoveFile event is fired . (this actually renames the file)

3) then, cbfs reopens all handles
(calling OnOpenFile) event

ex. OnOpenFile event for Handle1 called
it unexpecetedly opens the file handle of Handle1 with readWrite access.

OnOpenFile event for Handle2 fails (ERROR)
because the same file is already opend readWrite with Handle1

I've found that in the above case when OnCloseFile evnet for the Closed file comes delayed,
CbFsRenameOrMoveFileFunc reopens the file handle for it unexpectedly in the reopening loop process of 3).
thus causing "SHARING VIOLATION" with another file handle opened in the reopening loop.


I've added a boolean flag OnCleanupCallbackCalled to HandleInfo.
OnCleanupFile events set OnCleanupCallbackCalled to True.
OnOpenFile skips the file opening process if OnCleanupCallbackCalled = True.

Then,CbFsRenameOrMoveFileFunc successfully reopens the opened file handle (ex. Handle2 ).

I appreciate if you check this phenomina and consider adding this kind of skip logic
in CbFsRenamOrMoveFileFunc.

Thank you.
Posted: 07/04/2016 08:05:58
by Volodymyr Zinin (Team)

Thank you for the detailed description of the problem. Could you please specify what version of CBFS you are using? As I remember some bug with renaming has been fixed recently. So if you are using not the latest build please check the problem with it.

Posted: 07/04/2016 22:21:04
by Kunikazu Okada (Standard support level)
Joined: 05/12/2016
Posts: 3

I use CBFS 6.1.178 .
Posted: 07/05/2016 03:50:56
by Volodymyr Zinin (Team)

Please check the problem with the latest CBFS build and if it is still reproducible create a ticket in HelpDesk with detailed description what to do in order to reproduce it. Better if it was with the Mapper sample.




Topic viewed 3783 times

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


Back to top

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

Got it!