Windows XP
(1)
WinCE
(1)
Windows Embedded
(1)
WindowsEmbeddedCookbook
(1)
APIs
(1)
EMVP
(1)
Eurotech.it.nospam
(1)
Windowsembeddedit
(1)

USB mass storage device asynchronous file change notification

Asked By PeterV
18-Dec-09 09:46 PM
Hello,

A challenge: I have a (RAM) disk, which is exposed as a USB mass
storage device. Therefore, the desktop computer accesses my disk as a
SCSI block device. Also, I mounted the same disk using the FATFS and I
can see files under WinCE, which have been just copied over USB from
the desktop. So far, so good. Now: if I create a file under WinCE, the
desktop computer does not notice and I can wait forever. When I unplug
and plug-in the USB again, I can see the file created before under
WinCE.

Is there a sort of SCSI asynchronous file change notification? If so,
is there any example about how to implement that?

Thank you very much for help,
Peter

Uh?

Luca Calligaris [eMVP] replied to PeterV
18-Dec-09 07:37 AM
Uh? Do you mean that you have a Windows CE device which has a USB client
controller and it is seen by an USB host controller as an USB mass storage
device and the exposed storage that you see from the PC is not a 'real' one
(flash, SD, ...) but it is a RAM storage?
If I remember correctly once I did something similar (my device exposed the
SD card to the USB host, actually) and I noticed the same behaviour but it
was for testing purposes so I did not go on with the analysis

--
Luca Calligaris (MVP-Windows Embedded)
l.calligaris.nospam@eurotech.it.nospam
www.eurotech.it

Yes, the idea is the following: there is an input file, which has tobe

PeterV replied to Luca Calligaris [eMVP]
18-Dec-09 09:46 PM
Yes, the idea is the following: there is an input file, which has to
be processed by the target, and there is an output file from the
target, which must be read back to the desktop computer (host). The
desktop PC is waiting for the output file from the target.

It must be possible somehow: imagine a digital camera and the user
taking pictures while the camera is connected to the computer. After a
while, the user can see the new picture files appearing in the
Explorer...

It seems that this is a desktop question.

Paul G. Tobey [eMVP] replied to PeterV
18-Dec-09 11:13 AM
It seems that this is a desktop question.  My guess is that, just like with a
shared folder on the desktop, if you are watching it with Explorer, new files
created by remote users of the share do not instantly appear.  If you press
F5/choose Refresh in Explorer, the files show up.

Paul T.
No, it is no F5 issue - it does not work, if the USB mass
PeterV replied to Paul G. Tobey [eMVP]
19-Dec-09 06:57 AM
No, it is no F5 issue - it does not work, if the USB mass storage
asynchronously creates files. I think the reason for it is the disk
cache of the desktop Windows (XP), which caches blocks. In these
block, there are FAT directory entries as well as file data. The disk
cache has no means to renew blocks, which have been remotely changed
(because it expects the storage not to change files).

it is a desktop Windows question: can I set the disk cache for one
particular USB mass storage device to zero (or disable)? Either with
registry keys or with WIN32 APIs? That would be great if someone has a
hint.

Thanks,
Peter
On 12/18/2009 11:44 AM, PeterV wrote:AFAIK the USB mass-storage protocol work
Valter Minute [eMVP] replied to PeterV
21-Dec-09 09:05 AM
AFAIK the USB mass-storage protocol work on the disk blocks/sectors, not
on a filesystem (like SMB or other network sharing protocols, for
example). In this way both system have their own version of the
filesystem and they may modify it at the same time (leading to
filesystem corruption probably).
You may have one of the two system in read-only mode (the PC I suppose
in your case), and this may preserve filesystem integrity, but the PC
USB mass-storage driver does not refresh the contents of its own
filelists because no-one is supposed to modify them, so it may (and
will) keep a cache of them and does not refresh it even if you ask a
refresh from the explorer UI.
You may try to mount your mass-storage interface as a removable device
and notify that it has been removed and re-inserted everytime you need
to refresh the info, but this can cause errors on the PC side if an
application was reading the file or keeping an open handle when you
simulate the eject-reinsert procedure.

--
Valter Minute (eMVP)
Training, support and development for Windows CE:
www.fortechembeddedlabs.it
My embedded programming and cooking blog:
www.geekswithblogs.net/WindowsEmbeddedCookbook
Windows Embedded support forums in Italian:
http://social.msdn.microsoft.com/Forums/it-IT/windowsembeddedit/threads
(the reply address of this message is invalid)
Post Question To EggHeadCafe