ReactOS  0.4.13-dev-479-gec9c8fd
read.c File Reference
#include "ntifs.h"
#include "ffsdrv.h"
Include dependency graph for read.c:

Go to the source code of this file.

Functions

NTSTATUS FFSReadComplete (IN PFFS_IRP_CONTEXT IrpContext)
 
__drv_mustHoldCriticalRegion NTSTATUS FFSReadFile (IN PFFS_IRP_CONTEXT IrpContext)
 
__drv_mustHoldCriticalRegion NTSTATUS FFSReadVolume (IN PFFS_IRP_CONTEXT IrpContext)
 
__drv_mustHoldCriticalRegion NTSTATUS FFSCompleteIrpContext (IN PFFS_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
 
BOOLEAN FFSCopyRead (IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus)
 
NTSTATUS FFSv1ReadInode (IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN PFFSv1_INODE dinode1, IN ULONGLONG offset, IN PVOID Buffer, IN ULONG size, OUT PULONG dwRet)
 
NTSTATUS FFSv2ReadInode (IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN PFFSv2_INODE dinode2, IN ULONGLONG offset, IN PVOID Buffer, IN ULONG size, OUT PULONG dwRet)
 
__drv_mustHoldCriticalRegion NTSTATUS FFSRead (IN PFFS_IRP_CONTEXT IrpContext)
 

Variables

PFFS_GLOBAL FFSGlobal
 

Function Documentation

◆ FFSCompleteIrpContext()

__drv_mustHoldCriticalRegion NTSTATUS FFSCompleteIrpContext ( IN PFFS_IRP_CONTEXT  IrpContext,
IN NTSTATUS  Status 
)

Definition at line 53 of file read.c.

56 {
57  PIRP Irp = NULL;
58  BOOLEAN bPrint;
59 
60  PAGED_CODE();
61 
62  Irp = IrpContext->Irp;
63 
64  if (Irp != NULL)
65  {
66  if (NT_ERROR(Status))
67  {
68  Irp->IoStatus.Information = 0;
69  }
70 
71  Irp->IoStatus.Status = Status;
72  bPrint = !IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_REQUEUED);
73 
75  Irp, bPrint, (CCHAR)(NT_SUCCESS(Status)?
77 
78  IrpContext->Irp = NULL;
79  }
80 
81  FFSFreeIrpContext(IrpContext);
82 
83  return Status;
84 }
_In_ PIRP Irp
Definition: csq.h:116
__drv_mustHoldCriticalRegion VOID FFSFreeIrpContext(IN PFFS_IRP_CONTEXT IrpContext)
Definition: memory.c:179
#define FFSCompleteRequest(Irp, bPrint, PriorityBoost)
Definition: ffsdrv.h:1049
#define PAGED_CODE()
Definition: video.h:57
#define IO_DISK_INCREMENT
Definition: iotypes.h:567
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
char CCHAR
Definition: typedefs.h:50
#define NT_ERROR(Status)
Definition: umtypes.h:106
Status
Definition: gdiplustypes.h:24
#define IRP_CONTEXT_FLAG_REQUEUED
Definition: ext2fs.h:1085
#define IO_NO_INCREMENT
Definition: iotypes.h:565

Referenced by FFSAllowExtendedDasdIo(), FFSCleanup(), FFSClose(), FFSCreate(), FFSDeviceControlNormal(), FFSDirectoryControl(), FFSDismountVolume(), FFSDispatchRequest(), FFSFileSystemControl(), FFSFlush(), FFSInvalidateVolumes(), FFSLockControl(), FFSLockVolume(), FFSMountVolume(), FFSNotifyChangeDirectory(), FFSQueryDirectory(), FFSQueryInformation(), FFSQueryVolumeInformation(), FFSRead(), FFSReadComplete(), FFSReadFile(), FFSReadVolume(), FFSSelectBSDPartition(), FFSSetInformation(), FFSSetVolumeInformation(), FFSShutDown(), FFSUnlockVolume(), FFSUserFsRequest(), FFSVerifyVolume(), FFSWrite(), FFSWriteComplete(), FFSWriteFile(), and FFSWriteVolume().

◆ FFSCopyRead()

BOOLEAN FFSCopyRead ( IN PFILE_OBJECT  FileObject,
IN PLARGE_INTEGER  FileOffset,
IN ULONG  Length,
IN BOOLEAN  Wait,
OUT PVOID  Buffer,
OUT PIO_STATUS_BLOCK  IoStatus 
)

Definition at line 88 of file read.c.

95 {
96  BOOLEAN bRet;
97 
98  PAGED_CODE();
99 
100  bRet = CcCopyRead(FileObject,
101  FileOffset,
102  Length,
103  Wait,
104  Buffer,
105  IoStatus);
106 
107  if (bRet)
108  {
109  ASSERT(NT_SUCCESS(IoStatus->Status));
110  }
111 
112  return bRet;
113 /*
114  PVOID Bcb = NULL;
115  PVOID Buf = NULL;
116 
117  if (CcMapData(FileObject,
118  FileOffset,
119  Length,
120  Wait,
121  &Bcb,
122  &Buf))
123  {
124  RtlCopyMemory(Buffer, Buf, Length);
125  IoStatus->Status = STATUS_SUCCESS;
126  IoStatus->Information = Length;
127  CcUnpinData(Bcb);
128  return TRUE;
129 
130  }
131  else
132  {
133  // IoStatus->Status = STATUS_
134  return FALSE;
135  }
136 */
137 }
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
#define PAGED_CODE()
Definition: video.h:57
unsigned char BOOLEAN
Definition: bufpool.h:45
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
BOOLEAN NTAPI CcCopyRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus)
Definition: copysup.c:43
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:151
IN BOOLEAN Wait
Definition: fatprocs.h:1529

Referenced by FFSv1LoadBlock(), FFSv1LoadInode(), FFSv1ReadInode(), FFSv2LoadBlock(), FFSv2LoadInode(), and FFSv2ReadInode().

