d3693d897c28b70b8693ff68b4ba314cd6d93dfd
[reactos.git] / reactos / drivers / filesystems / fastfat_new / rw.c
1 /*
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)
7 * Alexey Vlasov
8 */
9
10 /* INCLUDES *****************************************************************/
11
12 #define NDEBUG
13 #include "fastfat.h"
14
15 /* FUNCTIONS *****************************************************************/
16
17 NTSTATUS
18 NTAPI
19 FatiRead(PFAT_IRP_CONTEXT IrpContext)
20 {
21 ULONG NumberOfBytes;
22 LARGE_INTEGER ByteOffset;
23 PFILE_OBJECT FileObject;
24 TYPE_OF_OPEN OpenType;
25 PIO_STACK_LOCATION IrpSp = IrpContext->Stack;
26 PFCB Fcb;
27 PVCB Vcb;
28 PCCB Ccb;
29
30 FileObject = IrpSp->FileObject;
31 NumberOfBytes = IrpSp->Parameters.Read.Length;
32 ByteOffset = IrpSp->Parameters.Read.ByteOffset;
33 if (NumberOfBytes == 0)
34 {
35 FatCompleteRequest(IrpContext, IrpContext->Irp, STATUS_SUCCESS);
36 return STATUS_SUCCESS;
37 }
38
39 OpenType = FatDecodeFileObject(FileObject, &Vcb, &Fcb, &Ccb);
40
41 DPRINT1("FatiRead() Fcb %p, Name %wZ, Offset %d, Length %d, Handle %p\n",
42 Fcb, &FileObject->FileName, ByteOffset.LowPart, NumberOfBytes, Fcb->FatHandle);
43 return STATUS_NOT_IMPLEMENTED;
44 }
45
46 NTSTATUS
47 NTAPI
48 FatRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
49 {
50 NTSTATUS Status;
51 BOOLEAN TopLevel, CanWait;
52 PFAT_IRP_CONTEXT IrpContext;
53
54 CanWait = TRUE;
55 TopLevel = FALSE;
56 Status = STATUS_INVALID_DEVICE_REQUEST;
57 /* Get CanWait flag */
58 if (IoGetCurrentIrpStackLocation(Irp)->FileObject != NULL)
59 CanWait = IoIsOperationSynchronous(Irp);
60
61 /* Enter FsRtl critical region */
62 FsRtlEnterFileSystem();
63
64 if (DeviceObject != FatGlobalData.DiskDeviceObject)
65 {
66 /* Set Top Level IRP if not set */
67 if (IoGetTopLevelIrp() == NULL)
68 {
69 IoSetTopLevelIrp(Irp);
70 TopLevel = TRUE;
71 }
72
73 /* Build an irp context */
74 IrpContext = FatBuildIrpContext(Irp, CanWait);
75
76 /* Perform the actual read */
77 Status = FatiRead(IrpContext);
78
79 /* Restore top level Irp */
80 if (TopLevel)
81 IoSetTopLevelIrp(NULL);
82 }
83 /* Leave FsRtl critical region */
84 FsRtlExitFileSystem();
85
86 DPRINT1("FatRead()\n");
87 return Status;
88 }
89
90 NTSTATUS
91 NTAPI
92 FatWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp)
93 {
94 DPRINT1("FatWrite()\n");
95 return STATUS_NOT_IMPLEMENTED;
96 }
97
98