EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Filesize changed --> NotifyDirectoryChange

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.
#21557
Posted: 09/17/2012 06:43:14
by Christopher Lenz (Basic support level)
Joined: 07/25/2012
Posts: 16

Hello,

I have a problem. I have an ecm system. This system is visualized by cbfs to the explorer. Now I "create" these virtual files with a filesize 100kb or so.
Now while reading the correct filesize after the filetransfer (triggered from readfile) I get a filesize like 102kb. How can I notify the explorer the new filesize? I tried it with:
Code
mCbFs.NotifyDirectoryChange(fileFullName, CbFsNotifyFileAction.fanMetaDataModified, true);

but the files are still corrupt.
#21558
Posted: 09/17/2012 06:52:41
by Eugene Mayevski (EldoS Corp.)

Let's rephrase your description.

You tell the OS in OnEnumerateDirectory/OnGetFileInfo, that filesize is 100Kb.

Now your backend data is changed NOT via the virtual disk (right?) and data size is increased to 102Kb. You need to tell the OS that the backend data have been changed.

Is this correct?


Sincerely yours
Eugene Mayevski
#21559
Posted: 09/17/2012 07:00:18
by Christopher Lenz (Basic support level)
Joined: 07/25/2012
Posts: 16

yes
#21567
Posted: 09/17/2012 08:40:41
by Volodymyr Zinin (EldoS Corp.)

mCbFs.NotifyDirectoryChange(fileFullName, CbFsNotifyFileAction.fanModified, true);
where fileFullName must be started with backslash (i.e. root directory).

fanModified must be used instead of fanMetaDataModified because it's really the data modified (and then the file size changed).
#22001
Posted: 10/15/2012 05:55:15
by Christopher Lenz (Basic support level)
Joined: 07/25/2012
Posts: 16

this NotifyDirectoryChange does not work with txt files and the normal editor?!?
#22002
Posted: 10/15/2012 06:19:32
by Eugene Mayevski (EldoS Corp.)

why not?


Sincerely yours
Eugene Mayevski
#28730
Posted: 03/07/2014 13:19:39
by Ivan P (Priority Standard support level)
Joined: 04/11/2011
Posts: 66

Hi there!

I have a question related to this problem: how should I properly handle filesize change when it was realized inside OnReadFile callback?

Consider the following situation:
1. My callback has received 100K size from the backend storage (GetFileInfo or EnumerateDirectory handler) and returned it to the system.

2. The user application (file manager) starts copying file, reading it by blocks and causing OnReadFile callbacks to be called several times.

3. At some point the OnReadFile handler "realizes" that the file size has changed, and there're 2 possible ways:
a) it can return the requested amount of data (file size increased)
b) it cannot return the requested amount of data (file size decreased)

How should I proceed in both cases?

I can call NotifyDirectoryChange(), but in case of situation (b) I still cannot return the requested data.
Should I return some 'proper' Win32 error code that will cause OS to properly handle this situation (because NotifyDirectoryChange was just called)?
Does the error code matters? Does the fact that I called NotifyDirectoryChange affects the way of handling read error by an OS?

Sincerely,
IP
#28733
Posted: 03/07/2014 14:12:27
by Volodymyr Zinin (EldoS Corp.)

In this case there is no "absolutely correct" way to resolve the problem. As a variant start to return an error from the OnReadFile callback (maybe ERROR_INVALID_HANDLE(6) is ok) and call NotifyDirectoryChange(fanModified).
Maybe it's better to call NotifyDirectoryChange outside the callbacks in order to call it synchronously and, until it hasn't been finished, continue returning ERROR_INVALID_HANDLE(6) from the callbacks for any requests passed to this file. After the NotifyDirectoryChange synchronous call is returned all of currently existing file handles are marked as invalid and any operation with these handles causes the ERROR_INVALID_HANDLE error to return without calling of the callbacks. The only successful API call for such handles is CloseHandle. Of course the OnCleanup and OnClose callbacks still will be called.
Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.

Reply

Statistics

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