◆ FFSRead()

Definition at line 1068 of file read.c.

1070 {
1071  NTSTATUS Status;
1072  PFFS_VCB Vcb;
1073  PFFS_FCBVCB FcbOrVcb;
1076  BOOLEAN bCompleteRequest;
1077 
1078  PAGED_CODE();
1079 
1080  ASSERT(IrpContext);
1081 
1082  ASSERT((IrpContext->Identifier.Type == FFSICX) &&
1083  (IrpContext->Identifier.Size == sizeof(FFS_IRP_CONTEXT)));
1084  _SEH2_TRY
1085  {
1086 
1087  if (FlagOn(IrpContext->MinorFunction, IRP_MN_COMPLETE))
1088  {
1089  Status = FFSReadComplete(IrpContext);
1090  bCompleteRequest = FALSE;
1091  }
1092  else
1093  {
1094  DeviceObject = IrpContext->DeviceObject;
1095 
1097  {
1099  bCompleteRequest = TRUE;
1100  _SEH2_LEAVE;
1101  }
1102 
1104 
1105  if (Vcb->Identifier.Type != FFSVCB ||
1106  Vcb->Identifier.Size != sizeof(FFS_VCB))
1107  {
1109  bCompleteRequest = TRUE;
1110 
1111  _SEH2_LEAVE;
1112  }
1113 
1114  if (IsFlagOn(Vcb->Flags, VCB_DISMOUNT_PENDING))
1115  {
1117  bCompleteRequest = TRUE;
1118  _SEH2_LEAVE;
1119  }
1120 
1121  FileObject = IrpContext->FileObject;
1122 
1123  FcbOrVcb = (PFFS_FCBVCB)FileObject->FsContext;
1124 
1125  if (FcbOrVcb->Identifier.Type == FFSVCB)
1126  {
1127  Status = FFSReadVolume(IrpContext);
1128  bCompleteRequest = FALSE;
1129  }
1130  else if (FcbOrVcb->Identifier.Type == FFSFCB)
1131  {
1132  Status = FFSReadFile(IrpContext);
1133  bCompleteRequest = FALSE;
1134  }
1135  else
1136  {
1137  FFSPrint((DBG_ERROR, "FFSRead: INVALID PARAMETER ... \n"));
1138  FFSBreakPoint();
1139 
1141  bCompleteRequest = TRUE;
1142  }
1143  }
1144  }
1145 
1147  {
1148  if (bCompleteRequest)
1149  {
1150  FFSCompleteIrpContext(IrpContext, Status);
1151  }
1152  } _SEH2_END;
1153 
1154  return Status;
1155 }
Definition: ffsdrv.h:281
#define TRUE
Definition: types.h:120
PFFS_GLOBAL FFSGlobal
Definition: init.c:22
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
__drv_mustHoldCriticalRegion NTSTATUS FFSReadFile(IN PFFS_IRP_CONTEXT IrpContext)
Definition: read.c:675
NTSTATUS FFSReadComplete(IN PFFS_IRP_CONTEXT IrpContext)
Definition: read.c:1027
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
Definition: ffsdrv.h:283
PDEVICE_OBJECT DeviceObject
Definition: ffsdrv.h:371
#define PAGED_CODE()
Definition: video.h:57
_SEH2_TRY
Definition: create.c:4250
#define FFSBreakPoint()
Definition: ffsdrv.h:43
#define IRP_MN_COMPLETE
Definition: iotypes.h:4063
__drv_mustHoldCriticalRegion NTSTATUS FFSReadVolume(IN PFFS_IRP_CONTEXT IrpContext)
Definition: read.c:142
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
struct _FFS_VCB * PFFS_VCB
FFS_IDENTIFIER_TYPE Type
Definition: ffsdrv.h:294
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
struct _FFS_FCBVCB * PFFS_FCBVCB
__drv_mustHoldCriticalRegion NTSTATUS FFSCompleteIrpContext(IN PFFS_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:53
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define Vcb
Definition: cdprocs.h:1425
* PFILE_OBJECT
Definition: iotypes.h:1954
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
FFS_IDENTIFIER Identifier
Definition: ffsdrv.h:426
#define VCB_DISMOUNT_PENDING
Definition: ext2fs.h:782
Definition: ffsdrv.h:280
#define DBG_ERROR
Definition: ffsdrv.h:1031
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
Status
Definition: gdiplustypes.h:24
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
_SEH2_END
Definition: create.c:4424
_SEH2_FINALLY
Definition: create.c:4395
#define _SEH2_LEAVE
Definition: filesup.c:20
#define STATUS_TOO_LATE
Definition: ntstatus.h:612

Referenced by FFSDispatchRequest().

◆ FFSReadComplete()

__drv_mustHoldCriticalRegion NTSTATUS FFSReadComplete ( IN PFFS_IRP_CONTEXT  IrpContext)

Definition at line 1027 of file read.c.

1029 {
1032  PIRP Irp;
1033 
1034  PAGED_CODE();
1035 
1036  _SEH2_TRY
1037  {
1038  ASSERT(IrpContext);
1039 
1040  ASSERT((IrpContext->Identifier.Type == FFSICX) &&
1041  (IrpContext->Identifier.Size == sizeof(FFS_IRP_CONTEXT)));
1042 
1043  FileObject = IrpContext->FileObject;
1044 
1045  Irp = IrpContext->Irp;
1046 
1047  CcMdlReadComplete(FileObject, Irp->MdlAddress);
1048 
1049  Irp->MdlAddress = NULL;
1050 
1052  }
1053 
1055  {
1056  if (!IrpContext->ExceptionInProgress)
1057  {
1058  FFSCompleteIrpContext(IrpContext, Status);
1059  }
1060  } _SEH2_END;
1061 
1062  return Status;
1063 }
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
Definition: ffsdrv.h:283
#define PAGED_CODE()
Definition: video.h:57
_SEH2_TRY
Definition: create.c:4250
VOID NTAPI CcMdlReadComplete(IN PFILE_OBJECT FileObject, IN PMDL MdlChain)
Definition: mdlsup.c:75
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
__drv_mustHoldCriticalRegion NTSTATUS FFSCompleteIrpContext(IN PFFS_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:53
* PFILE_OBJECT
Definition: iotypes.h:1954
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Status
Definition: gdiplustypes.h:24
_SEH2_END
Definition: create.c:4424
_SEH2_FINALLY
Definition: create.c:4395
return STATUS_SUCCESS
Definition: btrfs.c:2777

Referenced by FFSRead().

◆ FFSReadFile()

Definition at line 675 of file read.c.

677 {
679 
680  PFFS_VCB Vcb;
681  PFFS_FCB Fcb = 0;
682  PFFS_CCB Ccb;
684  PFILE_OBJECT CacheObject;
685 
687 
688  PIRP Irp;
689  PIO_STACK_LOCATION IoStackLocation;
690 
691  ULONG Length;
694 
695  BOOLEAN PagingIo;
696  BOOLEAN Nocache;
697  BOOLEAN SynchronousIo;
698  BOOLEAN MainResourceAcquired = FALSE;
699  BOOLEAN PagingIoResourceAcquired = FALSE;
700 
701  PUCHAR Buffer;
702 
703  PAGED_CODE();
704 
705  _SEH2_TRY
706  {
707  ASSERT(IrpContext);
708 
709  ASSERT((IrpContext->Identifier.Type == FFSICX) &&
710  (IrpContext->Identifier.Size == sizeof(FFS_IRP_CONTEXT)));
711 
712  DeviceObject = IrpContext->DeviceObject;
713 
715 
716  ASSERT(Vcb != NULL);
717 
718  ASSERT((Vcb->Identifier.Type == FFSVCB) &&
719  (Vcb->Identifier.Size == sizeof(FFS_VCB)));
720 
721  FileObject = IrpContext->FileObject;
722 
723  Fcb = (PFFS_FCB)FileObject->FsContext;
724 
725  ASSERT(Fcb);
726 
727  ASSERT((Fcb->Identifier.Type == FFSFCB) &&
728  (Fcb->Identifier.Size == sizeof(FFS_FCB)));
729 
730  Ccb = (PFFS_CCB)FileObject->FsContext2;
731 
732  Irp = IrpContext->Irp;
733 
734  IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
735 
736  Length = IoStackLocation->Parameters.Read.Length;
737  ByteOffset = IoStackLocation->Parameters.Read.ByteOffset;
738 
739  PagingIo = (Irp->Flags & IRP_PAGING_IO ? TRUE : FALSE);
740  Nocache = (Irp->Flags & IRP_NOCACHE ? TRUE : FALSE);
741  SynchronousIo = (FileObject->Flags & FO_SYNCHRONOUS_IO ? TRUE : FALSE);
742 
743 #if 0
744 /*
745  if (IsFlagOn(Fcb->Flags, FCB_FILE_DELETED))
746  {
747  Status = STATUS_FILE_DELETED;
748  _SEH2_LEAVE;
749  }
750 
751  if (IsFlagOn(Fcb->Flags, FCB_DELETE_PENDING))
752  {
753  Status = STATUS_DELETE_PENDING;
754  _SEH2_LEAVE;
755  }
756 */
757 #endif
758 
759  if (Length == 0)
760  {
761  Irp->IoStatus.Information = 0;
763  _SEH2_LEAVE;
764  }
765 
766  if (Nocache &&
767  (ByteOffset.LowPart & (SECTOR_SIZE - 1) ||
768  Length & (SECTOR_SIZE - 1)))
769  {
771  FFSBreakPoint();
772  _SEH2_LEAVE;
773  }
774 
775  if (FlagOn(IrpContext->MinorFunction, IRP_MN_DPC))
776  {
777  ClearFlag(IrpContext->MinorFunction, IRP_MN_DPC);
779  FFSBreakPoint();
780  _SEH2_LEAVE;
781  }
782 
783  if (!PagingIo)
784  {
786  &Fcb->MainResource,
787  IrpContext->IsSynchronous))
788  {
790  _SEH2_LEAVE;
791  }
792 
793  MainResourceAcquired = TRUE;
794 
796  &Fcb->FileLockAnchor,
797  Irp))
798  {
800  _SEH2_LEAVE;
801  }
802  }
803  else
804  {
807  IrpContext->IsSynchronous))
808  {
810  _SEH2_LEAVE;
811  }
812 
813  PagingIoResourceAcquired = TRUE;
814  }
815 
816  if (!Nocache)
817  {
818  if ((ByteOffset.QuadPart + (LONGLONG)Length) >
819  Fcb->Header.FileSize.QuadPart)
820  {
821  if (ByteOffset.QuadPart >= (Fcb->Header.FileSize.QuadPart))
822  {
823  Irp->IoStatus.Information = 0;
825  _SEH2_LEAVE;
826  }
827 
828  Length =
829  (ULONG)(Fcb->Header.FileSize.QuadPart - ByteOffset.QuadPart);
830 
831  }
832 
834 
835  if (IsDirectory(Fcb))
836  {
837  _SEH2_LEAVE;
838  }
839 
840  {
841  if (FileObject->PrivateCacheMap == NULL)
842  {
844  FileObject,
845  (PCC_FILE_SIZES)(&Fcb->Header.AllocationSize),
846  FALSE,
848  Fcb);
849  }
850 
851  CacheObject = FileObject;
852  }
853 
854  if (FlagOn(IrpContext->MinorFunction, IRP_MN_MDL))
855  {
856  CcMdlRead(
857  CacheObject,
858  (&ByteOffset),
859  Length,
860  &Irp->MdlAddress,
861  &Irp->IoStatus);
862 
863  Status = Irp->IoStatus.Status;
864  }
865  else
866  {
868 
869  if (Buffer == NULL)
870  {
872  FFSBreakPoint();
873  _SEH2_LEAVE;
874  }
875 
876  if (!CcCopyRead(
877  CacheObject,
879  Length,
880  IrpContext->IsSynchronous,
881  Buffer,
882  &Irp->IoStatus))
883  {
885  FFSBreakPoint();
886  _SEH2_LEAVE;
887  }
888 
889  Status = Irp->IoStatus.Status;
890  }
891  }
892  else
893  {
894  /* ByteOffset과 AllocationSize 모두 0이 아닐때 */
895  if (ByteOffset.QuadPart && Fcb->Header.AllocationSize.QuadPart)
896  {
897  if ((ByteOffset.QuadPart + (LONGLONG)Length) > Fcb->Header.AllocationSize.QuadPart)
898  {
899 
900  if (ByteOffset.QuadPart >= Fcb->Header.AllocationSize.QuadPart)
901  {
902  Irp->IoStatus.Information = 0;
904  FFSBreakPoint();
905  _SEH2_LEAVE;
906  }
907 
908  Length =
909  (ULONG)(Fcb->Header.AllocationSize.QuadPart- ByteOffset.QuadPart);
910  }
911  }
912 
914 
916  IrpContext->Irp,
917  Length,
918  IoWriteAccess);
919 
920  if (!NT_SUCCESS(Status))
921  {
922  _SEH2_LEAVE;
923  }
924 
925  Irp->IoStatus.Status = STATUS_SUCCESS;
926  Irp->IoStatus.Information = Length;
927 
928  if (FS_VERSION == 1)
929  {
930  Status =
932  IrpContext,
933  Vcb,
934  Fcb->dinode1,
935  ByteOffset.QuadPart,
936  NULL,
937  Length,
938  &ReturnedLength);
939  }
940  else
941  {
942  Status =
944  IrpContext,
945  Vcb,
946  Fcb->dinode2,
947  ByteOffset.QuadPart,
948  NULL,
949  Length,
950  &ReturnedLength);
951  }
952 
953  Irp = IrpContext->Irp;
954 
955  }
956  }
957 
959  {
960  if (PagingIoResourceAcquired)
961  {
965  }
966 
967  if (MainResourceAcquired)
968  {
970  &Fcb->MainResource,
972  }
973 
974  if (!IrpContext->ExceptionInProgress)
975  {
976  if (IrpContext->Irp)
977  {
978  if (Status == STATUS_PENDING)
979  {
981  IrpContext->Irp,
982  Length,
983  IoWriteAccess);
984 
985  if (NT_SUCCESS(Status))
986  {
987  Status = FFSQueueRequest(IrpContext);
988  }
989  else
990  {
991  FFSCompleteIrpContext(IrpContext, Status);
992  }
993  }
994  else
995  {
996  if (NT_SUCCESS(Status))
997  {
998  if (SynchronousIo && !PagingIo)
999  {
1000  IrpContext->FileObject->CurrentByteOffset.QuadPart =
1001  ByteOffset.QuadPart + IrpContext->Irp->IoStatus.Information;
1002  }
1003 
1004  if (!PagingIo)
1005  {
1006  IrpContext->FileObject->Flags &= ~FO_FILE_FAST_IO_READ;
1007  }
1008  }
1009 
1010  FFSCompleteIrpContext(IrpContext, Status);
1011  }
1012  }
1013  else
1014  {
1015  FFSFreeIrpContext(IrpContext);
1016  }
1017  }
1018  } _SEH2_END;
1019 
1020  return Status;
1021 
1022 }
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
NTSTATUS FFSQueueRequest(IN PFFS_IRP_CONTEXT IrpContext)
Definition: dispatch.c:33
Definition: ffsdrv.h:281
VOID NTAPI CcMdlRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, OUT PMDL *MdlChain, OUT PIO_STATUS_BLOCK IoStatus)
Definition: mdlsup.c:64
#define TRUE
Definition: types.h:120
#define FS_VERSION
Definition: ffsdrv.h:81
FSRTL_ADVANCED_FCB_HEADER Header
Definition: cdstruc.h:931
PFILE_OBJECT FileObject
Definition: ntfs.h:504
PFFS_GLOBAL FFSGlobal
Definition: init.c:22
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
#define IRP_NOCACHE
__drv_mustHoldCriticalRegion VOID FFSFreeIrpContext(IN PFFS_IRP_CONTEXT IrpContext)
Definition: memory.c:179
Definition: ffsdrv.h:283
NTSTATUS FFSLockUserBuffer(IN PIRP Irp, IN ULONG Length, IN LOCK_OPERATION Operation)
Definition: block.c:70
struct _FFS_FCB * PFFS_FCB
#define PAGED_CODE()
Definition: video.h:57
_SEH2_TRY
Definition: create.c:4250
#define FFSBreakPoint()
Definition: ffsdrv.h:43
#define STATUS_END_OF_FILE
Definition: shellext.h:62
#define FO_SYNCHRONOUS_IO
Definition: iotypes.h:1732
NTFSIDENTIFIER Identifier
Definition: ntfs.h:499
#define SECTOR_SIZE
Definition: winldr.h:34
#define FO_FILE_FAST_IO_READ
Definition: iotypes.h:1751
#define STATUS_INVALID_USER_BUFFER
Definition: udferr_usr.h:166
PVOID FFSGetUserBuffer(IN PIRP Irp)
Definition: block.c:115
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
struct _FFS_VCB * PFFS_VCB
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
__drv_mustHoldCriticalRegion NTSTATUS FFSCompleteIrpContext(IN PFFS_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:53
int64_t LONGLONG
Definition: typedefs.h:66
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
VOID NTAPI CcInitializeCacheMap(IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes, IN BOOLEAN PinAccess, IN PCACHE_MANAGER_CALLBACKS Callbacks, IN PVOID LazyWriteContext)
Definition: fssup.c:193
BOOLEAN NTAPI FsRtlCheckLockForReadAccess(IN PFILE_LOCK FileLock, IN PIRP Irp)
Definition: filelock.c:676
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
NTSTATUS FFSv1ReadInode(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN PFFSv1_INODE dinode1, IN ULONGLONG offset, IN PVOID Buffer, IN ULONG size, OUT PULONG dwRet)
Definition: read.c:496
* PFILE_OBJECT
Definition: iotypes.h:1954
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
BOOLEAN NTAPI CcCopyRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus)
Definition: copysup.c:43
_Must_inspect_result_ _In_ PFLT_INSTANCE _Out_ PBOOLEAN IsDirectory
Definition: fltkernel.h:1139
ULONG Type
Definition: ntfs.h:95
#define IRP_MN_MDL
Definition: iotypes.h:4062
_In_ ULONG _In_ BATTERY_QUERY_INFORMATION_LEVEL _In_ LONG _In_ ULONG _Out_ PULONG ReturnedLength
Definition: batclass.h:187
Definition: ffsdrv.h:280
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:593
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
ERESOURCE MainResource
Definition: ntfs.h:512
NTSTATUS FFSv2ReadInode(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN PFFSv2_INODE dinode2, IN ULONGLONG offset, IN PVOID Buffer, IN ULONG size, OUT PULONG dwRet)
Definition: read.c:585
ClearFlag(Dirent->Flags, DIRENT_FLAG_NOT_PERSISTENT)
Status
Definition: gdiplustypes.h:24
#define IRP_MN_DPC
Definition: iotypes.h:4061
struct _FFS_CCB * PFFS_CCB
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
_SEH2_END
Definition: create.c:4424
_SEH2_FINALLY
Definition: create.c:4395
#define IRP_PAGING_IO
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
#define STATUS_FILE_LOCK_CONFLICT
Definition: ntstatus.h:306
unsigned int ULONG
Definition: retypes.h:1
ERESOURCE PagingIoResource
Definition: ntfs.h:511
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
#define _SEH2_LEAVE
Definition: filesup.c:20
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
_In_ PFCB Fcb
Definition: cdprocs.h:151
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2777
ULONG Size
Definition: ntfs.h:96
CACHE_MANAGER_CALLBACKS CacheManagerCallbacks
Definition: ffsdrv.h:364
IN PDCB IN PCCB IN VBO IN OUT PULONG OUT PDIRENT OUT PBCB OUT PVBO ByteOffset
Definition: fatprocs.h:716

