EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Get the flags passed to CreateFile WinAPI

Also by EldoS: CallbackDisk
Create virtual disks backed by memory or custom location, expose disk images as disks and more.
#19082
Posted: 02/15/2012 11:17:47
by Ivan P (Priority Standard support level)
Joined: 04/11/2011
Posts: 66

Hi there,

The CreateFile() windows API functions accepts flags into dwFlagsAndAttributes parameter, but when it reaches CbFsCreateFile() callback, the FileAttributes parameter contains only attributes, but not flags. I tested with FILE_FLAG_DELETE_ON_CLOSE.

We use the remote back-end storage and it's unlikely to initiate data transfer operations for a file that is known to be deleted.
If we could check FILE_FLAG_DELETE_ON_CLOSE, we could cache it's contents locally.
Is ti possible to know this flag?

Thanks,
IP
#19091
Posted: 02/15/2012 12:12:02
by Volodymyr Zinin (EldoS Corp.)

Hello,

It's possible to pass the "delete on close" flag to the OnCreate and OnOpen callbacks. In the nearest build we will do it.
#19102
Posted: 02/16/2012 08:54:40
by Ivan P (Priority Standard support level)
Joined: 04/11/2011
Posts: 66

That's great!

What about other flags? I'm not sure right now how all of them can be used, but for example FILE_FLAG_RANDOM_ACCESS and FILE_FLAG_SEQUENTIAL_SCAN may be considered to select appropriate caching strategy.

Sincerely,
IP
#19117
Posted: 02/17/2012 07:11:35
by Volodymyr Zinin (EldoS Corp.)

We will check what other flags are possible to pass and do it with the "delete on close" one.
#19295
Posted: 03/05/2012 03:12:04
by Volodymyr Zinin (EldoS Corp.)

We have added it. In the next build there will be a new property UseFileCreationFlags which will allow to see in the FileAttributes parameter of the OnCreate/OnOpen callback the FILE_FLAG_DELETE_ON_CLOSE flag as well as other flags.
Below is the full list of these flags:
FILE_FLAG_WRITE_THROUGH
FILE_FLAG_SEQUENTIAL_SCAN
FILE_FLAG_RANDOM_ACCESS
FILE_FLAG_NO_BUFFERING
FILE_FLAG_DELETE_ON_CLOSE
FILE_FLAG_BACKUP_SEMANTICS
FILE_FLAG_OPEN_NO_RECALL
FILE_FLAG_OPEN_REPARSE_POINT
#19316
Posted: 03/07/2012 05:36:18
by Ivan P (Priority Standard support level)
Joined: 04/11/2011
Posts: 66

Great news! Thanks a lot!

Sincerely,
IP
#19318
Posted: 03/07/2012 05:43:27
by Volodymyr Zinin (EldoS Corp.)

Actually the new build is on the site.
#19435
Posted: 03/14/2012 08:32:05
by Ivan P (Priority Standard support level)
Joined: 04/11/2011
Posts: 66

Hi again,

I just installed new driver version 3.2.106.266 (and rebooted) and called:
Code
HANDLE hFileTest8 = CreateFile(L"Z:\\test8", FILE_GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_FLAG_WRITE_THROUGH | FILE_FLAG_DELETE_ON_CLOSE, NULL);


But the OnCreateFile callback came up with FileAttributes = 0x80
(used Mapper sample with CallAllOpenCloseCallbacks = true)

Another question:
OnOpenFile callabck doesn't have FileAttributes parameter. Maybe it's possible to call some CBFS API from this callback to get the file open flags?


OS: Windows 7 x64, sp 1

Sincerely,
IP
#19436
Posted: 03/14/2012 08:50:40
by Volodymyr Zinin (EldoS Corp.)

Set the UseFileCreationFlags property to TRUE.
#19437
Posted: 03/14/2012 09:00:31
by Ivan P (Priority Standard support level)
Joined: 04/11/2011
Posts: 66

It's set to true right after creation of CallBackFileSystem (and when I check sender's properties in a callback, it's set to "true").

And what about OnOpenFile callback?

Thanks,
IP

PS: I'm using .Net
Also by EldoS: CallbackFilter
A component to monitor and control disk activity, track file and directory operations (create, read, write, rename etc.), alter file data, encrypt files, create virtual files.

Reply

Statistics

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