I want to controll for usb mass storage device in linux,android
when usb device is in act to change a file, i wanner get the file in usb mass storage.
There is source code for Windows,but linux or android isn't.
please help me!
void main(){
HANDLE SourceFile, IoPort;
DWORD nBytes;
DWORD vRet;
DWORD vFileSize;
OVERLAPPED Overlapped;
BYTE *pBuf;
BOOL vStatus;
DWORD nFileSeek;
SourceFile = CreateFile("K:\\cmdtrans.bin",
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING,
NULL);
if( SourceFile == INVALID_HANDLE_VALUE ) return;
IoPort = CreateIoCompletionPort(SourceFile, NULL, 0, 1);
if( IoPort == NULL ) return;
vFileSize = GetFileSize(SourceFile, NULL);
pBuf = VirtualAlloc(NULL, vFileSize, MEM_COMMIT, PAGE_READWRITE);
if( pBuf == NULL ) return;
gCapFlag =1
while(gCapFlag)
{
if( SetFilePointer(SourceFile, 0, NULL, FILE_BEGIN) == 0xFFFFFFFF ) break;
Overlapped.Offset = 0;
Overlapped.OffsetHigh = 0;
Overlapped.hEvent = NULL;
vStatus = WriteFile(SourceFile,pBuf,512,&nBytes, &Overlapped);
ReadFile(SourceFile, pBuf, 65536, &nBytes, &Overlapped);
DispFP( hWnd, pBuf, 65536 );
ClearMessage();
}
OutputDebugString("breaked!!!");
CloseHandle(SourceFile);
CloseHandle(IoPort);
VirtualFree(pBuf, 65536, MEM_DECOMMIT);
}