在做USB mass storage功能时出现如下问题: 2G以下的卡通过USB MASS STORAGE在PC端能正常识别; 4G或8G的卡在PC端提无法识别。 系统是WINCE5.0,我用4G的卡调试了一下,发现BLOCK.CPP文件中的STORE_Init函数中OpenStore()打开失败。 请各位大侠给点建议,谢谢。
// Get the topmost file system object associated with the volume.
// If another filter is hooked between now and the time we call
// create file, we'll still use this one. This file system object
// will be referenced by the handle object.
FileSystem_t* pFileSystem = pVolume->GetFileSystem ();
DWORD Attributes = 0;
if (OPEN_EXISTING != Create) {
// If not trying to open an existing file, there is the
// possibility that we will create a new one. In order to
// properly generate notifications we need to detect whether or
// not the file already exists using GetFileAttributes.
Attributes = pFileSystem->GetFileAttributesW (pPathName);
}
// The file system succeeded creating/opening the file, so
// allocate an FileSystemHandle_t object and associate it with the
// MountedVolume_t object.
// Indicate whether or not this is a console or psuedo-device
// handle when creating the FileSystemHandle_t object. This will dictate
// how notifications are performed on the handle.
DWORD HandleType = FileSystemHandle_t::HDL_FILE; /*******************chaged by pang********************************/
if (IsPsuedoDeviceName(pPathName))
{
HandleType |= FileSystemHandle_t::HDL_PSUEDO;
}
/***************************************************/
if (IsConsoleName (pPathName)) {
HandleType |= FileSystemHandle_t::HDL_CONSOLE;
}
// Allocte a new handle object to track this item.
h = pVolume->AllocFileHandle (reinterpret_cast<DWORD> (hInt),
HandleType, pFileSystem, pPathName, Access);
if (INVALID_HANDLE_VALUE != h) {
// Perform notifications only when the handle is for a real file,
// not a pseudo device handle or console handle. Devices and streams
// shouldn't ever generate notifications.
if (FileSystemHandle_t::HDL_FILE == HandleType &&
!IsPsuedoDeviceName (pPathName)) {
// Successfully opened the file. Perform file notifications
// as required.
if (INVALID_FILE_ATTRIBUTES == Attributes) {
// The file did not previously exist; notify that it has
// been added.
pVolume->NotifyPathChange (pPathName, FALSE, FILE_ACTION_ADDED);
// The file previously existed but is being re-created or
// truncated so notify that it has changed.
pVolume->NotifyPathChange (pPathName, FALSE, FILE_ACTION_MODIFIED);
}
}
} else {
// Failed to allocate a handle object, so close the handle
// that was returned by the file system.
pFileSystem->CloseFile (reinterpret_cast<DWORD> (hInt));
}
// TODO: Privilege check for raw disk i/o. This requires more privilege than file i/o.
// Clear error code set by the FSD when it failed to open VOL: on its own.
SetLastError (ERROR_SUCCESS);
// We failed to open the file, but if it is VOL: special case this
// and allow direct partition access.
h = pVolume->AllocFileHandle (reinterpret_cast<DWORD> (hInt),
FileSystemHandle_t::HDL_PSUEDO, pFileSystem, pPathName, Access);
}