ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

rw.c
Go to the documentation of this file.
00001 /*
00002  *  ReactOS kernel
00003  *  Copyright (C) 2002 ReactOS Team
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
00018  *
00019  * COPYRIGHT:        See COPYING in the top level directory
00020  * PROJECT:          ReactOS kernel
00021  * FILE:             drivers/filesystem/ntfs/rw.c
00022  * PURPOSE:          CDROM (ISO 9660) filesystem driver
00023  * PROGRAMMER:       Art Yerkes
00024  * UPDATE HISTORY:
00025  */
00026 
00027 /* INCLUDES *****************************************************************/
00028 
00029 #include <ntddk.h>
00030 
00031 #define NDEBUG
00032 #include <debug.h>
00033 
00034 #include "ntfs.h"
00035 
00036 
00037 /* GLOBALS *******************************************************************/
00038 
00039 #define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S))
00040 #define ROUND_DOWN(N, S) ((N) - ((N) % (S)))
00041 
00042 
00043 /* FUNCTIONS ****************************************************************/
00044 
00045 static NTSTATUS
00046 NtfsReadFile(PDEVICE_EXTENSION DeviceExt,
00047          PFILE_OBJECT FileObject,
00048          PUCHAR Buffer,
00049          ULONG Length,
00050          ULONG ReadOffset,
00051          ULONG IrpFlags,
00052          PULONG LengthRead)
00053 /*
00054  * FUNCTION: Reads data from a file
00055  */
00056 {
00057 #if 0
00058   NTSTATUS Status = STATUS_SUCCESS;
00059   PUCHAR TempBuffer;
00060   ULONG TempLength;
00061   PCCB Ccb;
00062   PFCB Fcb;
00063 
00064   DPRINT("CdfsReadFile(ReadOffset %lu  Length %lu)\n", ReadOffset, Length);
00065 
00066   *LengthRead = 0;
00067 
00068   if (Length == 0)
00069     return(STATUS_SUCCESS);
00070 
00071   Ccb = (PCCB)FileObject->FsContext2;
00072   Fcb = (PFCB)FileObject->FsContext;
00073 
00074   if (ReadOffset >= Fcb->Entry.DataLengthL)
00075     return(STATUS_END_OF_FILE);
00076 
00077   DPRINT("Reading %d bytes at %d\n", Length, ReadOffset);
00078 
00079   if (!(IrpFlags & (IRP_NOCACHE|IRP_PAGING_IO)))
00080     {
00081       LARGE_INTEGER FileOffset;
00082       IO_STATUS_BLOCK IoStatus;
00083 
00084       if (ReadOffset + Length > Fcb->Entry.DataLengthL)
00085          Length = Fcb->Entry.DataLengthL - ReadOffset;
00086       if (FileObject->PrivateCacheMap == NULL)
00087       {
00088       CcRosInitializeFileCache(FileObject, PAGE_SIZE);
00089       }
00090 
00091       FileOffset.QuadPart = (LONGLONG)ReadOffset;
00092       CcCopyRead(FileObject,
00093          &FileOffset,
00094          Length,
00095          TRUE,
00096          Buffer,
00097          &IoStatus);
00098       *LengthRead = IoStatus.Information;
00099 
00100       return(IoStatus.Status);
00101     }
00102 
00103   if ((ReadOffset % BLOCKSIZE) != 0 || (Length % BLOCKSIZE) != 0)
00104     {
00105       return STATUS_INVALID_PARAMETER;
00106     }
00107   if (ReadOffset + Length > ROUND_UP(Fcb->Entry.DataLengthL, BLOCKSIZE))
00108     Length = ROUND_UP(Fcb->Entry.DataLengthL, BLOCKSIZE) - ReadOffset;
00109 
00110   Status = CdfsReadSectors(DeviceExt->StorageDevice,
00111                Fcb->Entry.ExtentLocationL + (ReadOffset / BLOCKSIZE),
00112                Length / BLOCKSIZE,
00113                Buffer);
00114   if (NT_SUCCESS(Status))
00115     {
00116       *LengthRead = Length;
00117       if (Length + ReadOffset > Fcb->Entry.DataLengthL)
00118       {
00119     memset(Buffer + Fcb->Entry.DataLengthL - ReadOffset,
00120            0, Length + ReadOffset - Fcb->Entry.DataLengthL);
00121       }
00122     }
00123 
00124   return(Status);
00125 #else
00126   *LengthRead = 0;
00127   return STATUS_END_OF_FILE;
00128 #endif
00129 }
00130 
00131 
00132 NTSTATUS NTAPI
00133 NtfsFsdRead(PDEVICE_OBJECT DeviceObject,
00134      PIRP Irp)
00135 {
00136   PDEVICE_EXTENSION DeviceExt;
00137   PIO_STACK_LOCATION Stack;
00138   PFILE_OBJECT FileObject;
00139   PVOID Buffer;
00140   ULONG ReadLength;
00141   LARGE_INTEGER ReadOffset;
00142   ULONG ReturnedReadLength = 0;
00143   NTSTATUS Status = STATUS_SUCCESS;
00144 
00145   DPRINT("NtfsRead(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
00146 
00147   DeviceExt = DeviceObject->DeviceExtension;
00148   Stack = IoGetCurrentIrpStackLocation(Irp);
00149   FileObject = Stack->FileObject;
00150 
00151   ReadLength = Stack->Parameters.Read.Length;
00152   ReadOffset = Stack->Parameters.Read.ByteOffset;
00153   Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
00154 
00155   Status = NtfsReadFile(DeviceExt,
00156             FileObject,
00157             Buffer,
00158             ReadLength,
00159             ReadOffset.u.LowPart,
00160             Irp->Flags,
00161             &ReturnedReadLength);
00162 
00163   if (NT_SUCCESS(Status))
00164     {
00165       if (FileObject->Flags & FO_SYNCHRONOUS_IO)
00166     {
00167       FileObject->CurrentByteOffset.QuadPart =
00168         ReadOffset.QuadPart + ReturnedReadLength;
00169     }
00170       Irp->IoStatus.Information = ReturnedReadLength;
00171     }
00172   else
00173     {
00174       Irp->IoStatus.Information = 0;
00175     }
00176 
00177   Irp->IoStatus.Status = Status;
00178   IoCompleteRequest(Irp,IO_NO_INCREMENT);
00179 
00180   return(Status);
00181 }
00182 
00183 
00184 NTSTATUS NTAPI
00185 NtfsFsdWrite(PDEVICE_OBJECT DeviceObject,
00186       PIRP Irp)
00187 {
00188   DPRINT("NtfwWrite(DeviceObject %x Irp %x)\n",DeviceObject,Irp);
00189 
00190   Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
00191   Irp->IoStatus.Information = 0;
00192   return(STATUS_NOT_SUPPORTED);
00193 }
00194 
00195 /* EOF */

Generated on Sun May 27 2012 04:24:27 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.