EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Refreshing Virtual Drive/Disk

Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.
#7737
Posted: 09/29/2008 08:36:28
by Khayralla AL-Athari (Standard support level)
Joined: 09/23/2008
Posts: 75

Hi all

After adding and deleteing subfolders on the Z:\ drive, I got incorrect folders structure. When I refresh Windows Explorer from View menu then Refresh, every thing is corrected. So I want to Refresh Virtual Derive Programmatically.

Is there any way to refresh Virtual Drive (Z:\) Programmatically ?

thanks

Khayralla
#7741
Posted: 09/29/2008 09:32:12
by Eugene Mayevski (EldoS Corp.)

Use NotifyDirectoryChange method to notify the OS that the contents of some folder has been changed.


Sincerely yours
Eugene Mayevski
#7744
Posted: 09/29/2008 10:32:20
by Khayralla AL-Athari (Standard support level)
Joined: 09/23/2008
Posts: 75

Hello Eugene

Is there any documents about How to use NotifyDirectoryChange ?

Windows Explorer is always hanging after using NotifyDirectoryChange.

thanks

Khayralla
#7748
Posted: 09/29/2008 12:08:30
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

I have this same problem.

I am using the VC++ library version of the API and running under Windows XP.

I also see an incorrect directory structure after I create a new file in a directory and when I put the NotifyDirectoryChange call into the CbFsCreateFile callback, the system hangs. Could you please help me with this problem?
#7750
Posted: 09/29/2008 12:24:37
by Eugene Mayevski (EldoS Corp.)

Vladimir Zinin will check the issue on Thursday when he returns from the conference.


Sincerely yours
Eugene Mayevski
#7762
Posted: 09/30/2008 10:46:29
by Volodymyr Zinin (EldoS Corp.)

Hello,

The NotifyDirectoryChange function should only be used when some files/directories are added/deleted/modified in some nonstandard way - not by adding/deleting/modifying them via the virtual disk. For example if you decide that some file mustn't be shown in a directory then you call this function and won't specify the file in the following enumerations.

Perhaps there is a bug in CallbackFS. Does the problem exist with our Mounter sample too? Some test from you that has this problem is really appreciated.
#7763
Posted: 09/30/2008 10:55:56
by Eugene Mayevski (EldoS Corp.)

To rephrase - the method should be called when the file is added to or is removed from the backend file system, which is represented by CBFS. If the file is created by the OS and you receive OnCreateFile callback, then there's no need to call Notify...() from the callback handler.


Sincerely yours
Eugene Mayevski
#8489
Posted: 12/16/2008 18:07:48
by Kurt Griffiths (Standard support level)
Joined: 12/08/2008
Posts: 34

After mounting my CBFS drive, I noticed that the first time I run this code:

HANDLE h = CreateFile("X:\\test.txt", GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
DWORD fsize = GetFileSize(h, NULL);
CloseHandle(h);

The OnGetFileInfo event is triggered, but for subsequent requests it is not. Am I correct in assuming that the file info (such as file size) is getting cached after the first call? If so, is calling NotifyDirectoryChange the correct way to force CBFS to call OnGetFileInfo again?

The reason I ask is that I am implementing a network file system and if a remote file's size changes, I need to let the operating system know so it will ask for the new size. The problem is complicated by the fact that I don't know that a file has been updated until a request comes in to reopen it.

As far as I can tell, I would need to call NotifyDirectoryChange (on a background thread) in my OnCreateFile callback when I detect the file has changed, waiting until the call completes to avoid a race condition where the file is opened and then the file size is immediately requested before NotifyDirectoryChange has a chance to run.

Does that sound like the right approach?
#8491
Posted: 12/17/2008 00:35:50
by Eugene Mayevski (EldoS Corp.)

Quote
Kurt Griffiths wrote:
Am I correct in assuming that the file info (such as file size) is getting cached after the first call? If so, is calling NotifyDirectoryChange the correct way to force CBFS to call OnGetFileInfo again?


The information is cached by Windows, not by CBFS. NotifyDirectoryChange should be called when you change the file not via the mapped disk but directly.

Example:

you map your database to drive X:. If you change the database, you need to call NotifyDirectoryChange in order to inform the OS avbout the change. If you change the file X:\test.txt, you don't need to call NotifyDirectoryChange as the OS knows about the file operation that you performed.

As for the scheme that you are thinking about, I don't know the details so I can't comment, but the above information should help. If something doesn't work, we'll dig deeper into your scheme.



Sincerely yours
Eugene Mayevski
#8493
Posted: 12/17/2008 03:00:45
by Volodymyr Zinin (EldoS Corp.)

Unfortunately in the current version it's possible only to call NotifyDirectoryChange outside the callback functions (from the callback functions context the NotifyDirectoryChange call fails).
But we'll investigate how to upgrade this mechanism and I'll notify you about it here in this topic. I think it won't be earlier than in 1 month.
Also by EldoS: SecureBlackbox
200+ components and classes for digital security, signing, encryption and secure networking.

Reply

Statistics

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