EldoS | Feel safer!

Software components for data protection, secure storage and transfer

File Rename, Create, Read Problem

Also by EldoS: BizCrypto
Components for BizTalk® and SQL Server® Integration Services that let you securely store and transfer information in your business automation solutions.
#20217
Posted: 05/23/2012 03:57:54
by Kenny Kim (Standard support level)
Joined: 08/19/2009
Posts: 38

Good afternoon.

I am having a number of problems related to file creation, renaming, and opening.

Test Folder Contents:
    Music
    Far_from_me.mp3
    a.txt
    MyDocs.rar


1. When I rename file "a.txt" to "b.txt"--> Far_from_me.mp3 disappears and a.txt does not change it's name:
    Music
    a.txt
    MyDocs.rar

After hitting F5, everything is ok as it was supposed to be.

2. I copy and paste Output.docx to Test Folder--> It does not show up until refreshing with F5.

3. I want to open MyDocs.rar--> WinRar gives an error: "Cannot open a.txt" (not MyDocs.rar).
If I try to open Output.docx--> Word gives an error: "Cannot open Far_from_me.mp3".

I tracked the log, and I get this kind of sequence:
Try to open MyDocs.rar:
Code
Open: Mydocs.rar, FileHandle: 8694240
Close: Mydocs.rar, FileHandle: 8694240
GetFileInfo: a.txt
Open: a.txt, FileHandle: 8694240
Read: a.txt, FileHandle: 8694240
Read: a.txt, FileHandle: 8694240
Read: a.txt, FileHandle: 8694240
...
Note that, file handle for "a.txt" is same like for "MyDocs.rar" (it should not be same).

I know that this is my mistake, as Mapper sample is working fine.
But, I would like to hear from you to which part of my code (which method of CbFs) I should pay attention in order to solve this problem. As, I want to read file "A", but the application is getting file "B".
#20219
Posted: 05/23/2012 04:13:33
by Eugene Mayevski (EldoS Corp.)

FileHandle is a pointer to certain in-memory structures, which are reused, so the same handle is not necessarily an indicator of the problem.

First of all I'd check your OnEnumerateDirectory and OnGetFileInfo callback implementations.

Next, it's not clear from your message, what "if I rename" means. Do you rename them in Windows Explorer or other file manager OR you change some backend data storage? Your remark about pressing F5 hints that you do the changes in the backend.


Sincerely yours
Eugene Mayevski
#20222
Posted: 05/23/2012 04:36:32
by Kenny Kim (Standard support level)
Joined: 08/19/2009
Posts: 38

Quote
Eugene Mayevski wrote:
FileHandle is a pointer to certain in-memory structures, which are reused, so the same handle is not necessarily an indicator of the problem. First of all I'd check your OnEnumerateDirectory and OnGetFileInfo callback implementations. Next, it's not clear from your message, what "if I rename" means. Do you rename them in Windows Explorer or other file manager OR you change some backend data storage? Your remark about pressing F5 hints that you do the changes in the backend.


In this case, FileHandle will never be the same for different files, as we get it from remote server when we open the file, it is unique:
Code
private void CbFsOpenFile(object sender, string FileName, ACCESS_MASK DesiredAccess, UInt32 ShareMode, ref IntPtr FileHandleContext)
{
...
IntPtr FileHandle = myDLL.open(storage_handle, FileName, O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
...

I am renaming the file in Windows Explorer, not in the backend.

And I'll recheck the callbacks you have mentioned.
Thank you.
#20225
Posted: 05/23/2012 06:26:14
by Volodymyr Zinin (EldoS Corp.)

Check the OnDirectoryEnumerate and OnGetFileInfo callbacks. Perhaps you missed to report "Far_from_me.mp3" or an incorrect data was returned in the previous OnDirectoryEnumerate call.
Take Process Monitor from sysinternals.com, set there to filter only your virtual disk (by setting a filter - "Path"->"Begins with"->"X:"), reproduce the problem, and examine the log. It can help to find what is wrong.
#20286
Posted: 05/31/2012 23:42:15
by Kenny Kim (Standard support level)
Joined: 08/19/2009
Posts: 38

Problem Solved.
The reason for problem was OnDirectoryEnumerate Mask parameter.
Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.

Reply

Statistics

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