EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Create a new file, event sequence

Also by EldoS: RawDisk
Access locked and protected files in Windows, read and write disks and partitions and more.
#27705
Posted: 12/18/2013 09:31:55
by Richard Hauer (Basic support level)
Joined: 12/05/2013
Posts: 26

I would like to understand the event sequence when creating a new file.
This is what I have observed:


  • GetFileInfo (should set FileExists to false to trigger 'Create')
  • CreateFile (called multiple times sometimes in several threads)
  • GetFileInfo (sometimes, if FileExists=true now I will get an 'overwrite' message)
  • OpenFile (sometimes, ?, FileInfo.UserContext not picked up from CreateFile)
  • WriteFile (FileInfo.UserContext not picked up from CreateFile))


I get a CleanupFile randomly here and there as well. Strange.

I wonder if I am introducing timeout/retries because of the attached debugger?

I would like to know the expected sequence, and which event is appropriate to set the FileInfo.UserContext for use in WriteFile.

Should I set up the code such that UserContext might not come along every time? (i.e. grab it if it's there, re-create if not).
#27712
Posted: 12/18/2013 11:10:24
by Volodymyr Zinin (EldoS Corp.)

Sequence of events depends on applications that performs I/O. For information you can take Process Monitor from sysinternals.com (it's a software which logs I/O operations) and see there what events are sent to file systems. Lots of them are easy to correlate with the CBFS callbacks.

There are two contexts - FileInfo and HandleInfo. The first one is FileInfo which represents an opened file/directory at whole. For example several processes can perform CreateFile call at the same time. For all of these requests the OnCreate and OnOpen callbacks will be called (but only if the CallAllOpenCloseCallbacks property is set to TRUE) and the FileInfo context will be the same for all of these requests. The other one represents an unique opening. I.e. it correlates with a handle to a file/directory. For each successful open there is always one OnCleanup callback (which is synchronously called when a handle to a file is being closed) and one OnClose callback (called asynchronously).

Usually FileInfo.UserContext is allocated and set in the first OnCreate or OnOpen callback and released when the last OnClose callback comes.

Reply

Statistics

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