[fastfat_new]
[reactos.git] / reactos / drivers / filesystems / fastfat_new / fullfat.c
1 /*
2 * PROJECT: ReactOS FAT file system driver
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: drivers/filesystems/fastfat/fullfat.c
5 * PURPOSE: FullFAT integration routines
6 * PROGRAMMERS: Aleksey Bragin (aleksey@reactos.org)
7 */
8
9 /* INCLUDES *****************************************************************/
10
11 #define NDEBUG
12 #include "fastfat.h"
13
14 /* GLOBALS ******************************************************************/
15
16 #define TAG_FULLFAT 'FLUF'
17
18 /* FUNCTIONS ****************************************************************/
19
20 VOID *
21 FF_Malloc(FF_T_UINT32 allocSize)
22 {
23 return ExAllocatePoolWithTag(PagedPool, allocSize, TAG_FULLFAT);
24 }
25
26 VOID
27 FF_Free(VOID *pBuffer)
28 {
29 return ExFreePoolWithTag(pBuffer, TAG_FULLFAT);
30 }
31
32 FF_T_SINT32
33 FatWriteBlocks(FF_T_UINT8 *pBuffer, FF_T_UINT32 SectorAddress, FF_T_UINT32 Count, void *pParam)
34 {
35 DPRINT1("FatWriteBlocks %p %d %d %p\n", pBuffer, SectorAddress, Count, pParam);
36
37 return 0;
38 }
39
40 FF_T_SINT32
41 FatReadBlocks(FF_T_UINT8 *DestBuffer, FF_T_UINT32 SectorAddress, FF_T_UINT32 Count, void *pParam)
42 {
43 LARGE_INTEGER Offset;
44 //PVOID Buffer;
45 PVCB Vcb = (PVCB)pParam;
46 //PBCB Bcb;
47 ULONG SectorSize = 512; // FIXME: hardcoding 512 is bad
48 IO_STATUS_BLOCK IoSb;
49
50 DPRINT("FatReadBlocks %p %d %d %p\n", DestBuffer, SectorAddress, Count, pParam);
51
52 /* Calculate the offset */
53 Offset.QuadPart = Int32x32To64(SectorAddress, SectorSize);
54 #if 0
55 if (!CcMapData(Vcb->StreamFileObject,
56 &Offset,
57 Count * SectorSize,
58 TRUE,
59 &Bcb,
60 &Buffer))
61 {
62 ASSERT(FALSE);
63 /* Mapping failed */
64 return 0;
65 }
66
67 /* Copy data to the buffer */
68 RtlCopyMemory(DestBuffer, Buffer, Count * SectorSize);
69
70 /* Unpin unneeded data */
71 CcUnpinData(Bcb);
72 #else
73 CcCopyRead(Vcb->StreamFileObject, &Offset, Count * SectorSize, TRUE, DestBuffer, &IoSb);
74 #endif
75
76 /* Return amount of read data in sectors */
77 return Count;
78 }
79
80 /* EOF */