Split the driver into more files.
[reactos.git] / reactos / drivers / fs / cdfs / rw.c
1 /*
2 * ReactOS kernel
3 * Copyright (C) 2002 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 /* $Id: rw.c,v 1.1 2002/04/15 20:39:49 ekohl Exp $
20 *
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
23 * FILE: services/fs/cdfs/rw.c
24 * PURPOSE: CDROM (ISO 9660) filesystem driver
25 * PROGRAMMER: Art Yerkes
26 * UPDATE HISTORY:
27 */
28
29 /* INCLUDES *****************************************************************/
30
31 #include <ddk/ntddk.h>
32
33 //#define NDEBUG
34 #include <debug.h>
35
36 #include "cdfs.h"
37
38
39 /* FUNCTIONS ****************************************************************/
40
41 static NTSTATUS
42 CdfsReadFile(PDEVICE_EXTENSION DeviceExt,
43 PFILE_OBJECT FileObject,
44 PVOID Buffer,
45 ULONG Length,
46 ULONG Offset)
47 /*
48 * FUNCTION: Reads data from a file
49 */
50 {
51 NTSTATUS Status;
52 PCCB Ccb;
53 PFCB Fcb;
54
55 DPRINT("CdfsReadFile(Offset %lu Length %lu)\n", Offset, Length);
56
57 if (Length == 0)
58 return STATUS_SUCCESS;
59
60 Ccb = (PCCB)FileObject->FsContext2;
61 Fcb = Ccb->Fcb;
62
63 if (Offset + Length > Fcb->Entry.DataLengthL)
64 Length = Fcb->Entry.DataLengthL - Offset;
65
66 DPRINT( "Reading %d bytes at %d\n", Offset, Length );
67
68 if (Length == 0)
69 return(STATUS_UNSUCCESSFUL);
70
71 Status = CdfsReadSectors(DeviceExt->StorageDevice,
72 Fcb->Entry.ExtentLocationL + Offset / BLOCKSIZE,
73 Length / BLOCKSIZE,
74 Buffer);
75
76 return(Status);
77 }
78
79
80 NTSTATUS STDCALL
81 CdfsRead(PDEVICE_OBJECT DeviceObject,
82 PIRP Irp)
83 {
84 ULONG Length;
85 PVOID Buffer;
86 ULONG Offset;
87 PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
88 PFILE_OBJECT FileObject = Stack->FileObject;
89 PDEVICE_EXTENSION DeviceExt = DeviceObject->DeviceExtension;
90 NTSTATUS Status;
91
92 DPRINT("CdfsRead(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
93
94 Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
95 Length = Stack->Parameters.Read.Length;
96 Offset = Stack->Parameters.Read.ByteOffset.u.LowPart;
97
98 Status = CdfsReadFile(DeviceExt,FileObject,Buffer,Length,Offset);
99
100 Irp->IoStatus.Status = Status;
101 Irp->IoStatus.Information = Length;
102 IoCompleteRequest(Irp,IO_NO_INCREMENT);
103 return(Status);
104 }
105
106
107 NTSTATUS STDCALL
108 CdfsWrite(PDEVICE_OBJECT DeviceObject,
109 PIRP Irp)
110 {
111 DPRINT("CdfsWrite(DeviceObject %x Irp %x)\n",DeviceObject,Irp);
112
113 Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
114 Irp->IoStatus.Information = 0;
115 return(STATUS_UNSUCCESSFUL);
116 }
117
118 /* EOF */