2 * PROJECT: ReactOS FAT file system driver
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: drivers/filesystems/fastfat/rw.c
5 * PURPOSE: Read/write support
6 * PROGRAMMERS: Aleksey Bragin (aleksey@reactos.org)
10 /* INCLUDES *****************************************************************/
15 /* FUNCTIONS *****************************************************************/
19 FatiRead(PFAT_IRP_CONTEXT IrpContext
)
22 LARGE_INTEGER ByteOffset
;
23 PFILE_OBJECT FileObject
;
24 TYPE_OF_OPEN OpenType
;
25 PIO_STACK_LOCATION IrpSp
= IrpContext
->Stack
;
32 FileObject
= IrpSp
->FileObject
;
33 NumberOfBytes
= IrpSp
->Parameters
.Read
.Length
;
34 ByteOffset
= IrpSp
->Parameters
.Read
.ByteOffset
;
35 if (NumberOfBytes
== 0)
37 FatCompleteRequest(IrpContext
, IrpContext
->Irp
, STATUS_SUCCESS
);
38 return STATUS_SUCCESS
;
41 OpenType
= FatDecodeFileObject(FileObject
, &Vcb
, &Fcb
, &Ccb
);
43 DPRINT1("FatiRead() Fcb %p, Name %wZ, Offset %d, Length %d, Handle %p\n",
44 Fcb
, &FileObject
->FileName
, ByteOffset
.LowPart
, NumberOfBytes
, Fcb
->FatHandle
);
46 /* Perform actual read */
48 if (IrpContext
->MinorFunction
& IRP_MN_MDL
)
50 DPRINT1("MDL read\n");
54 Buffer
= FatMapUserBuffer(IrpContext
->Irp
);
55 DPRINT1("Normal cached read, buffer %p\n");
57 BytesRead
= FF_Read(Fcb
->FatHandle
, NumberOfBytes
, 1, Buffer
);
58 DPRINT1("Read %d bytes\n", BytesRead
);
60 /* Indicate we read requested amount of bytes */
61 IrpContext
->Irp
->IoStatus
.Information
= BytesRead
;
62 IrpContext
->Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
65 /* Complete the request */
66 FatCompleteRequest(IrpContext
, IrpContext
->Irp
, STATUS_SUCCESS
);
67 return STATUS_SUCCESS
;
72 FatRead(PDEVICE_OBJECT DeviceObject
, PIRP Irp
)
75 BOOLEAN TopLevel
, CanWait
;
76 PFAT_IRP_CONTEXT IrpContext
;
80 Status
= STATUS_INVALID_DEVICE_REQUEST
;
81 /* Get CanWait flag */
82 if (IoGetCurrentIrpStackLocation(Irp
)->FileObject
!= NULL
)
83 CanWait
= IoIsOperationSynchronous(Irp
);
85 /* Enter FsRtl critical region */
86 FsRtlEnterFileSystem();
88 if (DeviceObject
!= FatGlobalData
.DiskDeviceObject
)
90 /* Set Top Level IRP if not set */
91 if (IoGetTopLevelIrp() == NULL
)
93 IoSetTopLevelIrp(Irp
);
97 /* Build an irp context */
98 IrpContext
= FatBuildIrpContext(Irp
, CanWait
);
100 /* Perform the actual read */
101 Status
= FatiRead(IrpContext
);
103 /* Restore top level Irp */
105 IoSetTopLevelIrp(NULL
);
107 /* Leave FsRtl critical region */
108 FsRtlExitFileSystem();
110 DPRINT1("FatRead()\n");
116 FatWrite(PDEVICE_OBJECT DeviceObject
, PIRP Irp
)
118 DPRINT1("FatWrite()\n");
119 return STATUS_NOT_IMPLEMENTED
;