fdbd2a6845cd4e326f5e2d7dfea1a04c6aff329e
[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
49 DPRINT("FatReadBlocks %p %d %d %p\n", DestBuffer, SectorAddress, Count, pParam);
50
51 /* Calculate the offset */
52 Offset.QuadPart = Int32x32To64(SectorAddress, SectorSize);
53
54 if (!CcMapData(Vcb->StreamFileObject,
55 &Offset,
56 Count * SectorSize,
57 TRUE,
58 &Bcb,
59 &Buffer))
60 {
61 ASSERT(FALSE);
62 /* Mapping failed */
63 return 0;
64 }
65
66 /* Copy data to the buffer */
67 RtlCopyMemory(DestBuffer, Buffer, Count * SectorSize);
68
69 /* Unpin unneeded data */
70 CcUnpinData(Bcb);
71
72 /* Return amount of read data in sectors */
73 return Count;
74 }
75
76 /* EOF */