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  * PROJECT:         ReactOS FAT file system driver
00003  * LICENSE:         GNU GPLv3 as published by the Free Software Foundation
00004  * FILE:            drivers/filesystems/fastfat/rw.c
00005  * PURPOSE:         Read/write support
00006  * PROGRAMMERS:     Aleksey Bragin (aleksey@reactos.org)
00007  */
00008 
00009 /* INCLUDES *****************************************************************/
00010 
00011 #define NDEBUG
00012 #include "fastfat.h"
00013 
00014 /* FUNCTIONS *****************************************************************/
00015 
00016 NTSTATUS
00017 NTAPI
00018 FatiRead(PFAT_IRP_CONTEXT IrpContext)
00019 {
00020     ULONG NumberOfBytes;
00021     LARGE_INTEGER ByteOffset;
00022     PFILE_OBJECT FileObject;
00023     TYPE_OF_OPEN OpenType;
00024     PIO_STACK_LOCATION IrpSp = IrpContext->Stack;
00025     PFCB Fcb;
00026     PVCB Vcb;
00027     PCCB Ccb;
00028     PVOID Buffer;
00029     LONG BytesRead;
00030 
00031     FileObject = IrpSp->FileObject;
00032     NumberOfBytes = IrpSp->Parameters.Read.Length;
00033     ByteOffset = IrpSp->Parameters.Read.ByteOffset;
00034     if (NumberOfBytes == 0)
00035     {
00036         FatCompleteRequest(IrpContext, IrpContext->Irp, STATUS_SUCCESS);
00037         return STATUS_SUCCESS;
00038     }
00039 
00040     OpenType = FatDecodeFileObject(FileObject, &Vcb, &Fcb, &Ccb);
00041 
00042     DPRINT("FatiRead() Fcb %p, Name %wZ, Offset %d, Length %d, Handle %p\n",
00043         Fcb, &FileObject->FileName, ByteOffset.LowPart, NumberOfBytes, Fcb->FatHandle);
00044 
00045     /* Perform actual read */
00046 
00047     if (IrpContext->MinorFunction & IRP_MN_MDL)
00048     {
00049         DPRINT1("MDL read\n");
00050     }
00051     else
00052     {
00053         Buffer = FatMapUserBuffer(IrpContext->Irp);
00054         DPRINT("Normal cached read, buffer %p\n");
00055 
00056         /* Set offset */
00057         FF_Seek(Fcb->FatHandle, ByteOffset.LowPart, FF_SEEK_SET);
00058 
00059         /* Read */
00060         BytesRead = FF_Read(Fcb->FatHandle, NumberOfBytes, 1, Buffer);
00061         DPRINT("Read %d bytes\n", BytesRead);
00062 
00063         /* Indicate we read requested amount of bytes */
00064         IrpContext->Irp->IoStatus.Information = BytesRead;
00065         IrpContext->Irp->IoStatus.Status = STATUS_SUCCESS;
00066     }
00067 
00068     /* Complete the request */
00069     FatCompleteRequest(IrpContext, IrpContext->Irp, STATUS_SUCCESS);
00070     return STATUS_SUCCESS;
00071 }
00072 
00073 NTSTATUS
00074 NTAPI
00075 FatRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
00076 {
00077     NTSTATUS Status;
00078     BOOLEAN TopLevel, CanWait;
00079     PFAT_IRP_CONTEXT IrpContext;
00080 
00081     CanWait = TRUE;
00082     TopLevel = FALSE;
00083     Status = STATUS_INVALID_DEVICE_REQUEST;
00084     /* Get CanWait flag */
00085     if (IoGetCurrentIrpStackLocation(Irp)->FileObject != NULL)
00086         CanWait = IoIsOperationSynchronous(Irp);
00087 
00088     /* Enter FsRtl critical region */
00089     FsRtlEnterFileSystem();
00090 
00091     if (DeviceObject != FatGlobalData.DiskDeviceObject)
00092     {
00093         /* Set Top Level IRP if not set */
00094         TopLevel = FatIsTopLevelIrp(Irp);
00095 
00096         /* Build an irp context */
00097         IrpContext = FatBuildIrpContext(Irp, CanWait);
00098 
00099         /* Perform the actual read */
00100         Status = FatiRead(IrpContext);
00101 
00102         /* Restore top level Irp */
00103         if (TopLevel)
00104             IoSetTopLevelIrp(NULL);
00105     }
00106     /* Leave FsRtl critical region */
00107     FsRtlExitFileSystem();
00108 
00109     return Status;
00110 }
00111 
00112 NTSTATUS
00113 NTAPI
00114 FatWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp)
00115 {
00116     DPRINT1("FatWrite()\n");
00117     return STATUS_NOT_IMPLEMENTED;
00118 }
00119 
00120 

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.