Referenced by FFSRead().

◆ FFSReadVolume()

Definition at line 142 of file read.c.

144 {
146 
147  PFFS_VCB Vcb = 0;
148  PFFS_CCB Ccb;
149  PFFS_FCBVCB FcbOrVcb;
151 
153 
154  PIRP Irp;
155  PIO_STACK_LOCATION IoStackLocation;
156 
157  ULONG Length;
159 
160  BOOLEAN PagingIo;
161  BOOLEAN Nocache;
162  BOOLEAN SynchronousIo;
163  BOOLEAN MainResourceAcquired = FALSE;
164  BOOLEAN PagingIoResourceAcquired = FALSE;
165 
166  PUCHAR Buffer = NULL;
167  PFFS_BDL ffs_bdl = NULL;
168 
169  PAGED_CODE();
170 
171  _SEH2_TRY
172  {
173  ASSERT(IrpContext);
174 
175  ASSERT((IrpContext->Identifier.Type == FFSICX) &&
176  (IrpContext->Identifier.Size == sizeof(FFS_IRP_CONTEXT)));
177 
178  DeviceObject = IrpContext->DeviceObject;
179 
181 
182  ASSERT(Vcb != NULL);
183 
184  ASSERT((Vcb->Identifier.Type == FFSVCB) &&
185  (Vcb->Identifier.Size == sizeof(FFS_VCB)));
186 
187  FileObject = IrpContext->FileObject;
188 
189  FcbOrVcb = (PFFS_FCBVCB)FileObject->FsContext;
190 
191  ASSERT(FcbOrVcb);
192 
193  if (!(FcbOrVcb->Identifier.Type == FFSVCB && (PVOID)FcbOrVcb == (PVOID)Vcb))
194  {
196  _SEH2_LEAVE;
197  }
198 
199  Ccb = (PFFS_CCB)FileObject->FsContext2;
200 
201  Irp = IrpContext->Irp;
202 
203  Irp->IoStatus.Information = 0;
204 
205  IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
206 
207  Length = IoStackLocation->Parameters.Read.Length;
208  ByteOffset = IoStackLocation->Parameters.Read.ByteOffset;
209 
210  PagingIo = (Irp->Flags & IRP_PAGING_IO ? TRUE : FALSE);
211  Nocache = (Irp->Flags & IRP_NOCACHE ? TRUE : FALSE);
212  SynchronousIo = (FileObject->Flags & FO_SYNCHRONOUS_IO ? TRUE : FALSE);
213 
214  if (Length == 0)
215  {
216  Irp->IoStatus.Information = 0;
218  _SEH2_LEAVE;
219  }
220 
221  if (Ccb != NULL)
222  {
224  {
225  if (ByteOffset.QuadPart + Length > Vcb->Header.FileSize.QuadPart)
226  {
227  Length = (ULONG)(Vcb->Header.FileSize.QuadPart - ByteOffset.QuadPart);
228  }
229  }
230 
231  {
232  FFS_BDL BlockArray;
233 
234  if ((ByteOffset.LowPart & (SECTOR_SIZE - 1)) ||
235  (Length & (SECTOR_SIZE - 1)))
236  {
238  _SEH2_LEAVE;
239  }
240 
242  IrpContext->Irp,
243  Length,
244  IoReadAccess);
245 
246  if (!NT_SUCCESS(Status))
247  {
248  _SEH2_LEAVE;
249  }
250 
251  BlockArray.Irp = NULL;
252  BlockArray.Lba = ByteOffset.QuadPart;;
253  BlockArray.Offset = 0;
254  BlockArray.Length = Length;
255 
256  Status = FFSReadWriteBlocks(IrpContext,
257  Vcb,
258  &BlockArray,
259  Length,
260  1,
261  FALSE);
262  Irp = IrpContext->Irp;
263 
264  _SEH2_LEAVE;
265  }
266  }
267 
268  if (Nocache &&
269  ((ByteOffset.LowPart & (SECTOR_SIZE - 1)) ||
270  (Length & (SECTOR_SIZE - 1))))
271  {
272  FFSBreakPoint();
273 
275  _SEH2_LEAVE;
276  }
277 
278  if (FlagOn(IrpContext->MinorFunction, IRP_MN_DPC))
279  {
280  ClearFlag(IrpContext->MinorFunction, IRP_MN_DPC);
282  _SEH2_LEAVE;
283  }
284 
285  if (!PagingIo)
286  {
288  &Vcb->MainResource,
289  IrpContext->IsSynchronous))
290  {
292  _SEH2_LEAVE;
293  }
294 
295  MainResourceAcquired = TRUE;
296  }
297  else
298  {
300  &Vcb->PagingIoResource,
301  IrpContext->IsSynchronous))
302  {
304  _SEH2_LEAVE;
305  }
306 
307  PagingIoResourceAcquired = TRUE;
308  }
309 
310 
311  if (ByteOffset.QuadPart >=
312  Vcb->PartitionInformation.PartitionLength.QuadPart)
313  {
314  Irp->IoStatus.Information = 0;
316  _SEH2_LEAVE;
317  }
318 
319  if (!Nocache)
320  {
321  if ((ByteOffset.QuadPart + Length) >
322  Vcb->PartitionInformation.PartitionLength.QuadPart)
323  {
324  Length = (ULONG)(
325  Vcb->PartitionInformation.PartitionLength.QuadPart -
326  ByteOffset.QuadPart);
327  Length &= ~((ULONG)SECTOR_SIZE - 1);
328  }
329 
330  if (FlagOn(IrpContext->MinorFunction, IRP_MN_MDL))
331  {
332  CcMdlRead(
333  Vcb->StreamObj,
334  &ByteOffset,
335  Length,
336  &Irp->MdlAddress,
337  &Irp->IoStatus);
338 
339  Status = Irp->IoStatus.Status;
340  }
341  else
342  {
344 
345  if (Buffer == NULL)
346  {
347  FFSBreakPoint();
349  _SEH2_LEAVE;
350  }
351 
352  if (!CcCopyRead(
353  Vcb->StreamObj,
355  Length,
356  IrpContext->IsSynchronous,
357  Buffer,
358  &Irp->IoStatus))
359  {
361  _SEH2_LEAVE;
362  }
363 
364  Status = Irp->IoStatus.Status;
365  }
366  }
367  else
368  {
369  if ((ByteOffset.QuadPart + Length) >
370  Vcb->PartitionInformation.PartitionLength.QuadPart
371  )
372  {
373  Length = (ULONG)(
374  Vcb->PartitionInformation.PartitionLength.QuadPart -
375  ByteOffset.QuadPart);
376 
377  Length &= ~((ULONG)SECTOR_SIZE - 1);
378  }
379 
381  IrpContext->Irp,
382  Length,
383  IoWriteAccess);
384 
385  if (!NT_SUCCESS(Status))
386  {
387  _SEH2_LEAVE;
388  }
389 
390 #if DBG
392 #endif
394 
395  if (!ffs_bdl)
396  {
398  _SEH2_LEAVE;
399  }
400 
401  ffs_bdl->Irp = NULL;
402  ffs_bdl->Lba = ByteOffset.QuadPart;
403  ffs_bdl->Length = Length;
404  ffs_bdl->Offset = 0;
405 
406  Status = FFSReadWriteBlocks(IrpContext,
407  Vcb,
408  ffs_bdl,
409  Length,
410  1,
411  FALSE);
412 
413  if (NT_SUCCESS(Status))
414  {
415  Irp->IoStatus.Information = Length;
416  }
417 
418  Irp = IrpContext->Irp;
419 
420  if (!Irp)
421  _SEH2_LEAVE;
422  }
423  }
424 
426  {
427  if (PagingIoResourceAcquired)
428  {
430  &Vcb->PagingIoResource,
432  }
433 
434  if (MainResourceAcquired)
435  {
437  &Vcb->MainResource,
439  }
440 
441  if (ffs_bdl)
442  ExFreePool(ffs_bdl);
443 
444  if (!IrpContext->ExceptionInProgress)
445  {
446  if (IrpContext->Irp)
447  {
448  if (Status == STATUS_PENDING &&
449  !IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_REQUEUED))
450  {
452  IrpContext->Irp,
453  Length,
454  IoWriteAccess);
455 
456  if (NT_SUCCESS(Status))
457  {
458  Status = FFSQueueRequest(IrpContext);
459  }
460  else
461  {
462  FFSCompleteIrpContext(IrpContext, Status);
463  }
464  }
465  else
466  {
467  if (NT_SUCCESS(Status))
468  {
469  if (SynchronousIo && !PagingIo)
470  {
471  IrpContext->FileObject->CurrentByteOffset.QuadPart =
472  ByteOffset.QuadPart + IrpContext->Irp->IoStatus.Information;
473  }
474 
475  if (!PagingIo)
476  {
477  IrpContext->FileObject->Flags &= ~FO_FILE_FAST_IO_READ;
478  }
479  }
480 
481  FFSCompleteIrpContext(IrpContext, Status);
482  }
483  }
484  else
485  {
486  FFSFreeIrpContext(IrpContext);
487  }
488  }
489  } _SEH2_END;
490 
491  return Status;
492 }
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
NTSTATUS FFSQueueRequest(IN PFFS_IRP_CONTEXT IrpContext)
Definition: dispatch.c:33
VOID NTAPI CcMdlRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, OUT PMDL *MdlChain, OUT PIO_STATUS_BLOCK IoStatus)
Definition: mdlsup.c:64
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
ULONG Offset
Definition: ffsdrv.h:800
PFILE_OBJECT FileObject
Definition: ntfs.h:504
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
#define IRP_NOCACHE
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
__drv_mustHoldCriticalRegion VOID FFSFreeIrpContext(IN PFFS_IRP_CONTEXT IrpContext)
Definition: memory.c:179
Definition: ffsdrv.h:283
NTSTATUS FFSLockUserBuffer(IN PIRP Irp, IN ULONG Length, IN LOCK_OPERATION Operation)
Definition: block.c:70
#define PAGED_CODE()
Definition: video.h:57
_SEH2_TRY
Definition: create.c:4250
#define FFSBreakPoint()
Definition: ffsdrv.h:43
#define STATUS_END_OF_FILE
Definition: shellext.h:62
#define FO_SYNCHRONOUS_IO
Definition: iotypes.h:1732
#define CCB_ALLOW_EXTENDED_DASD_IO
Definition: ext2fs.h:1028
#define SECTOR_SIZE
Definition: winldr.h:34
#define FO_FILE_FAST_IO_READ
Definition: iotypes.h:1751
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
#define STATUS_INVALID_USER_BUFFER
Definition: udferr_usr.h:166
PVOID FFSGetUserBuffer(IN PIRP Irp)
Definition: block.c:115
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
struct _FFS_VCB * PFFS_VCB
Definition: bufpool.h:45
FFS_IDENTIFIER_TYPE Type
Definition: ffsdrv.h:294
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
struct _FFS_FCBVCB * PFFS_FCBVCB
__drv_mustHoldCriticalRegion NTSTATUS FFSCompleteIrpContext(IN PFFS_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:53
NTSTATUS FFSReadWriteBlocks(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN PFFS_BDL FFSBDL, IN ULONG Length, IN ULONG Count, IN BOOLEAN bVerify)
Definition: block.c:207
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define Vcb
Definition: cdprocs.h:1425
LONGLONG Lba
Definition: ffsdrv.h:799
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
* PFILE_OBJECT
Definition: iotypes.h:1954
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
ULONG Flags
Definition: ntfs.h:520
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
FFS_IDENTIFIER Identifier
Definition: ffsdrv.h:426
BOOLEAN NTAPI CcCopyRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus)
Definition: copysup.c:43
#define IRP_MN_MDL
Definition: iotypes.h:4062
Definition: ffsdrv.h:280
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:593
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
#define FFS_POOL_TAG
Definition: ffsdrv.h:817
ClearFlag(Dirent->Flags, DIRENT_FLAG_NOT_PERSISTENT)
Status
Definition: gdiplustypes.h:24
#define IRP_MN_DPC
Definition: iotypes.h:4061
ULONG Length
Definition: ffsdrv.h:801
struct _FFS_CCB * PFFS_CCB
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
_SEH2_END
Definition: create.c:4424
_SEH2_FINALLY
Definition: create.c:4395
#define IRP_CONTEXT_FLAG_REQUEUED
Definition: ext2fs.h:1085
#define IRP_PAGING_IO
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
#define _SEH2_LEAVE
Definition: filesup.c:20
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
PIRP Irp
Definition: ffsdrv.h:802
IN PDCB IN PCCB IN VBO IN OUT PULONG OUT PDIRENT OUT PBCB OUT PVBO ByteOffset
Definition: fatprocs.h:716

Referenced by FFSRead().

◆ FFSv1ReadInode()

NTSTATUS FFSv1ReadInode ( IN PFFS_IRP_CONTEXT  IrpContext,
IN PFFS_VCB  Vcb,
IN PFFSv1_INODE  dinode1,
IN ULONGLONG  offset,
IN PVOID  Buffer,
IN ULONG  size,
OUT PULONG  dwRet 
)

Definition at line 496 of file read.c.

504 {
505  PFFS_BDL ffs_bdl = NULL;
506  ULONG blocks, i;
509 
510  ULONG Totalblocks;
511  LONGLONG AllocSize;
512 
513  PAGED_CODE();
514 
515  if (dwRet)
516  {
517  *dwRet = 0;
518  }
519 
520  Totalblocks = (dinode1->di_blocks);
521  AllocSize = ((LONGLONG)(FFSDataBlocks(Vcb, Totalblocks)) << BLOCK_BITS);
522 
523  if ((LONGLONG)offset >= AllocSize)
524  {
525  FFSPrint((DBG_ERROR, "FFSv1ReadInode: beyond the file range.\n"));
526  return STATUS_SUCCESS;
527  }
528 
529  if ((LONGLONG)offset + size > AllocSize)
530  {
531  size = (ULONG)(AllocSize - offset);
532  }
533 
534  blocks = FFSv1BuildBDL(IrpContext, Vcb, dinode1, offset, size, &ffs_bdl);
535 
536  if (blocks <= 0)
537  {
538  FFSBreakPoint();
539  goto errorout;
540  }
541 
542  if (IrpContext)
543  {
544  // assume offset is aligned.
545  Status = FFSReadWriteBlocks(IrpContext, Vcb, ffs_bdl, size, blocks, FALSE);
546  }
547  else
548  {
549  for(i = 0; i < blocks; i++)
550  {
551  IoStatus.Information = 0;
552 
553 #if DBG
554  KdPrint(("FFSv1ReadInode() i : %d, Lba : %x, Length : %x, Offset : %x\n",
555  i, ffs_bdl[i].Lba, ffs_bdl[i].Length, ffs_bdl[i].Offset));
556 #endif
557 
558  FFSCopyRead(
559  Vcb->StreamObj,
560  (PLARGE_INTEGER)(&(ffs_bdl[i].Lba)),
561  ffs_bdl[i].Length,
562  PIN_WAIT,
563  (PVOID)((PUCHAR)Buffer + ffs_bdl[i].Offset),
564  &IoStatus);
565 
566  Status = IoStatus.Status;
567  }
568  }
569 
570 errorout:
571 
572  if (ffs_bdl)
573  ExFreePool(ffs_bdl);
574 
575  if (NT_SUCCESS(Status))
576  {
577  if (dwRet) *dwRet = size;
578  }
579 
580  return Status;
581 }
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
GLintptr offset
Definition: glext.h:5920
#define PIN_WAIT
BOOLEAN FFSCopyRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus)
Definition: read.c:88
#define PAGED_CODE()
Definition: video.h:57
#define FFSBreakPoint()
Definition: ffsdrv.h:43
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
ULONG FFSDataBlocks(PFFS_VCB Vcb, ULONG TotalBlocks)
Definition: ffs.c:2930
#define BLOCK_BITS
Definition: stream.h:22
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
static int blocks
Definition: mkdosfs.c:527
int64_t LONGLONG
Definition: typedefs.h:66
NTSTATUS FFSReadWriteBlocks(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN PFFS_BDL FFSBDL, IN ULONG Length, IN ULONG Count, IN BOOLEAN bVerify)
Definition: block.c:207
GLsizeiptr size
Definition: glext.h:5919
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
ULONG FFSv1BuildBDL(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN PFFSv1_INODE dinode1, IN ULONGLONG Offset, IN ULONG Size, OUT PFFS_BDL *ffs_bdl)
Definition: ffs.c:817
#define DBG_ERROR
Definition: ffsdrv.h:1031
Status
Definition: gdiplustypes.h:24
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define KdPrint(x)
Definition: env_spec_w32.h:288
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by FFSAddEntry(), FFSIsDirectoryEmpty(), FFSQueryDirectory(), FFSReadFile(), FFSRemoveEntry(), FFSSetParentEntry(), and FFSv1ScanDir().

◆ FFSv2ReadInode()

NTSTATUS FFSv2ReadInode ( IN PFFS_IRP_CONTEXT  IrpContext,
IN PFFS_VCB  Vcb,
IN PFFSv2_INODE  dinode2,
IN ULONGLONG  offset,
IN PVOID  Buffer,
IN ULONG  size,
OUT PULONG  dwRet 
)

Definition at line 585 of file read.c.

593 {
594  PFFS_BDL ffs_bdl = NULL;
595  ULONG blocks, i;
598 
599  ULONG Totalblocks;
600  LONGLONG AllocSize;
601 
602  PAGED_CODE();
603 
604  if (dwRet)
605  {
606  *dwRet = 0;
607  }
608 
609  Totalblocks = (ULONG)(dinode2->di_blocks);
610  AllocSize = ((LONGLONG)(FFSDataBlocks(Vcb, Totalblocks)) << BLOCK_BITS);
611 
612  if ((LONGLONG)offset >= AllocSize)
613  {
614  FFSPrint((DBG_ERROR, "FFSv2ReadInode: beyond the file range.\n"));
615  return STATUS_SUCCESS;
616  }
617 
618  if ((LONGLONG)offset + size > AllocSize)
619  {
620  size = (ULONG)(AllocSize - offset);
621  }
622 
623  blocks = FFSv2BuildBDL(IrpContext, Vcb, dinode2, offset, size, &ffs_bdl);
624 
625  if (blocks <= 0)
626  {
627  FFSBreakPoint();
628  goto errorout;
629  }
630 
631  if (IrpContext)
632  {
633  // assume offset is aligned.
634  Status = FFSReadWriteBlocks(IrpContext, Vcb, ffs_bdl, size, blocks, FALSE);
635  }
636  else
637  {
638  for(i = 0; i < blocks; i++)
639  {
640  IoStatus.Information = 0;
641 
642 #if 0
643  KdPrint(("FFSv2ReadInode() i : %d, Lba : %x, Length : %x, Offset : %x\n",
644  i, ffs_bdl[i].Lba, ffs_bdl[i].Length, ffs_bdl[i].Offset));
645 #endif
646 
647  FFSCopyRead(
648  Vcb->StreamObj,
649  (PLARGE_INTEGER)(&(ffs_bdl[i].Lba)),
650  ffs_bdl[i].Length,
651  PIN_WAIT,
652  (PVOID)((PUCHAR)Buffer + ffs_bdl[i].Offset),
653  &IoStatus);
654 
655  Status = IoStatus.Status;
656  }
657  }
658 
659 errorout:
660 
661  if (ffs_bdl)
662  ExFreePool(ffs_bdl);
663 
664  if (NT_SUCCESS(Status))
665  {
666  if (dwRet) *dwRet = size;
667  }
668 
669  return Status;
670 }
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
GLintptr offset
Definition: glext.h:5920
#define PIN_WAIT
BOOLEAN FFSCopyRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus)
Definition: read.c:88
#define PAGED_CODE()
Definition: video.h:57
#define FFSBreakPoint()
Definition: ffsdrv.h:43
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
ULONG FFSDataBlocks(PFFS_VCB Vcb, ULONG TotalBlocks)
Definition: ffs.c:2930
#define BLOCK_BITS
Definition: stream.h:22
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
static int blocks
Definition: mkdosfs.c:527
int64_t LONGLONG
Definition: typedefs.h:66
NTSTATUS FFSReadWriteBlocks(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN PFFS_BDL FFSBDL, IN ULONG Length, IN ULONG Count, IN BOOLEAN bVerify)
Definition: block.c:207
GLsizeiptr size
Definition: glext.h:5919
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define DBG_ERROR
Definition: ffsdrv.h:1031
Status
Definition: gdiplustypes.h:24
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define KdPrint(x)
Definition: env_spec_w32.h:288
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
ULONG FFSv2BuildBDL(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN PFFSv2_INODE dinode2, IN ULONGLONG Offset, IN ULONG Size, OUT PFFS_BDL *ffs_bdl)
Definition: ffs.c:954

Referenced by FFSIsDirectoryEmpty(), FFSQueryDirectory(), FFSReadFile(), and FFSv2ScanDir().

Variable Documentation

◆ FFSGlobal

PFFS_GLOBAL FFSGlobal

Definition at line 22 of file init.c.

Referenced by FFSRead(), and FFSReadFile().