ReactOS  0.4.13-dev-551-gf37fb1f
ffs.c File Reference
#include "ntifs.h"
#include "ffsdrv.h"
Include dependency graph for ffs.c:

Go to the source code of this file.

Functions

PFFS_SUPER_BLOCK FFSLoadSuper (IN PFFS_VCB Vcb, IN BOOLEAN bVerify, IN ULONGLONG SuperBlockOffset)
 
__drv_mustHoldCriticalRegion BOOLEAN FFSSaveSuper (IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb)
 
BOOLEAN FFSv1GetInodeLba (IN PFFS_VCB Vcb, IN ULONG inode, OUT PLONGLONG offset)
 
BOOLEAN FFSv2GetInodeLba (IN PFFS_VCB Vcb, IN ULONG inode, OUT PLONGLONG offset)
 
BOOLEAN FFSv1LoadInode (IN PFFS_VCB Vcb, IN ULONG inode, IN PFFSv1_INODE dinode1)
 
BOOLEAN FFSv2LoadInode (IN PFFS_VCB Vcb, IN ULONG inode, IN PFFSv2_INODE dinode2)
 
__drv_mustHoldCriticalRegion BOOLEAN FFSv1SaveInode (IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN ULONG Inode, IN PFFSv1_INODE dinode1)
 
__drv_mustHoldCriticalRegion BOOLEAN FFSv2SaveInode (IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN ULONG Inode, IN PFFSv2_INODE dinode2)
 
BOOLEAN FFSv1LoadBlock (IN PFFS_VCB Vcb, IN ULONG dwBlk, IN PVOID Buffer)
 
BOOLEAN FFSv2LoadBlock (IN PFFS_VCB Vcb, IN ULONGLONG dwBlk, IN PVOID Buffer)
 
__drv_mustHoldCriticalRegion BOOLEAN FFSSaveBlock (IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN ULONG dwBlk, IN PVOID Buf)
 
__drv_mustHoldCriticalRegion BOOLEAN FFSSaveBuffer (IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN LONGLONG Offset, IN ULONG Size, IN PVOID Buf)
 
ULONG FFSv1GetBlock (IN PFFS_VCB Vcb, ULONG dwContent, ULONG Index, int layer)
 
ULONGLONG FFSv2GetBlock (IN PFFS_VCB Vcb, ULONGLONG dwContent, ULONG Index, int layer)
 
ULONG FFSv1BlockMap (IN PFFS_VCB Vcb, IN PFFSv1_INODE dinode1, IN ULONG Index)
 
ULONGLONG FFSv2BlockMap (IN PFFS_VCB Vcb, IN PFFSv2_INODE dinode2, IN ULONG Index)
 
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)
 
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)
 
BOOLEAN FFSNewBlock (PFFS_IRP_CONTEXT IrpContext, PFFS_VCB Vcb, ULONG GroupHint, ULONG BlockHint, PULONG dwRet)
 
BOOLEAN FFSFreeBlock (PFFS_IRP_CONTEXT IrpContext, PFFS_VCB Vcb, ULONG Block)
 
__drv_mustHoldCriticalRegion BOOLEAN FFSExpandBlock (PFFS_IRP_CONTEXT IrpContext, PFFS_VCB Vcb, PFFS_FCB Fcb, ULONG dwContent, ULONG Index, ULONG layer, BOOLEAN bNew, ULONG *dwRet)
 
BOOLEAN FFSExpandInode (PFFS_IRP_CONTEXT IrpContext, PFFS_VCB Vcb, PFFS_FCB Fcb, ULONG *dwRet)
 
NTSTATUS FFSNewInode (PFFS_IRP_CONTEXT IrpContext, PFFS_VCB Vcb, ULONG GroupHint, ULONG Type, PULONG Inode)
 
BOOLEAN FFSFreeInode (PFFS_IRP_CONTEXT IrpContext, PFFS_VCB Vcb, ULONG Inode, ULONG Type)
 
__drv_mustHoldCriticalRegion NTSTATUS FFSAddEntry (IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN PFFS_FCB Dcb, IN ULONG FileType, IN ULONG Inode, IN PUNICODE_STRING FileName)
 
__drv_mustHoldCriticalRegion NTSTATUS FFSRemoveEntry (IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN PFFS_FCB Dcb, IN ULONG FileType, IN ULONG Inode)
 
__drv_mustHoldCriticalRegion NTSTATUS FFSSetParentEntry (IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN PFFS_FCB Dcb, IN ULONG OldParent, IN ULONG NewParent)
 
__drv_mustHoldCriticalRegion BOOLEAN FFSTruncateBlock (IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN PFFS_FCB Fcb, IN ULONG dwContent, IN ULONG Index, IN ULONG layer, OUT BOOLEAN *bFreed)
 
BOOLEAN FFSTruncateInode (IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN PFFS_FCB Fcb)
 
__drv_mustHoldCriticalRegion BOOLEAN FFSAddMcbEntry (IN PFFS_VCB Vcb, IN LONGLONG Lba, IN LONGLONG Length)
 
__drv_mustHoldCriticalRegion VOID FFSRemoveMcbEntry (IN PFFS_VCB Vcb, IN LONGLONG Lba, IN LONGLONG Length)
 
__drv_mustHoldCriticalRegion BOOLEAN FFSLookupMcbEntry (IN PFFS_VCB Vcb, IN LONGLONG Lba, OUT PLONGLONG pLba, OUT PLONGLONG pLength, OUT PLONGLONG RunStart, OUT PLONGLONG RunLength, OUT PULONG Index)
 
ULONG FFSDataBlocks (PFFS_VCB Vcb, ULONG TotalBlocks)
 
ULONG FFSTotalBlocks (PFFS_VCB Vcb, ULONG DataBlocks)
 

Variables

PFFS_GLOBAL FFSGlobal
 

Function Documentation

◆ FFSAddEntry()

__drv_mustHoldCriticalRegion NTSTATUS FFSAddEntry ( IN PFFS_IRP_CONTEXT  IrpContext,
IN PFFS_VCB  Vcb,
IN PFFS_FCB  Dcb,
IN ULONG  FileType,
IN ULONG  Inode,
IN PUNICODE_STRING  FileName 
)

Definition at line 1965 of file ffs.c.

1972 {
1974 
1975  PFFS_DIR_ENTRY pDir = NULL;
1976  PFFS_DIR_ENTRY pNewDir = NULL;
1977  PFFS_DIR_ENTRY pTarget = NULL;
1978 
1979  ULONG Length = 0;
1980  ULONG dwBytes = 0;
1981 
1982  BOOLEAN bFound = FALSE;
1983  BOOLEAN bAdding = FALSE;
1984 
1985  BOOLEAN MainResourceAcquired = FALSE;
1986 
1987  ULONG dwRet;
1988 
1989  PAGED_CODE();
1990 
1991  if (!IsDirectory(Dcb))
1992  {
1993  FFSBreakPoint();
1995  return Status;
1996  }
1997 
1998  MainResourceAcquired = ExAcquireResourceExclusiveLite(&Dcb->MainResource, TRUE);
1999 
2000  _SEH2_TRY
2001  {
2002  Dcb->ReferenceCount++;
2003 
2006  if (!pDir)
2007  {
2009  _SEH2_LEAVE;
2010  }
2011 
2014  if (!pTarget)
2015  {
2017  _SEH2_LEAVE;
2018  }
2019 
2020 #if 0
2021  if (IsFlagOn(SUPER_BLOCK->s_feature_incompat,
2022  FFS_FEATURE_INCOMPAT_FILETYPE))
2023  {
2024  pDir->d_type = (UCHAR)FileType;
2025  }
2026  else
2027 #endif
2028  {
2029  pDir->d_type = 0;
2030  }
2031 
2032  {
2034  OemName.Buffer = pDir->d_name;
2035  OemName.MaximumLength = FFS_NAME_LEN;
2036  OemName.Length = 0;
2037 
2039 
2040  if (!NT_SUCCESS(Status))
2041  {
2042  _SEH2_LEAVE;
2043  }
2044 
2045  pDir->d_namlen = (CCHAR)OemName.Length;
2046  }
2047 
2048  pDir->d_ino = Inode;
2049  pDir->d_reclen = (USHORT)(FFS_DIR_REC_LEN(pDir->d_namlen));
2050 
2051  dwBytes = 0;
2052 
2053 Repeat:
2054 
2055  while ((LONGLONG)dwBytes < Dcb->Header.AllocationSize.QuadPart)
2056  {
2058 
2059  // Reading the DCB contents
2061  NULL,
2062  Vcb,
2063  Dcb->dinode1,
2064  dwBytes,
2065  (PVOID)pTarget,
2067  &dwRet);
2068 
2069  if (!NT_SUCCESS(Status))
2070  {
2071  FFSPrint((DBG_ERROR, "FFSAddDirectory: Reading Directory Content error.\n"));
2072  _SEH2_LEAVE;
2073  }
2074 
2075  if (((pTarget->d_ino == 0) && pTarget->d_reclen >= pDir->d_reclen) ||
2076  (pTarget->d_reclen >= FFS_DIR_REC_LEN(pTarget->d_namlen) + pDir->d_reclen))
2077  {
2078  if (pTarget->d_ino)
2079  {
2081 
2082  // Reading the DCB contents
2084  NULL,
2085  Vcb,
2086  Dcb->dinode1,
2087  dwBytes,
2088  (PVOID)pTarget,
2090  &dwRet);
2091 
2092  if (!NT_SUCCESS(Status))
2093  {
2094  FFSPrint((DBG_ERROR, "FFSAddDirectory: Reading Directory Content error.\n"));
2095  _SEH2_LEAVE;
2096  }
2097 
2098  Length = FFS_DIR_REC_LEN(pTarget->d_namlen);
2099 
2100  pNewDir = (PFFS_DIR_ENTRY) ((PUCHAR)pTarget + FFS_DIR_REC_LEN(pTarget->d_namlen));
2101 
2102  pNewDir->d_reclen = pTarget->d_reclen - FFS_DIR_REC_LEN(pTarget->d_namlen);
2103 
2104  pTarget->d_reclen = FFS_DIR_REC_LEN(pTarget->d_namlen);
2105  }
2106  else
2107  {
2108  pNewDir = pTarget;
2109  pNewDir->d_reclen = (USHORT)((ULONG)(Dcb->Header.AllocationSize.QuadPart) - dwBytes);
2110  }
2111 
2112  pNewDir->d_type = pDir->d_type;
2113  pNewDir->d_ino = pDir->d_ino;
2114  pNewDir->d_namlen = pDir->d_namlen;
2115  memcpy(pNewDir->d_name, pDir->d_name, pDir->d_namlen);
2116  Length += FFS_DIR_REC_LEN(pDir->d_namlen);
2117 
2118  bFound = TRUE;
2119  break;
2120  }
2121 
2122  dwBytes += pTarget->d_reclen;
2123  }
2124 
2125  if (bFound)
2126  {
2127  ULONG dwRet;
2128 
2129  if (FileType == DT_DIR)
2130  {
2131  if(((pDir->d_namlen == 1) && (pDir->d_name[0] == '.')) ||
2132  ((pDir->d_namlen == 2) && (pDir->d_name[0] == '.') && (pDir->d_name[1] == '.')))
2133  {
2134  }
2135  else
2136  {
2137  Dcb->dinode1->di_nlink++;
2138  }
2139  }
2140 
2141  Status = FFSv1WriteInode(IrpContext, Vcb, Dcb->dinode1, dwBytes, pTarget, Length, FALSE, &dwRet);
2142  }
2143  else
2144  {
2145  // We should expand the size of the dir inode
2146  if (!bAdding)
2147  {
2148  ULONG dwRet;
2149 
2150  bAdding = FFSExpandInode(IrpContext, Vcb, Dcb, &dwRet);
2151 
2152  if (bAdding)
2153  {
2154 
2155  Dcb->dinode1->di_size = Dcb->Header.AllocationSize.LowPart;
2156 
2157  FFSv1SaveInode(IrpContext, Vcb, Dcb->FFSMcb->Inode, Dcb->dinode1);
2158 
2159  Dcb->Header.FileSize = Dcb->Header.AllocationSize;
2160 
2161  goto Repeat;
2162  }
2163 
2164  _SEH2_LEAVE;
2165 
2166  }
2167  else // Something must be error!
2168  {
2169  _SEH2_LEAVE;
2170  }
2171  }
2172  }
2173 
2175  {
2176 
2177  Dcb->ReferenceCount--;
2178 
2179  if(MainResourceAcquired)
2180  {
2182  &Dcb->MainResource,
2184  }
2185 
2186  if (pTarget != NULL)
2187  {
2188  ExFreePool(pTarget);
2189  }
2190 
2191  if (pDir)
2192  {
2193  ExFreePool(pDir);
2194  }
2195  } _SEH2_END;
2196 
2197  return Status;
2198 }
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
Definition: dir.h:83
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
#define FFS_NAME_LEN
Definition: ffsdrv.h:202
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
#define FFS_DIR_REC_LEN(name_len)
Definition: ffsdrv.h:214
STRING OEM_STRING
Definition: umtypes.h:203
#define PAGED_CODE()
Definition: video.h:57
_SEH2_TRY
Definition: create.c:4250
#define FFSBreakPoint()
Definition: ffsdrv.h:43
#define DT_DIR
Definition: fs.h:149
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
NTSTATUS FFSUnicodeToOEM(IN OUT POEM_STRING Oem, IN PUNICODE_STRING Unicode)
Definition: misc.c:106
__drv_mustHoldCriticalRegion BOOLEAN FFSv1SaveInode(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN ULONG Inode, IN PFFSv1_INODE dinode1)
Definition: ffs.c:407
NTSTATUS FFSv1WriteInode(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN PFFSv1_INODE dinode1, IN ULONGLONG offset, IN PVOID Buffer, IN ULONG size, IN BOOLEAN bWriteToDisk, OUT PULONG dwRet)
Definition: write.c:798
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
u_int32_t d_ino
Definition: dir.h:84
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define SUPER_BLOCK
Definition: ext2fs.h:90
u_int8_t d_type
Definition: dir.h:86
char d_name[MAXNAMLEN+1]
Definition: dir.h:88
int64_t LONGLONG
Definition: typedefs.h:66
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
char CCHAR
Definition: typedefs.h:50
#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 ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
unsigned char UCHAR
Definition: xmlstorage.h:181
_Must_inspect_result_ _In_ PFLT_INSTANCE _Out_ PBOOLEAN IsDirectory
Definition: fltkernel.h:1139
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define DBG_ERROR
Definition: ffsdrv.h:1031
#define FFS_POOL_TAG
Definition: ffsdrv.h:817
static BOOLEAN Repeat
Definition: dem.c:247
u_int16_t d_reclen
Definition: dir.h:85
Status
Definition: gdiplustypes.h:24
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
BOOLEAN FFSExpandInode(PFFS_IRP_CONTEXT IrpContext, PFFS_VCB Vcb, PFFS_FCB Fcb, ULONG *dwRet)
Definition: ffs.c:1543
_SEH2_END
Definition: create.c:4424
unsigned short USHORT
Definition: pedump.c:61
_SEH2_FINALLY
Definition: create.c:4395
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
#define _SEH2_LEAVE
Definition: filesup.c:20
IN PDCB IN POEM_STRING OemName
Definition: fatprocs.h:1294
struct direct * PFFS_DIR_ENTRY
Definition: ffsdrv.h:265
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB * Dcb
Definition: create.c:4157
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
u_int8_t d_namlen
Definition: dir.h:87

Referenced by FFSCreateFile(), FFSCreateInode(), and FFSSetRenameInfo().

◆ FFSAddMcbEntry()

__drv_mustHoldCriticalRegion BOOLEAN FFSAddMcbEntry ( IN PFFS_VCB  Vcb,
IN LONGLONG  Lba,
IN LONGLONG  Length 
)

Definition at line 2673 of file ffs.c.

2677 {
2678  BOOLEAN bRet = FALSE;
2679 
2680  LONGLONG Offset;
2681 
2682 #if DBG
2683  LONGLONG DirtyLba;
2684  LONGLONG DirtyLen;
2685 #endif
2686 
2687  PAGED_CODE();
2688 
2689  Offset = Lba & (~((LONGLONG)BLOCK_SIZE - 1));
2690 
2691  Length = (Length + Lba - Offset + BLOCK_SIZE - 1) &
2692  (~((LONGLONG)BLOCK_SIZE - 1));
2693 
2694  ASSERT ((Offset & (BLOCK_SIZE - 1)) == 0);
2695  ASSERT ((Length & (BLOCK_SIZE - 1)) == 0);
2696 
2697  Offset = (Offset >> BLOCK_BITS) + 1;
2698  Length = (Length >>BLOCK_BITS);
2699 
2701  &(Vcb->McbResource),
2702  TRUE);
2703 
2704  FFSPrint((DBG_INFO, "FFSAddMcbEntry: Lba=%I64xh Length=%I64xh\n",
2705  Offset, Length));
2706 
2707 #if DBG
2708  bRet = FsRtlLookupLargeMcbEntry(
2709  &(Vcb->DirtyMcbs),
2710  Offset,
2711  &DirtyLba,
2712  &DirtyLen,
2713  NULL,
2714  NULL,
2715  NULL);
2716 
2717  if (bRet && DirtyLba == Offset && DirtyLen >= Length)
2718  {
2719  FFSPrint((DBG_INFO, "FFSAddMcbEntry: this run already exists.\n"));
2720  }
2721 #endif
2722 
2723  _SEH2_TRY
2724  {
2725  bRet = FsRtlAddLargeMcbEntry(
2726  &(Vcb->DirtyMcbs),
2727  Offset, Offset,
2728  Length);
2729 
2730  }
2732  {
2733  FFSBreakPoint();
2734  bRet = FALSE;
2735  } _SEH2_END;
2736 
2737 #if DBG
2738  if (bRet)
2739  {
2740  BOOLEAN bFound = FALSE;
2741  LONGLONG RunStart;
2742  LONGLONG RunLength;
2743  ULONG Index;
2744 
2745  bFound = FsRtlLookupLargeMcbEntry(
2746  &(Vcb->DirtyMcbs),
2747  Offset,
2748  &DirtyLba,
2749  &DirtyLen,
2750  &RunStart,
2751  &RunLength,
2752  &Index);
2753 
2754  if ((!bFound) || (DirtyLba == -1) ||
2755  (DirtyLba != Offset) || (DirtyLen < Length))
2756  {
2757  LONGLONG DirtyVba;
2758  LONGLONG DirtyLba;
2759  LONGLONG DirtyLength;
2760 
2761  FFSBreakPoint();
2762 
2763  for (Index = 0;
2764  FsRtlGetNextLargeMcbEntry(&(Vcb->DirtyMcbs),
2765  Index,
2766  &DirtyVba,
2767  &DirtyLba,
2768  &DirtyLength);
2769  Index++)
2770  {
2771  FFSPrint((DBG_INFO, "Index = %xh\n", Index));
2772  FFSPrint((DBG_INFO, "DirtyVba = %I64xh\n", DirtyVba));
2773  FFSPrint((DBG_INFO, "DirtyLba = %I64xh\n", DirtyLba));
2774  FFSPrint((DBG_INFO, "DirtyLen = %I64xh\n\n", DirtyLength));
2775  }
2776  }
2777  }
2778 #endif
2779 
2781  &(Vcb->McbResource),
2783 
2784  return bRet;
2785 }
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
#define TRUE
Definition: types.h:120
#define PAGED_CODE()
Definition: video.h:57
_SEH2_TRY
Definition: create.c:4250
#define FFSBreakPoint()
Definition: ffsdrv.h:43
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
BOOLEAN NTAPI FsRtlGetNextLargeMcbEntry(IN PLARGE_MCB Mcb, IN ULONG RunIndex, OUT PLONGLONG Vbn, OUT PLONGLONG Lbn, OUT PLONGLONG SectorCount)
Definition: largemcb.c:391
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned char BOOLEAN
#define BLOCK_BITS
Definition: stream.h:22
smooth NULL
Definition: ftsmooth.c:416
int64_t LONGLONG
Definition: typedefs.h:66
#define BLOCK_SIZE
Definition: dlist.c:220
#define Vcb
Definition: cdprocs.h:1425
static const UCHAR Index[8]
Definition: usbohci.c:18
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
BOOLEAN NTAPI FsRtlAddLargeMcbEntry(IN PLARGE_MCB Mcb, IN LONGLONG Vbn, IN LONGLONG Lbn, IN LONGLONG SectorCount)
Definition: largemcb.c:282
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
BOOLEAN NTAPI FsRtlLookupLargeMcbEntry(IN PLARGE_MCB Mcb, IN LONGLONG Vbn, OUT PLONGLONG Lbn OPTIONAL, OUT PLONGLONG SectorCountFromLbn OPTIONAL, OUT PLONGLONG StartingLbn OPTIONAL, OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, OUT PULONG Index OPTIONAL)
Definition: largemcb.c:564
_SEH2_END
Definition: create.c:4424
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
#define DBG_INFO
Definition: ffsdrv.h:1034
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6

Referenced by FFSCheckSetBlock(), FFSFreeBlock(), FFSFreeInode(), FFSNewBlock(), FFSNewInode(), FFSSaveBuffer(), FFSTruncateBlock(), and FFSWriteVolume().

◆ FFSDataBlocks()

ULONG FFSDataBlocks ( PFFS_VCB  Vcb,
ULONG  TotalBlocks 
)

Definition at line 2930 of file ffs.c.

2933 {
2935  ULONG dwMeta[FFS_BLOCK_TYPES];
2936  ULONG DataBlocks = 0;
2937  ULONG i, j;
2938 
2939  if (TotalBlocks <= NDADDR)
2940  {
2941  return TotalBlocks;
2942  }
2943 
2944  TotalBlocks -= NDADDR;
2945 
2946  for (i = 0; i < FFS_BLOCK_TYPES; i++)
2947  {
2948  if (i == 0)
2949  {
2950  dwData[i] = 1;
2951  }
2952  else
2953  {
2954  dwData[i] = Vcb->dwData[i];
2955  }
2956 
2957  dwMeta[i] = Vcb->dwMeta[i];
2958  }
2959 
2960  for(i = 1; (i < FFS_BLOCK_TYPES) && (TotalBlocks > 0); i++)
2961  {
2962  if (TotalBlocks >= (dwData[i] + dwMeta[i]))
2963  {
2964  TotalBlocks -= (dwData[i] + dwMeta[i]);
2965  DataBlocks += dwData[i];
2966  }
2967  else
2968  {
2969  ULONG dwDivide = 0;
2970  ULONG dwRemain = 0;
2971 
2972  for (j = i; (j > 0) && (TotalBlocks > 0); j--)
2973  {
2974  dwDivide = (TotalBlocks - 1) / (dwData[j - 1] + dwMeta[j - 1]);
2975  dwRemain = (TotalBlocks - 1) % (dwData[j - 1] + dwMeta[j - 1]);
2976 
2977  DataBlocks += (dwDivide * dwData[j - 1]);
2978  TotalBlocks = dwRemain;
2979  }
2980  }
2981  }
2982 
2983  return (DataBlocks + NDADDR);
2984 }
#define NDADDR
Definition: dinode.h:77
static HANDLE ULONG_PTR dwData
Definition: file.c:35
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
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 GLint GLint j
Definition: glfuncs.h:250
#define FFS_BLOCK_TYPES
Definition: ffsdrv.h:67
#define Vcb
Definition: cdprocs.h:1425
unsigned int ULONG
Definition: retypes.h:1

Referenced by FFSExpandInode(), FFSTruncateInode(), FFSv1AllocateFcb(), FFSv1BlockMap(), FFSv1BuildBDL(), FFSv1ReadInode(), FFSv1WriteInode(), FFSv2AllocateFcb(), FFSv2BlockMap(), FFSv2BuildBDL(), and FFSv2ReadInode().

◆ FFSExpandBlock()

__drv_mustHoldCriticalRegion BOOLEAN FFSExpandBlock ( PFFS_IRP_CONTEXT  IrpContext,
PFFS_VCB  Vcb,
PFFS_FCB  Fcb,
ULONG  dwContent,
ULONG  Index,
ULONG  layer,
BOOLEAN  bNew,
ULONG dwRet 
)

Definition at line 1406 of file ffs.c.

1415 {
1416  ULONG *pData = NULL;
1417  ULONG i = 0, j = 0, temp = 1;
1418  ULONG dwNewBlk = 0, dwBlk = 0;
1419  BOOLEAN bDirty = FALSE;
1420  BOOLEAN bRet = TRUE;
1421 
1422  PFFSv1_INODE dinode1 = Fcb->dinode1;
1423  PFFS_SUPER_BLOCK FFSSb = Vcb->ffs_super_block;
1424 
1425  PAGED_CODE();
1426 
1428 
1429  if (!pData)
1430  {
1431  return FALSE;
1432  }
1433 
1434  RtlZeroMemory(pData, Vcb->BlockSize);
1435 
1436  if (bNew)
1437  {
1438  if (layer == 0)
1439  {
1440  if (IsDirectory(Fcb))
1441  {
1442  PFFS_DIR_ENTRY pEntry;
1443 
1444  pEntry = (PFFS_DIR_ENTRY) pData;
1445  pEntry->d_reclen = (USHORT)(Vcb->BlockSize);
1446 
1447  if (!FFSSaveBlock(IrpContext, Vcb, dwContent, (PVOID)pData))
1448  {
1449  bRet = FALSE;
1450  goto errorout;
1451  }
1452  }
1453  else
1454  {
1456 
1457  Offset.QuadPart = (LONGLONG)dwContent;
1458  Offset.QuadPart = Offset.QuadPart * Vcb->BlockSize;
1459 
1460  FFSRemoveMcbEntry(Vcb, Offset.QuadPart, (LONGLONG)Vcb->BlockSize);
1461  }
1462  }
1463  else
1464  {
1465  if (!FFSSaveBlock(IrpContext, Vcb, dwContent, (PVOID)pData))
1466  {
1467  bRet = FALSE;
1468  goto errorout;
1469  }
1470  }
1471  }
1472 
1473  if (layer == 0)
1474  {
1475  dwNewBlk = dwContent;
1476  }
1477  else if (layer <= 3)
1478  {
1479  if (!bNew)
1480  {
1481  bRet = FFSv1LoadBlock(Vcb, dwContent, (void *)pData);
1482  if (!bRet) goto errorout;
1483  }
1484 
1485  temp = 1 << ((BLOCK_BITS - 2) * (layer - 1));
1486 
1487  i = Index / temp;
1488  j = Index % temp;
1489 
1490  dwBlk = pData[i];
1491 
1492  if (dwBlk == 0)
1493  {
1494  if (!FFSNewBlock(IrpContext,
1495  Vcb, 0,
1496  dwContent,
1497  &dwBlk))
1498  {
1499  bRet = FALSE;
1500  FFSPrint((DBG_ERROR, "FFSExpandBlock: get new block error.\n"));
1501  goto errorout;
1502  }
1503 
1504  dinode1->di_blocks += (Vcb->BlockSize / SECTOR_SIZE);
1505 
1506  pData[i] = dwBlk;
1507  bDirty = TRUE;
1508  }
1509 
1510  if (!FFSExpandBlock(IrpContext,
1511  Vcb, Fcb,
1512  dwBlk, j,
1513  layer - 1,
1514  bDirty,
1515  &dwNewBlk))
1516  {
1517  bRet = FALSE;
1518  FFSPrint((DBG_ERROR, "FFSExpandBlockk: ... error recuise...\n"));
1519  goto errorout;
1520  }
1521 
1522  if (bDirty)
1523  {
1524  bRet = FFSSaveBlock(IrpContext,
1525  Vcb, dwContent,
1526  (void *)pData);
1527  }
1528  }
1529 
1530 errorout:
1531 
1532  if (pData)
1533  ExFreePool(pData);
1534 
1535  if (bRet && dwRet)
1536  *dwRet = dwNewBlk;
1537 
1538  return bRet;
1539 }
#define TRUE
Definition: types.h:120
Definition: dir.h:83
Definition: fs.h:235
#define PAGED_CODE()
Definition: video.h:57
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
BOOLEAN FFSNewBlock(PFFS_IRP_CONTEXT IrpContext, PFFS_VCB Vcb, ULONG GroupHint, ULONG BlockHint, PULONG dwRet)
Definition: ffs.c:1094
#define SECTOR_SIZE
Definition: winldr.h:34
unsigned char BOOLEAN
#define BLOCK_BITS
Definition: stream.h:22
smooth NULL
Definition: ftsmooth.c:416
__drv_mustHoldCriticalRegion BOOLEAN FFSSaveBlock(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN ULONG dwBlk, IN PVOID Buf)
Definition: ffs.c:525
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 GLint GLint j
Definition: glfuncs.h:250
GLenum GLuint GLint GLint layer
Definition: glext.h:7007
int64_t LONGLONG
Definition: typedefs.h:66
BOOLEAN FFSv1LoadBlock(IN PFFS_VCB Vcb, IN ULONG dwBlk, IN PVOID Buffer)
Definition: ffs.c:459
#define Vcb
Definition: cdprocs.h:1425
static const UCHAR Index[8]
Definition: usbohci.c:18
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_Must_inspect_result_ _In_ PFLT_INSTANCE _Out_ PBOOLEAN IsDirectory
Definition: fltkernel.h:1139
#define DBG_ERROR
Definition: ffsdrv.h:1031
#define FFS_POOL_TAG
Definition: ffsdrv.h:817
u_int16_t d_reclen
Definition: dir.h:85
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
unsigned short USHORT
Definition: pedump.c:61
static calc_node_t temp
Definition: rpn_ieee.c:38
__drv_mustHoldCriticalRegion VOID FFSRemoveMcbEntry(IN PFFS_VCB Vcb, IN LONGLONG Lba, IN LONGLONG Length)
Definition: ffs.c:2790
__drv_mustHoldCriticalRegion BOOLEAN FFSExpandBlock(PFFS_IRP_CONTEXT IrpContext, PFFS_VCB Vcb, PFFS_FCB Fcb, ULONG dwContent, ULONG Index, ULONG layer, BOOLEAN bNew, ULONG *dwRet)
Definition: ffs.c:1406
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
_In_ PFCB Fcb
Definition: cdprocs.h:151
struct direct * PFFS_DIR_ENTRY
Definition: ffsdrv.h:265
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
u_int32_t di_blocks
Definition: dinode.h:97

Referenced by FFSExpandInode().

◆ FFSExpandInode()

BOOLEAN FFSExpandInode ( PFFS_IRP_CONTEXT  IrpContext,
PFFS_VCB  Vcb,
PFFS_FCB  Fcb,
ULONG dwRet 
)

Definition at line 1543 of file ffs.c.

1548 {
1549  ULONG dwSizes[FFS_BLOCK_TYPES];
1550  ULONG Index = 0;
1551  ULONG dwTotal = 0;
1552  ULONG dwBlk = 0, dwNewBlk = 0;
1553  ULONG i;
1554  BOOLEAN bRet = FALSE;
1555  BOOLEAN bNewBlock = FALSE;
1556 
1557  PFFSv1_INODE dinode1 = Fcb->dinode1;
1558 
1559  PAGED_CODE();
1560 
1561  Index = (ULONG)(Fcb->Header.AllocationSize.QuadPart >> BLOCK_BITS);
1562 
1563  for (i = 0; i < FFS_BLOCK_TYPES; i++)
1564  {
1565  dwSizes[i] = Vcb->dwData[i];
1566  dwTotal += dwSizes[i];
1567  }
1568 
1569  if (Index >= dwTotal)
1570  {
1571  FFSPrint((DBG_ERROR, "FFSExpandInode: beyond the maxinum size of an inode.\n"));
1572  return FALSE;
1573  }
1574 
1575  for (i = 0; i < FFS_BLOCK_TYPES; i++)
1576  {
1577  if (Index < dwSizes[i])
1578  {
1579  dwBlk = dinode1->di_db[i == 0 ? (Index) : (i + NDADDR - 1)];
1580  if (dwBlk == 0)
1581  {
1582  if (!FFSNewBlock(IrpContext,
1583  Vcb,
1584  Fcb->BlkHint ? 0 : ((Fcb->FFSMcb->Inode - 1) / INODES_PER_GROUP),
1585  Fcb->BlkHint,
1586  &dwBlk))
1587  {
1588  FFSPrint((DBG_ERROR, "FFSExpandInode: get new block error.\n"));
1589  break;
1590  }
1591 
1592  dinode1->di_ib[i == 0 ? (Index):(i + NDADDR - 1)] = dwBlk;
1593 
1594  dinode1->di_blocks += (Vcb->BlockSize / SECTOR_SIZE);
1595 
1596  bNewBlock = TRUE;
1597  }
1598 
1599  bRet = FFSExpandBlock(IrpContext,
1600  Vcb, Fcb,
1601  dwBlk, Index,
1602  i, bNewBlock,
1603  &dwNewBlk);
1604 
1605  if (bRet)
1606  {
1607  Fcb->Header.AllocationSize.QuadPart += Vcb->BlockSize;
1608  }
1609 
1610  break;
1611  }
1612 
1613  Index -= dwSizes[i];
1614  }
1615 
1616  {
1618  == (Fcb->Header.AllocationSize.QuadPart / BLOCK_SIZE));
1619 
1620  ASSERT(FFSTotalBlocks(Vcb, (ULONG)(Fcb->Header.AllocationSize.QuadPart / BLOCK_SIZE))
1621  == (dinode1->di_blocks / (BLOCK_SIZE / SECTOR_SIZE)));
1622  }
1623 
1624 
1625  FFSv1SaveInode(IrpContext, Vcb, Fcb->FFSMcb->Inode, dinode1);
1626 
1627  if (bRet && dwNewBlk)
1628  {
1629  if (dwRet)
1630  {
1631  Fcb->BlkHint = dwNewBlk+1;
1632  *dwRet = dwNewBlk;
1633 
1634  FFSPrint((DBG_INFO, "FFSExpandInode: %S (%xh) i=%2.2xh Index=%8.8xh New Block=%8.8xh\n", Fcb->FFSMcb->ShortName.Buffer, Fcb->FFSMcb->Inode, i, Index, dwNewBlk));
1635  }
1636 
1637  return TRUE;
1638  }
1639 
1640  return FALSE;
1641 }
#define NDADDR
Definition: dinode.h:77
ULONG FFSTotalBlocks(PFFS_VCB Vcb, ULONG DataBlocks)
Definition: ffs.c:2988
#define TRUE
Definition: types.h:120
FSRTL_ADVANCED_FCB_HEADER Header
Definition: cdstruc.h:931
#define PAGED_CODE()
Definition: video.h:57
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
__drv_mustHoldCriticalRegion BOOLEAN FFSv1SaveInode(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN ULONG Inode, IN PFFSv1_INODE dinode1)
Definition: ffs.c:407
BOOLEAN FFSNewBlock(PFFS_IRP_CONTEXT IrpContext, PFFS_VCB Vcb, ULONG GroupHint, ULONG BlockHint, PULONG dwRet)
Definition: ffs.c:1094
#define SECTOR_SIZE
Definition: winldr.h:34
int32_t di_ib[NIADDR]
Definition: dinode.h:95
unsigned char BOOLEAN
#define BLOCK_BITS
Definition: stream.h:22
#define FFS_BLOCK_TYPES
Definition: ffsdrv.h:67
#define BLOCK_SIZE
Definition: dlist.c:220
#define Vcb
Definition: cdprocs.h:1425
static const UCHAR Index[8]
Definition: usbohci.c:18
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define DBG_ERROR
Definition: ffsdrv.h:1031
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
__drv_mustHoldCriticalRegion BOOLEAN FFSExpandBlock(PFFS_IRP_CONTEXT IrpContext, PFFS_VCB Vcb, PFFS_FCB Fcb, ULONG dwContent, ULONG Index, ULONG layer, BOOLEAN bNew, ULONG *dwRet)
Definition: ffs.c:1406
unsigned int ULONG
Definition: retypes.h:1
#define INODES_PER_GROUP
Definition: ext2fs.h:99
#define DBG_INFO
Definition: ffsdrv.h:1034
_In_ PFCB Fcb
Definition: cdprocs.h:151
ULONG FFSDataBlocks(PFFS_VCB Vcb, ULONG TotalBlocks)
Definition: ffs.c:2930
FILE_NAME_NODE ShortName
Definition: fatstruc.h:1111
int32_t di_db[NDADDR]
Definition: dinode.h:94
u_int32_t di_blocks
Definition: dinode.h:97

Referenced by FFSAddEntry(), and FFSExpandFile().

◆ FFSFreeBlock()

BOOLEAN FFSFreeBlock ( PFFS_IRP_CONTEXT  IrpContext,
PFFS_VCB  Vcb,
ULONG  Block 
)

Definition at line 1296 of file ffs.c.

1300 {
1301  RTL_BITMAP BlockBitmap;
1303  ULONG Length;
1304 
1305  PBCB BitmapBcb;
1306  PVOID BitmapCache;
1307 
1308  ULONG Group, dwBlk;
1309  BOOLEAN bModified = FALSE;
1310 
1311  PAGED_CODE();
1312 
1313 #if 0
1314  if (Block < FFS_FIRST_DATA_BLOCK || Block > (BLOCKS_PER_GROUP * Vcb->ffs_groups))
1315  {
1316  FFSBreakPoint();
1317  return TRUE;
1318  }
1319 
1320  FFSPrint((DBG_INFO, "FFSFreeBlock: Block %xh to be freed.\n", Block));
1321 
1323 
1324  dwBlk = (Block - FFS_FIRST_DATA_BLOCK) % BLOCKS_PER_GROUP;
1325 
1326  {
1327  Offset.QuadPart = (LONGLONG) Vcb->BlockSize;
1328  Offset.QuadPart = Offset.QuadPart * Vcb->ffs_group_desc[Group].bg_block_bitmap;
1329 
1330  if (Group == Vcb->ffs_groups - 1)
1331  {
1333 
1334  /* s_blocks_count is integer multiple of s_blocks_per_group */
1335  if (Length == 0)
1336  {
1338  }
1339  }
1340  else
1341  {
1343  }
1344 
1345  if (!CcPinRead(Vcb->StreamObj,
1346  &Offset,
1347  Vcb->BlockSize,
1348  PIN_WAIT,
1349  &BitmapBcb,
1350  &BitmapCache))
1351  {
1352  FFSPrint((DBG_ERROR, "FFSDeleteBlock: PinReading error ...\n"));
1353  return FALSE;
1354  }
1355 
1356  RtlInitializeBitMap(&BlockBitmap,
1357  BitmapCache,
1358  Length);
1359 
1360  if (RtlCheckBit(&BlockBitmap, dwBlk) == 0)
1361  {
1362 
1363  }
1364  else
1365  {
1366  RtlClearBits(&BlockBitmap, dwBlk, 1);
1367  bModified = TRUE;
1368  }
1369 
1370  if (!bModified)
1371  {
1372  CcUnpinData(BitmapBcb);
1373  BitmapBcb = NULL;
1374  BitmapCache = NULL;
1375 
1376  RtlZeroMemory(&BlockBitmap, sizeof(RTL_BITMAP));
1377  }
1378  }
1379 
1380  if (bModified)
1381  {
1382  CcSetDirtyPinnedData(BitmapBcb, NULL);
1383 
1384  FFSRepinBcb(IrpContext, BitmapBcb);
1385 
1386  CcUnpinData(BitmapBcb);
1387 
1388  FFSAddMcbEntry(Vcb, Offset.QuadPart, (LONGLONG)Vcb->BlockSize);
1389 
1390  //Updating Group Desc / Superblock
1391  Vcb->ffs_group_desc[Group].bg_free_blocks_count++;
1392  FFSSaveGroup(IrpContext, Vcb);
1393 
1394  Vcb->ffs_super_block->s_free_blocks_count++;
1395  FFSSaveSuper(IrpContext, Vcb);
1396 
1397  return TRUE;
1398  }
1399 #endif
1400  return FALSE;
1401 }
NTSYSAPI void WINAPI RtlClearBits(PRTL_BITMAP, ULONG, ULONG)
#define TRUE
Definition: types.h:120
NTSYSAPI void WINAPI RtlInitializeBitMap(PRTL_BITMAP, PULONG, ULONG)
VOID NTAPI CcSetDirtyPinnedData(IN PVOID BcbVoid, IN OPTIONAL PLARGE_INTEGER Lsn)
Definition: cachesub.c:121
_In_opt_ PSID Group
Definition: rtlfuncs.h:1606
VOID NTAPI CcUnpinData(IN PVOID Bcb)
Definition: pinsup.c:955
#define PIN_WAIT
#define RtlCheckBit(BMH, BP)
Definition: rtlfuncs.h:3154
#define FFS_FIRST_DATA_BLOCK
Definition: ffsdrv.h:256
#define PAGED_CODE()
Definition: video.h:57
#define FFSBreakPoint()
Definition: ffsdrv.h:43
BOOLEAN FFSSaveGroup(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb)
VOID FFSRepinBcb(IN PFFS_IRP_CONTEXT IrpContext, IN PBCB Bcb)
Definition: memory.c:221
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define TOTAL_BLOCKS
Definition: ext2fs.h:101
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
__drv_mustHoldCriticalRegion BOOLEAN FFSAddMcbEntry(IN PFFS_VCB Vcb, IN LONGLONG Lba, IN LONGLONG Length)
Definition: ffs.c:2673
int64_t LONGLONG
Definition: typedefs.h:66
__drv_mustHoldCriticalRegion BOOLEAN FFSSaveSuper(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb)
Definition: ffs.c:112
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
BOOLEAN NTAPI CcPinRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG Flags, OUT PVOID *Bcb, OUT PVOID *Buffer)
Definition: pinsup.c:802
#define DBG_ERROR
Definition: ffsdrv.h:1031
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define DBG_INFO
Definition: ffsdrv.h:1034
#define BLOCKS_PER_GROUP
Definition: ext2fs.h:100

Referenced by FFSTruncateBlock().

◆ FFSFreeInode()

BOOLEAN FFSFreeInode ( PFFS_IRP_CONTEXT  IrpContext,
PFFS_VCB  Vcb,
ULONG  Inode,
ULONG  Type 
)

Definition at line 1857 of file ffs.c.

1862 {
1863  RTL_BITMAP InodeBitmap;
1864  PVOID BitmapCache;
1865  PBCB BitmapBcb;
1866 
1867  ULONG Group;
1868  ULONG Length;
1870 
1871  ULONG dwIno;
1872  BOOLEAN bModified = FALSE;
1873 
1874  PAGED_CODE();
1875 
1876 #if 0
1877  Group = (Inode - 1) / INODES_PER_GROUP;
1878  dwIno = (Inode - 1) % INODES_PER_GROUP;
1879 
1880  FFSPrint((DBG_INFO, "FFSFreeInode: Inode: %xh (Group/Off = %xh/%xh)\n",
1881  Inode, Group, dwIno));
1882 
1883  {
1884  Offset.QuadPart = (LONGLONG) Vcb->BlockSize;
1885  Offset.QuadPart = Offset.QuadPart * Vcb->ffs_group_desc[Group].bg_inode_bitmap;
1886  if (Group == Vcb->ffs_groups - 1)
1887  {
1889  if (!Length)
1890  { /* s_inodes_count is integer multiple of s_inodes_per_group */
1892  }
1893  }
1894  else
1895  {
1897  }
1898 
1899  if (!CcPinRead(Vcb->StreamObj,
1900  &Offset,
1901  Vcb->BlockSize,
1902  PIN_WAIT,
1903  &BitmapBcb,
1904  &BitmapCache))
1905  {
1906  FFSPrint((DBG_ERROR, "FFSFreeInode: PinReading error ...\n"));
1907  return FALSE;
1908  }
1909 
1910  RtlInitializeBitMap(&InodeBitmap,
1911  BitmapCache,
1912  Length);
1913 
1914  if (RtlCheckBit(&InodeBitmap, dwIno) == 0)
1915  {
1916 
1917  }
1918  else
1919  {
1920  RtlClearBits(&InodeBitmap, dwIno, 1);
1921  bModified = TRUE;
1922  }
1923 
1924  if (!bModified)
1925  {
1926  CcUnpinData(BitmapBcb);
1927  BitmapBcb = NULL;
1928  BitmapCache = NULL;
1929 
1930  RtlZeroMemory(&InodeBitmap, sizeof(RTL_BITMAP));
1931  }
1932  }
1933 
1934  if (bModified)
1935  {
1936  CcSetDirtyPinnedData(BitmapBcb, NULL);
1937 
1938  FFSRepinBcb(IrpContext, BitmapBcb);
1939 
1940  CcUnpinData(BitmapBcb);
1941 
1942  FFSAddMcbEntry(Vcb, Offset.QuadPart, (LONGLONG)Vcb->BlockSize);
1943 
1944  //Updating Group Desc / Superblock
1945  if (Type == DT_DIR)
1946  {
1947  Vcb->ffs_group_desc[Group].bg_used_dirs_count--;
1948  }
1949 
1950  Vcb->ffs_group_desc[Group].bg_free_inodes_count++;
1951  FFSSaveGroup(IrpContext, Vcb);
1952 
1953  Vcb->ffs_super_block->s_free_inodes_count++;
1954  FFSSaveSuper(IrpContext, Vcb);
1955 
1956  return TRUE;
1957  }
1958 #endif
1959  return FALSE;
1960 }
NTSYSAPI void WINAPI RtlClearBits(PRTL_BITMAP, ULONG, ULONG)
#define TRUE
Definition: types.h:120
NTSYSAPI void WINAPI RtlInitializeBitMap(PRTL_BITMAP, PULONG, ULONG)
Type
Definition: Type.h:6
VOID NTAPI CcSetDirtyPinnedData(IN PVOID BcbVoid, IN OPTIONAL PLARGE_INTEGER Lsn)
Definition: cachesub.c:121
_In_opt_ PSID Group
Definition: rtlfuncs.h:1606
VOID NTAPI CcUnpinData(IN PVOID Bcb)
Definition: pinsup.c:955
#define PIN_WAIT
#define RtlCheckBit(BMH, BP)
Definition: rtlfuncs.h:3154
#define PAGED_CODE()
Definition: video.h:57
#define DT_DIR
Definition: fs.h:149
BOOLEAN FFSSaveGroup(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb)
VOID FFSRepinBcb(IN PFFS_IRP_CONTEXT IrpContext, IN PBCB Bcb)
Definition: memory.c:221
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
__drv_mustHoldCriticalRegion BOOLEAN FFSAddMcbEntry(IN PFFS_VCB Vcb, IN LONGLONG Lba, IN LONGLONG Length)
Definition: ffs.c:2673
int64_t LONGLONG
Definition: typedefs.h:66
__drv_mustHoldCriticalRegion BOOLEAN FFSSaveSuper(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb)
Definition: ffs.c:112
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
BOOLEAN NTAPI CcPinRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG Flags, OUT PVOID *Bcb, OUT PVOID *Buffer)
Definition: pinsup.c:802
#define DBG_ERROR
Definition: ffsdrv.h:1031
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
unsigned int ULONG
Definition: retypes.h:1
#define INODES_PER_GROUP
Definition: ext2fs.h:99
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define INODES_COUNT
Definition: ext2fs.h:97
#define DBG_INFO
Definition: ffsdrv.h:1034

Referenced by FFSCreateInode(), and FFSDeleteFile().

◆ FFSLoadSuper()

PFFS_SUPER_BLOCK FFSLoadSuper ( IN PFFS_VCB  Vcb,
IN BOOLEAN  bVerify,
IN ULONGLONG  SuperBlockOffset 
)

Definition at line 75 of file ffs.c.

79 {
81  PFFS_SUPER_BLOCK FFSSb = NULL;
82 
83  PAGED_CODE();
84 
86  if (!FFSSb)
87  {
88  return NULL;
89  }
90 
92  SuperBlockOffset,
94  (PVOID)FFSSb,
95  bVerify);
96 
97  if (!NT_SUCCESS(Status))
98  {
99  FFSPrint((DBG_ERROR, "FFSLoadSuper: Read Block Device error.\n"));
100 
101  ExFreePool(FFSSb);
102  return NULL;
103  }
104 
105  return FFSSb;
106 }
LONG NTSTATUS
Definition: precomp.h:26
Definition: fs.h:235
#define PAGED_CODE()
Definition: video.h:57
NTSTATUS FFSReadDisk(IN PFFS_VCB Vcb, IN ULONGLONG Offset, IN ULONG Size, IN PVOID Buffer, IN BOOLEAN bVerify)
Definition: block.c:448
struct fs * PFFS_SUPER_BLOCK
Definition: ffsdrv.h:258
smooth NULL
Definition: ftsmooth.c:416
static BOOL bVerify
Definition: verify.c:27
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define Vcb
Definition: cdprocs.h:1425
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define DBG_ERROR
Definition: ffsdrv.h:1031
#define FFS_POOL_TAG
Definition: ffsdrv.h:817
#define SUPER_BLOCK_SIZE
Definition: ext2fs.h:86
Status
Definition: gdiplustypes.h:24
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by FFSLoadDiskLabel(), and FFSVerifyVolume().

◆ FFSLookupMcbEntry()

__drv_mustHoldCriticalRegion BOOLEAN FFSLookupMcbEntry ( IN PFFS_VCB  Vcb,
IN LONGLONG  Lba,
OUT PLONGLONG  pLba,
OUT PLONGLONG  pLength,
OUT PLONGLONG  RunStart,
OUT PLONGLONG  RunLength,
OUT PULONG  Index 
)

Definition at line 2860 of file ffs.c.

2868 {
2869  BOOLEAN bRet;
2870  LONGLONG Offset;
2871 
2872  PAGED_CODE();
2873 
2874  Offset = Lba & (~((LONGLONG)BLOCK_SIZE - 1));
2875  ASSERT ((Offset & (BLOCK_SIZE - 1)) == 0);
2876 
2877  ASSERT(Lba == Offset);
2878 
2879  Offset = (Offset >> BLOCK_BITS) + 1;
2880 
2882  &(Vcb->McbResource),
2883  TRUE);
2884 
2885  bRet = FsRtlLookupLargeMcbEntry(
2886  &(Vcb->DirtyMcbs),
2887  Offset,
2888  pLba,
2889  pLength,
2890  RunStart,
2891  RunLength,
2892  Index);
2893 
2895  &(Vcb->McbResource),
2897 
2898  if (bRet)
2899  {
2900  if (pLba && ((*pLba) != -1))
2901  {
2902  ASSERT((*pLba) > 0);
2903 
2904  (*pLba) = (((*pLba) - 1) << BLOCK_BITS);
2905  (*pLba) += ((Lba) & ((LONGLONG)BLOCK_SIZE - 1));
2906  }
2907 
2908  if (pLength)
2909  {
2910  (*pLength) <<= BLOCK_BITS;
2911  (*pLength) -= ((Lba) & ((LONGLONG)BLOCK_SIZE - 1));
2912  }
2913 
2914  if (RunStart && (*RunStart != -1))
2915  {
2916  (*RunStart) = (((*RunStart) - 1) << BLOCK_BITS);
2917  }
2918 
2919  if (RunLength)
2920  {
2921  (*RunLength) <<= BLOCK_BITS;
2922  }
2923  }
2924 
2925  return bRet;
2926 }
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
#define TRUE
Definition: types.h:120
#define PAGED_CODE()
Definition: video.h:57
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
unsigned char BOOLEAN
#define BLOCK_BITS
Definition: stream.h:22
int64_t LONGLONG
Definition: typedefs.h:66
#define BLOCK_SIZE
Definition: dlist.c:220
#define Vcb
Definition: cdprocs.h:1425
static const UCHAR Index[8]
Definition: usbohci.c:18
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
BOOLEAN NTAPI FsRtlLookupLargeMcbEntry(IN PLARGE_MCB Mcb, IN LONGLONG Vbn, OUT PLONGLONG Lbn OPTIONAL, OUT PLONGLONG SectorCountFromLbn OPTIONAL, OUT PLONGLONG StartingLbn OPTIONAL, OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, OUT PULONG Index OPTIONAL)
Definition: largemcb.c:564
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844

Referenced by FFSWriteVolume().

◆ FFSNewBlock()

BOOLEAN FFSNewBlock ( PFFS_IRP_CONTEXT  IrpContext,
PFFS_VCB  Vcb,
ULONG  GroupHint,
ULONG  BlockHint,
PULONG  dwRet 
)

Definition at line 1094 of file ffs.c.

1100 {
1101  RTL_BITMAP BlockBitmap;
1103  ULONG Length;
1104 
1105  PBCB BitmapBcb;
1106  PVOID BitmapCache;
1107 
1108  ULONG Group = 0, dwBlk, dwHint = 0;
1109 
1110  PAGED_CODE();
1111 
1112 #if 0
1113  *dwRet = 0;
1114  dwBlk = 0XFFFFFFFF;
1115 
1116  if (GroupHint > Vcb->ffs_groups)
1117  GroupHint = Vcb->ffs_groups - 1;
1118 
1119  if (BlockHint != 0)
1120  {
1121  GroupHint = (BlockHint - FFS_FIRST_DATA_BLOCK) / BLOCKS_PER_GROUP;
1122  dwHint = (BlockHint - FFS_FIRST_DATA_BLOCK) % BLOCKS_PER_GROUP;
1123  }
1124 
1125 ScanBitmap:
1126 
1127  // Perform Prefered Group
1128  if (Vcb->ffs_group_desc[GroupHint].bg_free_blocks_count)
1129  {
1130  Offset.QuadPart = (LONGLONG) Vcb->BlockSize;
1131  Offset.QuadPart = Offset.QuadPart *
1132  Vcb->ffs_group_desc[GroupHint].bg_block_bitmap;
1133 
1134  if (GroupHint == Vcb->ffs_groups - 1)
1135  {
1137 
1138  /* s_blocks_count is integer multiple of s_blocks_per_group */
1139  if (Length == 0)
1140  {
1142  }
1143  }
1144  else
1145  {
1147  }
1148 
1149  if (!CcPinRead(Vcb->StreamObj,
1150  &Offset,
1151  Vcb->BlockSize,
1152  PIN_WAIT,
1153  &BitmapBcb,
1154  &BitmapCache))
1155  {
1156  FFSPrint((DBG_ERROR, "FFSNewBlock: PinReading error ...\n"));
1157  return FALSE;
1158  }
1159 
1160  RtlInitializeBitMap(&BlockBitmap,
1161  BitmapCache,
1162  Length);
1163 
1164  Group = GroupHint;
1165 
1166  if (RtlCheckBit(&BlockBitmap, dwHint) == 0)
1167  {
1168  dwBlk = dwHint;
1169  }
1170  else
1171  {
1172  dwBlk = RtlFindClearBits(&BlockBitmap, 1, dwHint);
1173  }
1174 
1175  // We could not get new block in the prefered group.
1176  if (dwBlk == 0xFFFFFFFF)
1177  {
1178  CcUnpinData(BitmapBcb);
1179  BitmapBcb = NULL;
1180  BitmapCache = NULL;
1181 
1182  RtlZeroMemory(&BlockBitmap, sizeof(RTL_BITMAP));
1183  }
1184  }
1185 
1186  if (dwBlk == 0xFFFFFFFF)
1187  {
1188  for(Group = 0; Group < Vcb->ffs_groups; Group++)
1189  if (Vcb->ffs_group_desc[Group].bg_free_blocks_count)
1190  {
1191 
1192  if (Group == GroupHint)
1193  continue;
1194 
1195  Offset.QuadPart = (LONGLONG) Vcb->BlockSize;
1196  Offset.QuadPart = Offset.QuadPart * Vcb->ffs_group_desc[Group].bg_block_bitmap;
1197 
1198  if (Vcb->ffs_groups == 1)
1199  {
1200  Length = TOTAL_BLOCKS;
1201  }
1202  else
1203  {
1204  if (Group == Vcb->ffs_groups - 1)
1205  {
1207 
1208  /* s_blocks_count is integer multiple of s_blocks_per_group */
1209  if (Length == 0)
1210  {
1212  }
1213  }
1214  else
1215  {
1217  }
1218  }
1219 
1220  if (!CcPinRead(Vcb->StreamObj,
1221  &Offset,
1222  Vcb->BlockSize,
1223  PIN_WAIT,
1224  &BitmapBcb,
1225  &BitmapCache))
1226  {
1227  FFSPrint((DBG_ERROR, "FFSNewBlock: PinReading error ...\n"));
1228  return FALSE;
1229  }
1230 
1231  RtlInitializeBitMap(&BlockBitmap,
1232  BitmapCache,
1233  Length);
1234 
1235  dwBlk = RtlFindClearBits(&BlockBitmap, 1, 0);
1236 
1237  if (dwBlk != 0xFFFFFFFF)
1238  {
1239  break;
1240  }
1241  else
1242  {
1243  CcUnpinData(BitmapBcb);
1244  BitmapBcb = NULL;
1245  BitmapCache = NULL;
1246 
1247  RtlZeroMemory(&BlockBitmap, sizeof(RTL_BITMAP));
1248  }
1249  }
1250  }
1251 
1252  if (dwBlk < Length)
1253  {
1254  RtlSetBits(&BlockBitmap, dwBlk, 1);
1255 
1256  CcSetDirtyPinnedData(BitmapBcb, NULL);
1257 
1258  FFSRepinBcb(IrpContext, BitmapBcb);
1259 
1260  CcUnpinData(BitmapBcb);
1261 
1262  FFSAddMcbEntry(Vcb, Offset.QuadPart, (LONGLONG)Vcb->BlockSize);
1263 
1264  *dwRet = dwBlk + FFS_FIRST_DATA_BLOCK + Group * BLOCKS_PER_GROUP;
1265 
1266  //Updating Group Desc / Superblock
1267  Vcb->ffs_group_desc[Group].bg_free_blocks_count--;
1268  FFSSaveGroup(IrpContext, Vcb);
1269 
1270  Vcb->ffs_super_block->s_free_blocks_count--;
1271  FFSSaveSuper(IrpContext, Vcb);
1272 
1273  {
1274  ULONG i = 0;
1275  for (i = 0; i < Vcb->ffs_groups; i++)
1276  {
1277  if ((Vcb->ffs_group_desc[i].bg_block_bitmap == *dwRet) ||
1278  (Vcb->ffs_group_desc[i].bg_inode_bitmap == *dwRet) ||
1279  (Vcb->ffs_group_desc[i].bg_inode_table == *dwRet))
1280  {
1281  FFSBreakPoint();
1282  GroupHint = Group;
1283  goto ScanBitmap;
1284  }
1285  }
1286  }
1287 
1288  return TRUE;
1289  }
1290 #endif
1291  return FALSE;
1292 }
#define TRUE
Definition: types.h:120
NTSYSAPI void WINAPI RtlInitializeBitMap(PRTL_BITMAP, PULONG, ULONG)
VOID NTAPI CcSetDirtyPinnedData(IN PVOID BcbVoid, IN OPTIONAL PLARGE_INTEGER Lsn)
Definition: cachesub.c:121
_In_opt_ PSID Group
Definition: rtlfuncs.h:1606
VOID NTAPI CcUnpinData(IN PVOID Bcb)
Definition: pinsup.c:955
#define PIN_WAIT
#define RtlCheckBit(BMH, BP)
Definition: rtlfuncs.h:3154
#define FFS_FIRST_DATA_BLOCK
Definition: ffsdrv.h:256
#define PAGED_CODE()
Definition: video.h:57
#define FFSBreakPoint()
Definition: ffsdrv.h:43
BOOLEAN FFSSaveGroup(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb)
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
VOID FFSRepinBcb(IN PFFS_IRP_CONTEXT IrpContext, IN PBCB Bcb)
Definition: memory.c:221
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define TOTAL_BLOCKS
Definition: ext2fs.h:101
smooth NULL
Definition: ftsmooth.c:416
__drv_mustHoldCriticalRegion BOOLEAN FFSAddMcbEntry(IN PFFS_VCB Vcb, IN LONGLONG Lba, IN LONGLONG Length)
Definition: ffs.c:2673
int64_t LONGLONG
Definition: typedefs.h:66
__drv_mustHoldCriticalRegion BOOLEAN FFSSaveSuper(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb)
Definition: ffs.c:112
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
BOOLEAN NTAPI CcPinRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG Flags, OUT PVOID *Bcb, OUT PVOID *Buffer)
Definition: pinsup.c:802
#define DBG_ERROR
Definition: ffsdrv.h:1031
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
NTSYSAPI void WINAPI RtlSetBits(PRTL_BITMAP, ULONG, ULONG)
NTSYSAPI ULONG WINAPI RtlFindClearBits(PCRTL_BITMAP, ULONG, ULONG)
#define BLOCKS_PER_GROUP
Definition: ext2fs.h:100

Referenced by FFSExpandBlock(), and FFSExpandInode().

◆ FFSNewInode()

NTSTATUS FFSNewInode ( PFFS_IRP_CONTEXT  IrpContext,
PFFS_VCB  Vcb,
ULONG  GroupHint,
ULONG  Type,
PULONG  Inode 
)

Definition at line 1645 of file ffs.c.

1651 {
1652  RTL_BITMAP InodeBitmap;
1653  PVOID BitmapCache;
1654  PBCB BitmapBcb;
1655 
1656  ULONG Group, i, j;
1657  ULONG Average, Length;
1659 
1660  ULONG dwInode;
1661 
1662  PAGED_CODE();
1663 
1664 #if 0
1665  *Inode = dwInode = 0XFFFFFFFF;
1666 
1667 repeat:
1668 
1669  Group = i = 0;
1670 
1671  if (Type == DT_DIR)
1672  {
1673  Average = Vcb->ffs_super_block->s_free_inodes_count / Vcb->ffs_groups;
1674 
1675  for (j = 0; j < Vcb->ffs_groups; j++)
1676  {
1677  i = (j + GroupHint) % (Vcb->ffs_groups);
1678 
1679  if ((Vcb->ffs_group_desc[i].bg_used_dirs_count << 8) <
1680  Vcb->ffs_group_desc[i].bg_free_inodes_count)
1681  {
1682  Group = i + 1;
1683  break;
1684  }
1685  }
1686 
1687  if (!Group)
1688  {
1689  for (j = 0; j < Vcb->ffs_groups; j++)
1690  {
1691  if (Vcb->ffs_group_desc[j].bg_free_inodes_count >= Average)
1692  {
1693  if (!Group || (Vcb->ffs_group_desc[j].bg_free_blocks_count > Vcb->ffs_group_desc[Group].bg_free_blocks_count))
1694  Group = j + 1;
1695  }
1696  }
1697  }
1698  }
1699  else
1700  {
1701  /*
1702  * Try to place the inode in its parent directory (GroupHint)
1703  */
1704  if (Vcb->ffs_group_desc[GroupHint].bg_free_inodes_count)
1705  {
1706  Group = GroupHint + 1;
1707  }
1708  else
1709  {
1710  i = GroupHint;
1711 
1712  /*
1713  * Use a quadratic hash to find a group with a
1714  * free inode
1715  */
1716  for (j = 1; j < Vcb->ffs_groups; j <<= 1)
1717  {
1718 
1719  i += j;
1720  if (i > Vcb->ffs_groups)
1721  i -= Vcb->ffs_groups;
1722 
1723  if (Vcb->ffs_group_desc[i].bg_free_inodes_count)
1724  {
1725  Group = i + 1;
1726  break;
1727  }
1728  }
1729  }
1730 
1731  if (!Group) {
1732  /*
1733  * That failed: try linear search for a free inode
1734  */
1735  i = GroupHint + 1;
1736  for (j = 2; j < Vcb->ffs_groups; j++)
1737  {
1738  if (++i >= Vcb->ffs_groups) i = 0;
1739 
1740  if (Vcb->ffs_group_desc[i].bg_free_inodes_count)
1741  {
1742  Group = i + 1;
1743  break;
1744  }
1745  }
1746  }
1747  }
1748 
1749  // Could not find a proper group.
1750  if (!Group)
1751  {
1752  return STATUS_DISK_FULL;
1753  }
1754  else
1755  {
1756  Group--;
1757 
1758  Offset.QuadPart = (LONGLONG) Vcb->BlockSize;
1759  Offset.QuadPart = Offset.QuadPart * Vcb->ffs_group_desc[Group].bg_inode_bitmap;
1760 
1761  if (Vcb->ffs_groups == 1)
1762  {
1763  Length = INODES_COUNT;
1764  }
1765  else
1766  {
1767  if (Group == Vcb->ffs_groups - 1)
1768  {
1770  if (!Length)
1771  {
1772  /* INODES_COUNT is integer multiple of INODES_PER_GROUP */
1774  }
1775  }
1776  else
1777  {
1779  }
1780  }
1781 
1782  if (!CcPinRead(Vcb->StreamObj,
1783  &Offset,
1784  Vcb->BlockSize,
1785  PIN_WAIT,
1786  &BitmapBcb,
1787  &BitmapCache))
1788  {
1789  FFSPrint((DBG_ERROR, "FFSNewInode: PinReading error ...\n"));
1790 
1791  return STATUS_UNSUCCESSFUL;
1792  }
1793 
1794  RtlInitializeBitMap(&InodeBitmap,
1795  BitmapCache,
1796  Length);
1797 
1798  dwInode = RtlFindClearBits(&InodeBitmap, 1, 0);
1799 
1800  if (dwInode == 0xFFFFFFFF)
1801  {
1802  CcUnpinData(BitmapBcb);
1803  BitmapBcb = NULL;
1804  BitmapCache = NULL;
1805 
1806  RtlZeroMemory(&InodeBitmap, sizeof(RTL_BITMAP));
1807  }
1808  }
1809 
1810  if (dwInode == 0xFFFFFFFF || dwInode >= Length)
1811  {
1812  if (Vcb->ffs_group_desc[Group].bg_free_inodes_count != 0)
1813  {
1814  Vcb->ffs_group_desc[Group].bg_free_inodes_count = 0;
1815 
1816  FFSSaveGroup(IrpContext, Vcb);
1817  }
1818 
1819  goto repeat;
1820  }
1821  else
1822  {
1823  RtlSetBits(&InodeBitmap, dwInode, 1);
1824 
1825  CcSetDirtyPinnedData(BitmapBcb, NULL);
1826 
1827  FFSRepinBcb(IrpContext, BitmapBcb);
1828 
1829  CcUnpinData(BitmapBcb);
1830 
1831  FFSAddMcbEntry(Vcb, Offset.QuadPart, (LONGLONG)Vcb->BlockSize);
1832 
1833  *Inode = dwInode + 1 + Group * INODES_PER_GROUP;
1834 
1835  //Updating Group Desc / Superblock
1836  Vcb->ffs_group_desc[Group].bg_free_inodes_count--;
1837  if (Type == FFS_FT_DIR)
1838  {
1839  Vcb->ffs_group_desc[Group].bg_used_dirs_count++;
1840  }
1841 
1842  FFSSaveGroup(IrpContext, Vcb);
1843 
1844  Vcb->ffs_super_block->s_free_inodes_count--;
1845  FFSSaveSuper(IrpContext, Vcb);
1846 
1847  return STATUS_SUCCESS;
1848  }
1849 
1850  return STATUS_DISK_FULL;
1851 #endif
1852  return STATUS_UNSUCCESSFUL;
1853 }
NTSYSAPI void WINAPI RtlInitializeBitMap(PRTL_BITMAP, PULONG, ULONG)
Type
Definition: Type.h:6
VOID NTAPI CcSetDirtyPinnedData(IN PVOID BcbVoid, IN OPTIONAL PLARGE_INTEGER Lsn)
Definition: cachesub.c:121
_In_opt_ PSID Group
Definition: rtlfuncs.h:1606
VOID NTAPI CcUnpinData(IN PVOID Bcb)
Definition: pinsup.c:955
#define PIN_WAIT
#define PAGED_CODE()
Definition: video.h:57
#define DT_DIR
Definition: fs.h:149
BOOLEAN FFSSaveGroup(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb)
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
VOID FFSRepinBcb(IN PFFS_IRP_CONTEXT IrpContext, IN PBCB Bcb)
Definition: memory.c:221
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
smooth NULL
Definition: ftsmooth.c:416
__drv_mustHoldCriticalRegion BOOLEAN FFSAddMcbEntry(IN PFFS_VCB Vcb, IN LONGLONG Lba, IN LONGLONG Length)
Definition: ffs.c:2673
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 GLint GLint j
Definition: glfuncs.h:250
int64_t LONGLONG
Definition: typedefs.h:66
__drv_mustHoldCriticalRegion BOOLEAN FFSSaveSuper(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb)
Definition: ffs.c:112
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
BOOLEAN NTAPI CcPinRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG Flags, OUT PVOID *Bcb, OUT PVOID *Buffer)
Definition: pinsup.c:802
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define DBG_ERROR
Definition: ffsdrv.h:1031
static int repeat
Definition: xmllint.c:143
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
#define STATUS_DISK_FULL
Definition: udferr_usr.h:155
unsigned int ULONG
Definition: retypes.h:1
#define INODES_PER_GROUP
Definition: ext2fs.h:99
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define INODES_COUNT
Definition: ext2fs.h:97
NTSYSAPI void WINAPI RtlSetBits(PRTL_BITMAP, ULONG, ULONG)
return STATUS_SUCCESS
Definition: btrfs.c:2777
NTSYSAPI ULONG WINAPI RtlFindClearBits(PCRTL_BITMAP, ULONG, ULONG)

Referenced by FFSCreateInode().

◆ FFSRemoveEntry()

__drv_mustHoldCriticalRegion NTSTATUS FFSRemoveEntry ( IN PFFS_IRP_CONTEXT  IrpContext,
IN PFFS_VCB  Vcb,
IN PFFS_FCB  Dcb,
IN ULONG  FileType,
IN ULONG  Inode 
)

Definition at line 2203 of file ffs.c.

2209 {
2211 
2212  PFFS_DIR_ENTRY pTarget = NULL;
2213  PFFS_DIR_ENTRY pPrevDir = NULL;
2214 
2215  USHORT PrevRecLen = 0;
2216 
2217  ULONG Length = 0;
2218  ULONG dwBytes = 0;
2219 
2220  BOOLEAN bRet = FALSE;
2221  BOOLEAN MainResourceAcquired = FALSE;
2222 
2223  ULONG dwRet;
2224 
2225  PAGED_CODE();
2226 
2227  if (!IsDirectory(Dcb))
2228  {
2229  return FALSE;
2230  }
2231 
2232  MainResourceAcquired =
2233  ExAcquireResourceExclusiveLite(&Dcb->MainResource, TRUE);
2234 
2235  _SEH2_TRY
2236  {
2237 
2238  Dcb->ReferenceCount++;
2239 
2242  if (!pTarget)
2243  {
2245  _SEH2_LEAVE;
2246  }
2247 
2250  if (!pPrevDir)
2251  {
2253  _SEH2_LEAVE;
2254  }
2255 
2256  dwBytes = 0;
2257 
2258  while ((LONGLONG)dwBytes < Dcb->Header.AllocationSize.QuadPart)
2259  {
2261 
2263  NULL,
2264  Vcb,
2265  Dcb->dinode1,
2266  dwBytes,
2267  (PVOID)pTarget,
2269  &dwRet);
2270 
2271  if (!NT_SUCCESS(Status))
2272  {
2273  FFSPrint((DBG_ERROR, "FFSRemoveEntry: Reading Directory Content error.\n"));
2274  _SEH2_LEAVE;
2275  }
2276 
2277  if (pTarget->d_ino == Inode)
2278  {
2279  ULONG dwRet;
2280  ULONG RecLen;
2281 
2282  if ((PrevRecLen + pTarget->d_reclen) < MAXIMUM_RECORD_LENGTH)
2283  {
2284  pPrevDir->d_reclen += pTarget->d_reclen;
2285  RecLen = FFS_DIR_REC_LEN(pTarget->d_namlen);
2286 
2287  RtlZeroMemory(pTarget, RecLen);
2288 
2289  FFSv1WriteInode(IrpContext, Vcb, Dcb->dinode1, dwBytes - PrevRecLen, pPrevDir, 8, FALSE, &dwRet);
2290  FFSv1WriteInode(IrpContext, Vcb, Dcb->dinode1, dwBytes, pTarget, RecLen, FALSE, &dwRet);
2291  }
2292  else
2293  {
2294  RecLen = (ULONG)pTarget->d_reclen;
2295  if (RecLen > FFS_DIR_REC_LEN(FFS_NAME_LEN))
2296  {
2298  }
2299  else
2300  {
2301  RtlZeroMemory(pTarget, RecLen);
2302  }
2303 
2304  pTarget->d_reclen = (USHORT)RecLen;
2305 
2306  FFSv1WriteInode(IrpContext, Vcb, Dcb->dinode1, dwBytes, pTarget, RecLen, FALSE, &dwRet);
2307  }
2308 
2309  if (FileType == DT_DIR)
2310  {
2311  if(((pTarget->d_namlen == 1) && (pTarget->d_name[0] == '.')) ||
2312  ((pTarget->d_namlen == 2) && (pTarget->d_name[0] == '.') && (pTarget->d_name[1] == '.')))
2313  {
2314  FFSBreakPoint();
2315  }
2316  else
2317  {
2318  Dcb->dinode1->di_nlink--;
2319  }
2320  }
2321 
2322  /* Update at least mtime/atime if !FFS_FT_DIR. */
2323  FFSv1SaveInode(IrpContext, Vcb, Dcb->FFSMcb->Inode, Dcb->dinode1);
2324 
2325  bRet = TRUE;
2326 
2327  break;
2328  }
2329  else
2330  {
2331  RtlCopyMemory(pPrevDir, pTarget, FFS_DIR_REC_LEN(FFS_NAME_LEN));
2332  PrevRecLen = pTarget->d_reclen;
2333  }
2334 
2335  dwBytes += pTarget->d_reclen;
2336  }
2337  }
2338 
2340  {
2341 
2342  Dcb->ReferenceCount--;
2343 
2344  if(MainResourceAcquired)
2346  &Dcb->MainResource,
2348 
2349  if (pTarget != NULL)
2350  {
2351  ExFreePool(pTarget);
2352  }
2353 
2354  if (pPrevDir != NULL)
2355  {
2356  ExFreePool(pPrevDir);
2357  }
2358  } _SEH2_END;
2359 
2360  return bRet;
2361 }
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
Definition: dir.h:83
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
#define FFS_NAME_LEN
Definition: ffsdrv.h:202
LONG NTSTATUS
Definition: precomp.h:26
#define MAXIMUM_RECORD_LENGTH
Definition: ext2fs.h:79
#define FFS_DIR_REC_LEN(name_len)
Definition: ffsdrv.h:214
#define PAGED_CODE()
Definition: video.h:57
_SEH2_TRY
Definition: create.c:4250
#define FFSBreakPoint()
Definition: ffsdrv.h:43
#define DT_DIR
Definition: fs.h:149
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
__drv_mustHoldCriticalRegion BOOLEAN FFSv1SaveInode(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN ULONG Inode, IN PFFSv1_INODE dinode1)
Definition: ffs.c:407
NTSTATUS FFSv1WriteInode(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN PFFSv1_INODE dinode1, IN ULONGLONG offset, IN PVOID Buffer, IN ULONG size, IN BOOLEAN bWriteToDisk, OUT PULONG dwRet)
Definition: write.c:798
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
int64_t LONGLONG
Definition: typedefs.h:66
if(!(yy_init))
Definition: macro.lex.yy.c:714
#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 ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_Must_inspect_result_ _In_ PFLT_INSTANCE _Out_ PBOOLEAN IsDirectory
Definition: fltkernel.h:1139
#define DBG_ERROR
Definition: ffsdrv.h:1031
#define FFS_POOL_TAG
Definition: ffsdrv.h:817
u_int16_t d_reclen
Definition: dir.h:85
Status
Definition: gdiplustypes.h:24
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
_SEH2_END
Definition: create.c:4424
unsigned short USHORT
Definition: pedump.c:61
_SEH2_FINALLY
Definition: create.c:4395
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
#define _SEH2_LEAVE
Definition: filesup.c:20
struct direct * PFFS_DIR_ENTRY
Definition: ffsdrv.h:265
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB * Dcb
Definition: create.c:4157
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by FFSDeleteFile(), and FFSSetRenameInfo().

◆ FFSRemoveMcbEntry()

__drv_mustHoldCriticalRegion VOID FFSRemoveMcbEntry ( IN PFFS_VCB  Vcb,
IN LONGLONG  Lba,
IN LONGLONG  Length 
)

Definition at line 2790 of file ffs.c.

2794 {
2795  LONGLONG Offset;
2796 
2797  PAGED_CODE();
2798 
2799  Offset = Lba & (~((LONGLONG)BLOCK_SIZE - 1));
2800 
2801  Length = (Length + Lba - Offset + BLOCK_SIZE - 1) &
2802  (~((LONGLONG)BLOCK_SIZE - 1));
2803 
2804  ASSERT(Offset == Lba);
2805 
2806  ASSERT ((Offset & (BLOCK_SIZE - 1)) == 0);
2807  ASSERT ((Length & (BLOCK_SIZE - 1)) == 0);
2808 
2809  Offset = (Offset >> BLOCK_BITS) + 1;
2810  Length = (Length >> BLOCK_BITS);
2811 
2812  FFSPrint((DBG_INFO, "FFSRemoveMcbEntry: Lba=%I64xh Length=%I64xh\n",
2813  Offset, Length));
2814 
2816  &(Vcb->McbResource),
2817  TRUE);
2818 
2819  _SEH2_TRY
2820  {
2822  &(Vcb->DirtyMcbs),
2823  Offset, Length);
2824 
2825  }
2827  {
2828  FFSBreakPoint();
2829  } _SEH2_END;
2830 
2831 #if DBG
2832  {
2833  BOOLEAN bFound = FALSE;
2834  LONGLONG DirtyLba, DirtyLen;
2835 
2836  bFound = FsRtlLookupLargeMcbEntry(
2837  &(Vcb->DirtyMcbs),
2838  Offset,
2839  &DirtyLba,
2840  &DirtyLen,
2841  NULL,
2842  NULL,
2843  NULL);
2844 
2845  if (bFound &&(DirtyLba != -1))
2846  {
2847  FFSBreakPoint();
2848  }
2849  }
2850 #endif
2851 
2853  &(Vcb->McbResource),
2855 }
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
#define TRUE
Definition: types.h:120
VOID NTAPI FsRtlRemoveLargeMcbEntry(IN PLARGE_MCB Mcb, IN LONGLONG Vbn, IN LONGLONG SectorCount)
Definition: largemcb.c:862
#define PAGED_CODE()
Definition: video.h:57
_SEH2_TRY
Definition: create.c:4250
#define FFSBreakPoint()
Definition: ffsdrv.h:43
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned char BOOLEAN
#define BLOCK_BITS
Definition: stream.h:22
smooth NULL
Definition: ftsmooth.c:416
int64_t LONGLONG
Definition: typedefs.h:66
#define BLOCK_SIZE
Definition: dlist.c:220
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
BOOLEAN NTAPI FsRtlLookupLargeMcbEntry(IN PLARGE_MCB Mcb, IN LONGLONG Vbn, OUT PLONGLONG Lbn OPTIONAL, OUT PLONGLONG SectorCountFromLbn OPTIONAL, OUT PLONGLONG StartingLbn OPTIONAL, OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, OUT PULONG Index OPTIONAL)
Definition: largemcb.c:564
_SEH2_END
Definition: create.c:4424
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
#define DBG_INFO
Definition: ffsdrv.h:1034
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6

Referenced by FFSExpandBlock(), and FFSWriteVolume().

◆ FFSSaveBlock()

__drv_mustHoldCriticalRegion BOOLEAN FFSSaveBlock ( IN PFFS_IRP_CONTEXT  IrpContext,
IN PFFS_VCB  Vcb,
IN ULONG  dwBlk,
IN PVOID  Buf 
)

Definition at line 525 of file ffs.c.

530 {
532  BOOLEAN bRet;
533 
534  PAGED_CODE();
535 
536  Offset = (LONGLONG)dwBlk;
537  Offset = Offset * Vcb->BlockSize;
538 
539  bRet = FFSSaveBuffer(IrpContext, Vcb, Offset, Vcb->BlockSize, Buf);
540 
541  if (IsFlagOn(Vcb->Flags, VCB_FLOPPY_DISK))
542  {
544  }
545 
546  return bRet;
547 }
VOID FFSStartFloppyFlushDpc(PFFS_VCB Vcb, PFFS_FCB Fcb, PFILE_OBJECT FileObject)
Definition: write.c:160
#define PAGED_CODE()
Definition: video.h:57
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
__drv_mustHoldCriticalRegion BOOLEAN FFSSaveBuffer(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN LONGLONG Offset, IN ULONG Size, IN PVOID Buf)
Definition: ffs.c:552
int64_t LONGLONG
Definition: typedefs.h:66
#define Vcb
Definition: cdprocs.h:1425
#define VCB_FLOPPY_DISK
Definition: ext2fs.h:797

Referenced by FFSExpandBlock().

◆ FFSSaveBuffer()

__drv_mustHoldCriticalRegion BOOLEAN FFSSaveBuffer ( IN PFFS_IRP_CONTEXT  IrpContext,
IN PFFS_VCB  Vcb,
IN LONGLONG  Offset,
IN ULONG  Size,
IN PVOID  Buf 
)

Definition at line 552 of file ffs.c.

558 {
559  PBCB Bcb;
560  PVOID Buffer;
561 
562  PAGED_CODE();
563 
564  if(!CcPinRead(Vcb->StreamObj,
565  (PLARGE_INTEGER) (&Offset),
566  Size,
567  PIN_WAIT,
568  &Bcb,
569  &Buffer))
570  {
571  FFSPrint((DBG_ERROR, "FFSSaveBuffer: PinReading error ...\n"));
572  return FALSE;
573  }
574 
575 
576  /*FFSPrint((DBG_INFO, "FFSSaveBuffer: Off=%I64xh Len=%xh Bcb=%xh\n",
577  Offset, Size, (ULONG)Bcb));*/
578 
579  RtlCopyMemory(Buffer, Buf, Size);
581 
582  FFSRepinBcb(IrpContext, Bcb);
583 
584  CcUnpinData(Bcb);
585 
586  SetFlag(Vcb->StreamObj->Flags, FO_FILE_MODIFIED);
587 
589 
590  return TRUE;
591 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
IN PVCB IN VBO IN ULONG OUT PBCB * Bcb
Definition: fatprocs.h:402
VOID NTAPI CcSetDirtyPinnedData(IN PVOID BcbVoid, IN OPTIONAL PLARGE_INTEGER Lsn)
Definition: cachesub.c:121
VOID NTAPI CcUnpinData(IN PVOID Bcb)
Definition: pinsup.c:955
#define PIN_WAIT
#define PAGED_CODE()
Definition: video.h:57
#define FO_FILE_MODIFIED
Definition: iotypes.h:1744
VOID FFSRepinBcb(IN PFFS_IRP_CONTEXT IrpContext, IN PBCB Bcb)
Definition: memory.c:221
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
smooth NULL
Definition: ftsmooth.c:416
__drv_mustHoldCriticalRegion BOOLEAN FFSAddMcbEntry(IN PFFS_VCB Vcb, IN LONGLONG Lba, IN LONGLONG Length)
Definition: ffs.c:2673
Definition: bufpool.h:45
int64_t LONGLONG
Definition: typedefs.h:66
#define Vcb
Definition: cdprocs.h:1425
BOOLEAN NTAPI CcPinRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG Flags, OUT PVOID *Bcb, OUT PVOID *Buffer)
Definition: pinsup.c:802
#define DBG_ERROR
Definition: ffsdrv.h:1031
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

Referenced by FFSSaveBlock(), FFSSaveSuper(), FFSv1SaveInode(), and FFSv1WriteInode().

◆ FFSSaveSuper()

__drv_mustHoldCriticalRegion BOOLEAN FFSSaveSuper ( IN PFFS_IRP_CONTEXT  IrpContext,
IN PFFS_VCB  Vcb 
)

Definition at line 112 of file ffs.c.

115 {
117  BOOLEAN bRet;
118 
119  PAGED_CODE();
120 
122 
123  bRet = FFSSaveBuffer(IrpContext,
124  Vcb,
125  Offset,
127  Vcb->ffs_super_block);
128 
129  if (IsFlagOn(Vcb->Flags, VCB_FLOPPY_DISK))
130  {
132  }
133 
134  return bRet;
135 }
VOID FFSStartFloppyFlushDpc(PFFS_VCB Vcb, PFFS_FCB Fcb, PFILE_OBJECT FileObject)
Definition: write.c:160
#define PAGED_CODE()
Definition: video.h:57
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
__drv_mustHoldCriticalRegion BOOLEAN FFSSaveBuffer(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN LONGLONG Offset, IN ULONG Size, IN PVOID Buf)
Definition: ffs.c:552
int64_t LONGLONG
Definition: typedefs.h:66
#define Vcb
Definition: cdprocs.h:1425
#define SUPER_BLOCK_SIZE
Definition: ext2fs.h:86
#define VCB_FLOPPY_DISK
Definition: ext2fs.h:797
#define SUPER_BLOCK_OFFSET
Definition: ext2fs.h:85

Referenced by FFSFreeBlock(), FFSFreeInode(), FFSNewBlock(), FFSNewInode(), and FFSSetVolumeInformation().

◆ FFSSetParentEntry()

__drv_mustHoldCriticalRegion NTSTATUS FFSSetParentEntry ( IN PFFS_IRP_CONTEXT  IrpContext,
IN PFFS_VCB  Vcb,
IN PFFS_FCB  Dcb,
IN ULONG  OldParent,
IN ULONG  NewParent 
)

Definition at line 2366 of file ffs.c.

2372 {
2374 
2375  PFFS_DIR_ENTRY pSelf = NULL;
2376  PFFS_DIR_ENTRY pParent = NULL;
2377 
2378  ULONG dwBytes = 0;
2379 
2380  BOOLEAN MainResourceAcquired = FALSE;
2381 
2382  ULONG Offset = 0;
2383 
2384  if (!IsDirectory(Dcb))
2385  {
2387  return Status;
2388  }
2389 
2390  MainResourceAcquired =
2391  ExAcquireResourceExclusiveLite(&Dcb->MainResource, TRUE);
2392 
2393  _SEH2_TRY
2394  {
2395  Dcb->ReferenceCount++;
2396 
2399  if (!pSelf)
2400  {
2402  _SEH2_LEAVE;
2403  }
2404 
2405  dwBytes = 0;
2406 
2407  // Reading the DCB contents
2409  NULL,
2410  Vcb,
2411  Dcb->dinode1,
2412  Offset,
2413  (PVOID)pSelf,
2415  &dwBytes);
2416 
2417  if (!NT_SUCCESS(Status))
2418  {
2419  FFSPrint((DBG_ERROR, "FFSSetParentEntry: Reading Directory Content error.\n"));
2420  _SEH2_LEAVE;
2421  }
2422 
2423  ASSERT(dwBytes == FFS_DIR_REC_LEN(1) + FFS_DIR_REC_LEN(2));
2424 
2425  pParent = (PFFS_DIR_ENTRY)((PUCHAR)pSelf + pSelf->d_reclen);
2426 
2427  if (pParent->d_ino != OldParent)
2428  {
2429  FFSBreakPoint();
2430  }
2431 
2432  pParent->d_ino = NewParent;
2433 
2434  Status = FFSv1WriteInode(IrpContext,
2435  Vcb,
2436  Dcb->dinode1,
2437  Offset,
2438  pSelf,
2439  dwBytes,
2440  FALSE,
2441  &dwBytes);
2442  }
2443 
2445  {
2446  Dcb->ReferenceCount--;
2447 
2448  if(MainResourceAcquired)
2449  {
2451  &Dcb->MainResource,
2453  }
2454 
2455  if (pSelf)
2456  {
2457  ExFreePool(pSelf);
2458  }
2459  } _SEH2_END;
2460 
2461  return Status;
2462 }
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
Definition: dir.h:83
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
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
#define FFS_DIR_REC_LEN(name_len)
Definition: ffsdrv.h:214
_SEH2_TRY
Definition: create.c:4250
#define FFSBreakPoint()
Definition: ffsdrv.h:43
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
NTSTATUS FFSv1WriteInode(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN PFFSv1_INODE dinode1, IN ULONGLONG offset, IN PVOID Buffer, IN ULONG size, IN BOOLEAN bWriteToDisk, OUT PULONG dwRet)
Definition: write.c:798
u_int32_t d_ino
Definition: dir.h:84
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define Vcb
Definition: cdprocs.h:1425
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_Must_inspect_result_ _In_ PFLT_INSTANCE _Out_ PBOOLEAN IsDirectory
Definition: fltkernel.h:1139
#define DBG_ERROR
Definition: ffsdrv.h:1031
#define FFS_POOL_TAG
Definition: ffsdrv.h:817
Status
Definition: gdiplustypes.h:24
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
_SEH2_END
Definition: create.c:4424
_SEH2_FINALLY
Definition: create.c:4395
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 direct * PFFS_DIR_ENTRY
Definition: ffsdrv.h:265
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB * Dcb
Definition: create.c:4157
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by FFSSetRenameInfo().

◆ FFSTotalBlocks()

ULONG FFSTotalBlocks ( PFFS_VCB  Vcb,
ULONG  DataBlocks 
)

Definition at line 2988 of file ffs.c.

2991 {
2993  ULONG dwMeta[FFS_BLOCK_TYPES];
2994  ULONG TotalBlocks = 0;
2995  ULONG i, j;
2996 
2997  if (DataBlocks <= NDADDR)
2998  {
2999  return DataBlocks;
3000  }
3001 
3002  DataBlocks -= NDADDR;
3003 
3004  for (i = 0; i < FFS_BLOCK_TYPES; i++)
3005  {
3006  if (i == 0)
3007  {
3008  dwData[i] = 1;
3009  }
3010  else
3011  {
3012  dwData[i] = Vcb->dwData[i];
3013  }
3014 
3015  dwMeta[i] = Vcb->dwMeta[i];
3016  }
3017 
3018  for(i = 1; (i < FFS_BLOCK_TYPES) && (DataBlocks > 0); i++)
3019  {
3020  if (DataBlocks >= dwData[i])
3021  {
3022  DataBlocks -= dwData[i];
3023  TotalBlocks += (dwData[i] + dwMeta[i]);
3024  }
3025  else
3026  {
3027  ULONG dwDivide = 0;
3028  ULONG dwRemain = 0;
3029 
3030  for (j = i; (j > 0) && (DataBlocks > 0); j--)
3031  {
3032  dwDivide = (DataBlocks) / (dwData[j - 1]);
3033  dwRemain = (DataBlocks) % (dwData[j - 1]);
3034 
3035  TotalBlocks += (dwDivide * (dwData[j - 1] + dwMeta[j - 1]) + 1);
3036  DataBlocks = dwRemain;
3037  }
3038  }
3039  }
3040 
3041  return (TotalBlocks + NDADDR);
3042 }
#define NDADDR
Definition: dinode.h:77
static HANDLE ULONG_PTR dwData
Definition: file.c:35
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
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 GLint GLint j
Definition: glfuncs.h:250
#define FFS_BLOCK_TYPES
Definition: ffsdrv.h:67
#define Vcb
Definition: cdprocs.h:1425
unsigned int ULONG
Definition: retypes.h:1

Referenced by FFSExpandInode(), and FFSTruncateInode().

◆ FFSTruncateBlock()

__drv_mustHoldCriticalRegion BOOLEAN FFSTruncateBlock ( IN PFFS_IRP_CONTEXT  IrpContext,
IN PFFS_VCB  Vcb,
IN PFFS_FCB  Fcb,
IN ULONG  dwContent,
IN ULONG  Index,
IN ULONG  layer,
OUT BOOLEAN bFreed 
)

Definition at line 2467 of file ffs.c.

2475 {
2476  ULONG *pData = NULL;
2477  ULONG i = 0, j = 0, temp = 1;
2478  BOOLEAN bDirty = FALSE;
2479  BOOLEAN bRet = FALSE;
2480  ULONG dwBlk;
2481 
2482  LONGLONG Offset;
2483 
2484  PBCB Bcb;
2485 
2486  PFFSv1_INODE dinode1 = Fcb->dinode1;
2487 
2488  PAGED_CODE();
2489 
2490  *bFreed = FALSE;
2491 
2492  if (layer == 0)
2493  {
2494  //if (dwContent > 0 && dwContent < (BLOCKS_PER_GROUP * Vcb->ffs_groups))
2495  if (dwContent > 0)
2496  {
2497  bRet = FFSFreeBlock(IrpContext, Vcb, dwContent);
2498 
2499  if (bRet)
2500  {
2501  ASSERT(dinode1->di_blocks >= (Vcb->BlockSize / SECTOR_SIZE));
2502  dinode1->di_blocks -= (Vcb->BlockSize / SECTOR_SIZE);
2503  }
2504  }
2505  else
2506  {
2507  FFSBreakPoint();
2508  bRet = FALSE;
2509  }
2510 
2511  *bFreed = bRet;
2512  }
2513  else if (layer <= 3)
2514  {
2515  Offset = (LONGLONG)dwContent;
2516  Offset = Offset * Vcb->BlockSize;
2517 
2518  if(!CcPinRead(Vcb->StreamObj,
2519  (PLARGE_INTEGER)(&Offset),
2520  Vcb->BlockSize,
2521  PIN_WAIT,
2522  &Bcb,
2523  &pData))
2524  {
2525  FFSPrint((DBG_ERROR, "FFSSaveBuffer: PinReading error ...\n"));
2526  goto errorout;
2527  }
2528 
2529  temp = 1 << ((BLOCK_BITS - 2) * (layer - 1));
2530 
2531  i = Index / temp;
2532  j = Index % temp;
2533 
2534  dwBlk = pData[i];
2535 
2536  if(!FFSTruncateBlock(IrpContext, Vcb, Fcb, dwBlk, j, layer - 1, &bDirty))
2537  {
2538  goto errorout;
2539  }
2540 
2541  if (bDirty)
2542  {
2543  pData[i] = 0;
2544  }
2545 
2546  if (i == 0 && j == 0)
2547  {
2548  CcUnpinData(Bcb);
2549  pData = NULL;
2550 
2551  *bFreed = TRUE;
2552  bRet = FFSFreeBlock(IrpContext, Vcb, dwContent);
2553 
2554  if (bRet)
2555  {
2556  ASSERT(dinode1->di_blocks >= (Vcb->BlockSize / SECTOR_SIZE));
2557  dinode1->di_blocks -= (Vcb->BlockSize / SECTOR_SIZE);
2558  }
2559  }
2560  else
2561  {
2563  FFSRepinBcb(IrpContext, Bcb);
2564 
2565  FFSAddMcbEntry(Vcb, Offset, (LONGLONG)Vcb->BlockSize);
2566 
2567  bRet = TRUE;
2568  *bFreed = FALSE;
2569  }
2570  }
2571 
2572 errorout:
2573 
2574  if (pData)
2575  {
2576  CcUnpinData(Bcb);
2577  }
2578 
2579  return bRet;
2580 }
#define TRUE
Definition: types.h:120
IN PVCB IN VBO IN ULONG OUT PBCB * Bcb
Definition: fatprocs.h:402
VOID NTAPI CcSetDirtyPinnedData(IN PVOID BcbVoid, IN OPTIONAL PLARGE_INTEGER Lsn)
Definition: cachesub.c:121
VOID NTAPI CcUnpinData(IN PVOID Bcb)
Definition: pinsup.c:955
#define PIN_WAIT
BOOLEAN FFSFreeBlock(PFFS_IRP_CONTEXT IrpContext, PFFS_VCB Vcb, ULONG Block)
Definition: ffs.c:1296
#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
VOID FFSRepinBcb(IN PFFS_IRP_CONTEXT IrpContext, IN PBCB Bcb)
Definition: memory.c:221
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define SECTOR_SIZE
Definition: winldr.h:34
unsigned char BOOLEAN
#define BLOCK_BITS
Definition: stream.h:22
smooth NULL
Definition: ftsmooth.c:416
__drv_mustHoldCriticalRegion BOOLEAN FFSAddMcbEntry(IN PFFS_VCB Vcb, IN LONGLONG Lba, IN LONGLONG Length)
Definition: ffs.c:2673
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 GLint GLint j
Definition: glfuncs.h:250
GLenum GLuint GLint GLint layer
Definition: glext.h:7007
int64_t LONGLONG
Definition: typedefs.h:66
__drv_mustHoldCriticalRegion BOOLEAN FFSTruncateBlock(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN PFFS_FCB Fcb, IN ULONG dwContent, IN ULONG Index, IN ULONG layer, OUT BOOLEAN *bFreed)
Definition: ffs.c:2467
#define Vcb
Definition: cdprocs.h:1425
static const UCHAR Index[8]
Definition: usbohci.c:18
BOOLEAN NTAPI CcPinRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN ULONG Flags, OUT PVOID *Bcb, OUT PVOID *Buffer)
Definition: pinsup.c:802
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define DBG_ERROR
Definition: ffsdrv.h:1031
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
static calc_node_t temp
Definition: rpn_ieee.c:38
unsigned int ULONG
Definition: retypes.h:1
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
_In_ PFCB Fcb
Definition: cdprocs.h:151
u_int32_t di_blocks
Definition: dinode.h:97

Referenced by FFSTruncateInode().

◆ FFSTruncateInode()

BOOLEAN FFSTruncateInode ( IN PFFS_IRP_CONTEXT  IrpContext,
IN PFFS_VCB  Vcb,
IN PFFS_FCB  Fcb 
)

Definition at line 2584 of file ffs.c.

2588 {
2589  ULONG dwSizes[FFS_BLOCK_TYPES];
2590  ULONG Index = 0;
2591  ULONG dwTotal = 0;
2592  ULONG dwBlk = 0;
2593 
2594  ULONG i;
2595  BOOLEAN bRet = FALSE;
2596  BOOLEAN bFreed = FALSE;
2597 
2598  PFFSv1_INODE dinode1 = Fcb->dinode1;
2599 
2600  PAGED_CODE();
2601 
2602  Index = (ULONG)(Fcb->Header.AllocationSize.QuadPart >> BLOCK_BITS);
2603 
2604  if (Index > 0)
2605  {
2606  Index--;
2607  }
2608  else
2609  {
2610  return TRUE;
2611  }
2612 
2613  for (i = 0; i < FFS_BLOCK_TYPES; i++)
2614  {
2615  dwSizes[i] = Vcb->dwData[i];
2616  dwTotal += dwSizes[i];
2617  }
2618 
2619  if (Index >= dwTotal)
2620  {
2621  FFSPrint((DBG_ERROR, "FFSTruncateInode: beyond the maxinum size of an inode.\n"));
2622  return TRUE;
2623  }
2624 
2625  for (i = 0; i < FFS_BLOCK_TYPES; i++)
2626  {
2627 #if 0
2628  if (Index < dwSizes[i])
2629  {
2630  dwBlk = Inode->i_block[i == 0 ? (Index) : (i + NDADDR - 1)];
2631 
2632  bRet = FFSTruncateBlock(IrpContext, Vcb, Fcb, dwBlk, Index , i, &bFreed);
2633 
2634  if (bRet)
2635  {
2636  Fcb->Header.AllocationSize.QuadPart -= Vcb->BlockSize;
2637 
2638  if (bFreed)
2639  {
2640  Inode->i_block[i == 0 ? (Index) : (i + NDADDR - 1)] = 0;
2641  }
2642  }
2643 
2644  break;
2645  }
2646 #endif
2647  Index -= dwSizes[i];
2648  }
2649 
2650  {
2652  == (Fcb->Header.AllocationSize.QuadPart / BLOCK_SIZE));
2653 
2654  ASSERT(FFSTotalBlocks(Vcb, (ULONG)(Fcb->Header.AllocationSize.QuadPart / BLOCK_SIZE))
2655  == (dinode1->di_blocks / (BLOCK_SIZE / SECTOR_SIZE)));
2656 
2657  }
2658 
2659  //
2660  // Inode struct saving is done externally.
2661  //
2662 
2663  FFSv1SaveInode(IrpContext, Vcb, Fcb->FFSMcb->Inode, dinode1);
2664 
2665 
2666  return bRet;
2667 }
#define NDADDR
Definition: dinode.h:77
ULONG FFSTotalBlocks(PFFS_VCB Vcb, ULONG DataBlocks)
Definition: ffs.c:2988
#define TRUE
Definition: types.h:120
FSRTL_ADVANCED_FCB_HEADER Header
Definition: cdstruc.h:931
#define PAGED_CODE()
Definition: video.h:57
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
__drv_mustHoldCriticalRegion BOOLEAN FFSv1SaveInode(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN ULONG Inode, IN PFFSv1_INODE dinode1)
Definition: ffs.c:407
#define SECTOR_SIZE
Definition: winldr.h:34
unsigned char BOOLEAN
#define BLOCK_BITS
Definition: stream.h:22
#define FFS_BLOCK_TYPES
Definition: ffsdrv.h:67
#define BLOCK_SIZE
Definition: dlist.c:220
__drv_mustHoldCriticalRegion BOOLEAN FFSTruncateBlock(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN PFFS_FCB Fcb, IN ULONG dwContent, IN ULONG Index, IN ULONG layer, OUT BOOLEAN *bFreed)
Definition: ffs.c:2467
#define Vcb
Definition: cdprocs.h:1425
static const UCHAR Index[8]
Definition: usbohci.c:18
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define DBG_ERROR
Definition: ffsdrv.h:1031
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
unsigned int ULONG
Definition: retypes.h:1
_In_ PFCB Fcb
Definition: cdprocs.h:151
ULONG FFSDataBlocks(PFFS_VCB Vcb, ULONG TotalBlocks)
Definition: ffs.c:2930
u_int32_t di_blocks
Definition: dinode.h:97

Referenced by FFSTruncateFile().

◆ FFSv1BlockMap()

ULONG FFSv1BlockMap ( IN PFFS_VCB  Vcb,
IN PFFSv1_INODE  dinode1,
IN ULONG  Index 
)

Definition at line 701 of file ffs.c.

705 {
706  ULONG dwSizes[FFS_BLOCK_TYPES];
707  int i;
708  ULONG dwBlk;
709  ULONG Totalblocks;
710 
711  PAGED_CODE();
712 
713  for (i = 0; i < FFS_BLOCK_TYPES; i++)
714  {
715  dwSizes[i] = Vcb->dwData[i];
716  }
717 
718  Totalblocks = (dinode1->di_blocks);
719 
720  if (Index >= FFSDataBlocks(Vcb, Totalblocks))
721  {
722  FFSPrint((DBG_ERROR, "FFSv1BlockMap: error input paramters.\n"));
723 
724  FFSBreakPoint();
725 
726  return 0;
727  }
728 
729  /* 流立, 埃立, 2吝 埃立 贸府 */
730  for (i = 0; i < FFS_BLOCK_TYPES; i++)
731  {
732  if (Index < dwSizes[i])
733  {
734  if (i == 0)
735  dwBlk = dinode1->di_db[Index]; /* 流立 */
736  else
737  dwBlk = dinode1->di_ib[i - 1]; /* 埃立 */
738 #if DBG
739  {
740  ULONG dwRet = FFSv1GetBlock(Vcb, dwBlk, Index , i);
741 
742  KdPrint(("FFSv1BlockMap: i : %d, Index : %d, dwBlk : %x, Data Block : %X\n", i, Index, dwRet, (dwRet * 0x400)));
743 
744  return dwRet;
745  }
746 #else
747  return FFSv1GetBlock(Vcb, dwBlk, Index , i);
748 #endif
749  }
750 
751  Index -= dwSizes[i];
752  }
753 
754  return 0;
755 }
#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
#define FFS_BLOCK_TYPES
Definition: ffsdrv.h:67
#define Vcb
Definition: cdprocs.h:1425
static const UCHAR Index[8]
Definition: usbohci.c:18
#define DBG_ERROR
Definition: ffsdrv.h:1031
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
unsigned int ULONG
Definition: retypes.h:1
ULONG FFSDataBlocks(PFFS_VCB Vcb, ULONG TotalBlocks)
Definition: ffs.c:2930
#define KdPrint(x)
Definition: env_spec_w32.h:288
ULONG FFSv1GetBlock(IN PFFS_VCB Vcb, ULONG dwContent, ULONG Index, int layer)
Definition: ffs.c:596

Referenced by FFSv1BuildBDL().

◆ FFSv1BuildBDL()

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 at line 817 of file ffs.c.

824 {
825  ULONG nBeg, nEnd, nBlocks;
826  ULONG dwBlk, i;
827  ULONG dwBytes = 0;
828  LONGLONG Lba;
829  LONGLONG AllocSize;
830  ULONG Totalblocks;
831 
832  PFFS_BDL ffsbdl;
833 
834  PAGED_CODE();
835 
836  *ffs_bdl = NULL;
837 
838 
839  Totalblocks = (dinode1->di_blocks);
840  AllocSize = FFSDataBlocks(Vcb, Totalblocks);
841  AllocSize = (AllocSize << BLOCK_BITS);
842 
843  if ((LONGLONG)Offset >= AllocSize)
844  {
845  FFSPrint((DBG_ERROR, "FFSv1BuildBDL: beyond the file range.\n"));
846  return 0;
847  }
848 
849  if ((LONGLONG)(Offset + Size) > AllocSize)
850  {
851  Size = (ULONG)(AllocSize - Offset);
852  }
853 
854  nBeg = (ULONG)(Offset >> BLOCK_BITS);
855  nEnd = (ULONG)((Size + Offset + Vcb->BlockSize - 1) >> BLOCK_BITS);
856 
857 #if DBG
858  KdPrint(("FFSv1BuildBDL() Offset : %x\n", Offset));
859  KdPrint(("FFSv1BuildBDL() Size : %x\n", Size));
860  KdPrint(("FFSv1BuildBDL() nBeg : %d, nEnd : %d\n", nBeg, nEnd));
861 #endif
862 
863  nBlocks = 0;
864 
865  if ((nEnd - nBeg) > 0)
866  {
867  ffsbdl = ExAllocatePoolWithTag(PagedPool, sizeof(FFS_BDL) * (nEnd - nBeg), FFS_POOL_TAG);
868 
869  if (ffsbdl)
870  {
871  RtlZeroMemory(ffsbdl, sizeof(FFS_BDL) * (nEnd - nBeg));
872 
873  for (i = nBeg; i < nEnd; i++)
874  {
875  dwBlk = FFSv1BlockMap(Vcb, dinode1, i);
876 
877  if (dwBlk > 0)
878  {
879  Lba = (LONGLONG)dwBlk;
880  Lba = Lba * SUPER_BLOCK->fs_fsize; // fragment size
881 
882  if (nBeg == nEnd - 1) // ie. (nBeg == nEnd - 1)
883  {
884  dwBytes = Size;
885  ffsbdl[nBlocks].Lba = Lba + (LONGLONG)(Offset % (Vcb->BlockSize));
886  ffsbdl[nBlocks].Length = dwBytes;
887  ffsbdl[nBlocks].Offset = 0;
888 
889  nBlocks++;
890  }
891  else
892  {
893  if (i == nBeg)
894  {
895  dwBytes = Vcb->BlockSize - (ULONG)(Offset % (Vcb->BlockSize));
896  ffsbdl[nBlocks].Lba = Lba + (LONGLONG)(Offset % (Vcb->BlockSize));
897  ffsbdl[nBlocks].Length = dwBytes;
898  ffsbdl[nBlocks].Offset = 0;
899 
900  nBlocks++;
901  }
902  else if (i == nEnd - 1)
903  {
904  if (ffsbdl[nBlocks - 1].Lba + ffsbdl[nBlocks - 1].Length == Lba)
905  {
906  ffsbdl[nBlocks - 1].Length += Size - dwBytes;
907  }
908  else
909  {
910  ffsbdl[nBlocks].Lba = Lba;
911  ffsbdl[nBlocks].Length = Size - dwBytes;
912  ffsbdl[nBlocks].Offset = dwBytes;
913  nBlocks++;
914  }
915 
916  dwBytes = Size;
917 
918  }
919  else
920  {
921  if (ffsbdl[nBlocks - 1].Lba + ffsbdl[nBlocks - 1].Length == Lba)
922  {
923  ffsbdl[nBlocks - 1].Length += Vcb->BlockSize;
924  }
925  else
926  {
927  ffsbdl[nBlocks].Lba = Lba;
928  ffsbdl[nBlocks].Length = Vcb->BlockSize;
929  ffsbdl[nBlocks].Offset = dwBytes;
930  nBlocks++;
931  }
932 
933  dwBytes += Vcb->BlockSize;
934  }
935  }
936  }
937  else
938  {
939  break;
940  }
941  }
942 
943  *ffs_bdl = ffsbdl;
944  return nBlocks;
945  }
946  }
947 
948  // Error
949  return 0;
950 }
ULONG Offset
Definition: ffsdrv.h:800
#define PAGED_CODE()
Definition: video.h:57
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
#define BLOCK_BITS
Definition: stream.h:22
smooth NULL
Definition: ftsmooth.c:416
#define SUPER_BLOCK
Definition: ext2fs.h:90
int64_t LONGLONG
Definition: typedefs.h:66
#define Vcb
Definition: cdprocs.h:1425
LONGLONG Lba
Definition: ffsdrv.h:799
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define DBG_ERROR
Definition: ffsdrv.h:1031
#define FFS_POOL_TAG
Definition: ffsdrv.h:817
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
ULONG Length
Definition: ffsdrv.h:801
ULONG FFSv1BlockMap(IN PFFS_VCB Vcb, IN PFFSv1_INODE dinode1, IN ULONG Index)
Definition: ffs.c:701
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
ULONG FFSDataBlocks(PFFS_VCB Vcb, ULONG TotalBlocks)
Definition: ffs.c:2930
#define KdPrint(x)
Definition: env_spec_w32.h:288

Referenced by FFSv1ReadInode(), and FFSv1WriteInode().

◆ FFSv1GetBlock()

ULONG FFSv1GetBlock ( IN PFFS_VCB  Vcb,
ULONG  dwContent,
ULONG  Index,
int  layer 
)

Definition at line 596 of file ffs.c.

601 {
602  ULONG *pData = NULL;
603  ULONG i = 0, j = 0, temp = 1;
604  ULONG dwBlk = 0;
605 
606  PAGED_CODE();
607 
608  if (layer == 0)
609  {
610  dwBlk = dwContent;
611  }
612  else if (layer <= 3)
613  {
615  Vcb->BlockSize, FFS_POOL_TAG);
616  if (!pData)
617  {
618  FFSPrint((DBG_ERROR, "FFSGetBlock: no enough memory.\n"));
619  return dwBlk;
620  }
621 
622  KdPrint(("FFSGetBlock Index : %d, dwContent : %x, layer : %d\n", Index, dwContent, layer));
623 
624  if (!FFSv1LoadBlock(Vcb, dwContent, pData))
625  {
626  ExFreePool(pData);
627  return 0;
628  }
629 
630  temp = 1 << ((BLOCK_BITS - 2) * (layer - 1));
631 
632  i = Index / temp;
633  j = Index % temp;
634 
635  dwBlk = pData[i];
636 
637  ExFreePool(pData);
638 
639  dwBlk = FFSv1GetBlock(Vcb, dwBlk, j, layer - 1);
640  }
641 
642  return dwBlk;
643 }
#define PAGED_CODE()
Definition: video.h:57
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
#define BLOCK_BITS
Definition: stream.h:22
smooth NULL
Definition: ftsmooth.c:416
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 GLint GLint j
Definition: glfuncs.h:250
GLenum GLuint GLint GLint layer
Definition: glext.h:7007
BOOLEAN FFSv1LoadBlock(IN PFFS_VCB Vcb, IN ULONG dwBlk, IN PVOID Buffer)
Definition: ffs.c:459
#define Vcb
Definition: cdprocs.h:1425
static const UCHAR Index[8]
Definition: usbohci.c:18
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define DBG_ERROR
Definition: ffsdrv.h:1031
#define FFS_POOL_TAG
Definition: ffsdrv.h:817
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
static calc_node_t temp
Definition: rpn_ieee.c:38
unsigned int ULONG
Definition: retypes.h:1
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define KdPrint(x)
Definition: env_spec_w32.h:288
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
ULONG FFSv1GetBlock(IN PFFS_VCB Vcb, ULONG dwContent, ULONG Index, int layer)
Definition: ffs.c:596

Referenced by FFSv1BlockMap().

◆ FFSv1GetInodeLba()

BOOLEAN FFSv1GetInodeLba ( IN PFFS_VCB  Vcb,
IN ULONG  inode,
OUT PLONGLONG  offset 
)

Definition at line 244 of file ffs.c.

248 {
249  LONGLONG loc;
250 
251  PAGED_CODE();
252 
253 #if 0
255  {
256  FFSPrint((DBG_ERROR, "FFSv1GetInodeLba: Inode value %xh is invalid.\n",inode));
257  *offset = 0;
258  return FALSE;
259  }
260 #endif
261 
262  loc = cgimin(Vcb->ffs_super_block, ino_to_cg(Vcb->ffs_super_block, inode))
263  * Vcb->ffs_super_block->fs_fsize + ((inode % Vcb->ffs_super_block->fs_ipg) * 128);
264 
265  *offset = loc;
266  KdPrint(("FFSv1GetInodeLba() inode : %d, loc : %x, offset : %x\n", inode, loc, offset));
267 
268  return TRUE;
269 }
#define TRUE
Definition: types.h:120
GLintptr offset
Definition: glext.h:5920
#define ino_to_cg(fs, x)
Definition: fs.h:579
#define PAGED_CODE()
Definition: video.h:57
Definition: fs.h:78
int64_t LONGLONG
Definition: typedefs.h:66
#define Vcb
Definition: cdprocs.h:1425
#define DBG_ERROR
Definition: ffsdrv.h:1031
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
#define INODES_COUNT
Definition: ext2fs.h:97
#define KdPrint(x)
Definition: env_spec_w32.h:288
#define cgimin(fs, c)
Definition: fs.h:569

Referenced by FFSv1LoadInode(), and FFSv1SaveInode().

◆ FFSv1LoadBlock()

BOOLEAN FFSv1LoadBlock ( IN PFFS_VCB  Vcb,
IN ULONG  dwBlk,
IN PVOID  Buffer 
)

Definition at line 459 of file ffs.c.

463 {
466 
467  PAGED_CODE();
468 
469  Offset = (LONGLONG) dwBlk;
470  Offset = Offset * SUPER_BLOCK->fs_fsize; // fragment size
471 
472  if (!FFSCopyRead(
473  Vcb->StreamObj,
475  Vcb->BlockSize,
476  PIN_WAIT,
477  Buffer,
478  &IoStatus));
479 
480  if (!NT_SUCCESS(IoStatus.Status))
481  {
482  return FALSE;
483  }
484 
485  return TRUE;
486 }
#define TRUE
Definition: types.h:120
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
#define PIN_WAIT
#define PAGED_CODE()
Definition: video.h:57
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
Definition: bufpool.h:45
#define SUPER_BLOCK
Definition: ext2fs.h:90
int64_t LONGLONG
Definition: typedefs.h:66
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define Vcb
Definition: cdprocs.h:1425
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

Referenced by FFSExpandBlock(), and FFSv1GetBlock().

◆ FFSv1LoadInode()

BOOLEAN FFSv1LoadInode ( IN PFFS_VCB  Vcb,
IN ULONG  inode,
IN PFFSv1_INODE  dinode1 
)

Definition at line 302 of file ffs.c.

306 {
309 
310  PAGED_CODE();
311 
312  if (!FFSv1GetInodeLba(Vcb, inode, &Offset))
313  {
314  FFSPrint((DBG_ERROR, "FFSv1LoadInode: error get inode(%xh)'s addr.\n", inode));
315  return FALSE;
316  }
317 
318  if (!FFSCopyRead(
319  Vcb->StreamObj,
321  DINODE1_SIZE,
322  PIN_WAIT,
323  (PVOID)dinode1,
324  &IoStatus));
325 
326  if (!NT_SUCCESS(IoStatus.Status))
327  {
328  return FALSE;
329  }
330 
331  return TRUE;
332 }
BOOLEAN FFSv1GetInodeLba(IN PFFS_VCB Vcb, IN ULONG inode, OUT PLONGLONG offset)
Definition: ffs.c:244
#define TRUE
Definition: types.h:120
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
#define PIN_WAIT
#define PAGED_CODE()
Definition: video.h:57
Definition: fs.h:78
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
int64_t LONGLONG
Definition: typedefs.h:66
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define Vcb
Definition: cdprocs.h:1425
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 DBG_ERROR
Definition: ffsdrv.h:1031
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
#define DINODE1_SIZE
Definition: dinode.h:174

Referenced by FFSCreateFcbFromMcb(), FFSCreateFile(), FFSProcessDirEntry(), and FFSv1LookupFileName().

◆ FFSv1SaveInode()

__drv_mustHoldCriticalRegion BOOLEAN FFSv1SaveInode ( IN PFFS_IRP_CONTEXT  IrpContext,
IN PFFS_VCB  Vcb,
IN ULONG  Inode,
IN PFFSv1_INODE  dinode1 
)

Definition at line 407 of file ffs.c.

412 {
413  LONGLONG Offset = 0;
414  LARGE_INTEGER CurrentTime;
415  BOOLEAN bRet;
416 
417  PAGED_CODE();
418 
419  KeQuerySystemTime(&CurrentTime);
420  dinode1->di_mtime = dinode1->di_atime =
421  (ULONG)(FFSInodeTime(CurrentTime));
422 
423  FFSPrint((DBG_INFO, "FFSv1SaveInode: Saving Inode %xh: Mode=%xh Size=%xh\n",
424  Inode, dinode1->di_mode, dinode1->di_size));
425 
426  if (!FFSv1GetInodeLba(Vcb, Inode, &Offset))
427  {
428  FFSPrint((DBG_ERROR, "FFSv1SaveInode: error get inode(%xh)'s addr.\n", Inode));
429  return FALSE;
430  }
431 
432  bRet = FFSSaveBuffer(IrpContext, Vcb, Offset, DINODE1_SIZE, dinode1);
433 
434  if (IsFlagOn(Vcb->Flags, VCB_FLOPPY_DISK))
435  {
437  }
438 
439  return bRet;
440 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
BOOLEAN FFSv1GetInodeLba(IN PFFS_VCB Vcb, IN ULONG inode, OUT PLONGLONG offset)
Definition: ffs.c:244
VOID FFSStartFloppyFlushDpc(PFFS_VCB Vcb, PFFS_FCB Fcb, PFILE_OBJECT FileObject)
Definition: write.c:160
#define PAGED_CODE()
Definition: video.h:57
ULONG FFSInodeTime(IN LARGE_INTEGER SysTime)
Definition: misc.c:66
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
__drv_mustHoldCriticalRegion BOOLEAN FFSSaveBuffer(IN PFFS_IRP_CONTEXT IrpContext, IN PFFS_VCB Vcb, IN LONGLONG Offset, IN ULONG Size, IN PVOID Buf)
Definition: ffs.c:552
int64_t LONGLONG
Definition: typedefs.h:66
#define Vcb
Definition: cdprocs.h:1425
#define DBG_ERROR
Definition: ffsdrv.h:1031
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
#define VCB_FLOPPY_DISK
Definition: ext2fs.h:797
unsigned int ULONG
Definition: retypes.h:1
#define DINODE1_SIZE
Definition: dinode.h:174
#define DBG_INFO
Definition: ffsdrv.h:1034

Referenced by FFSAddEntry(), FFSCreateFile(), FFSCreateInode(), FFSDeleteFile(), FFSExpandInode(), FFSRemoveEntry(), FFSSetInformation(), FFSSetRenameInfo(), FFSSupersedeOrOverWriteFile(), FFSTruncateInode(), and FFSWriteFile().

◆ FFSv2BlockMap()

ULONGLONG FFSv2BlockMap ( IN PFFS_VCB  Vcb,
IN PFFSv2_INODE  dinode2,
IN ULONG  Index 
)

Definition at line 759 of file ffs.c.

763 {
764  ULONG dwSizes[FFS_BLOCK_TYPES];
765  int i;
766  ULONGLONG dwBlk;
767  ULONG Totalblocks;
768 
769  PAGED_CODE();
770 
771  for (i = 0; i < FFS_BLOCK_TYPES; i++)
772  {
773  dwSizes[i] = Vcb->dwData[i];
774  }
775 
776  Totalblocks = (ULONG)(dinode2->di_blocks);
777 
778  if (Index >= FFSDataBlocks(Vcb, Totalblocks))
779  {
780  FFSPrint((DBG_ERROR, "FFSv2BlockMap: error input paramters.\n"));
781 
782  FFSBreakPoint();
783 
784  return 0;
785  }
786 
787  /* 流立, 埃立, 2吝 埃立 贸府 */
788  for (i = 0; i < FFS_BLOCK_TYPES; i++)
789  {
790  if (Index < dwSizes[i])
791  {
792  if (i == 0)
793  dwBlk = (ULONGLONG)dinode2->di_db[Index]; /* 流立 */
794  else
795  dwBlk = (ULONGLONG)dinode2->di_ib[i - 1]; /* 埃立 */
796 #if 0
797  {
798  ULONGLONG dwRet = FFSv2GetBlock(Vcb, dwBlk, Index , i);
799 
800  KdPrint(("FFSv2BlockMap: i : %d, Index : %d, dwBlk : %x, Data Block : %X\n", i, Index, dwRet, (dwRet * 0x400)));
801 
802  return dwRet;
803  }
804 #else
805  return FFSv2GetBlock(Vcb, dwBlk, Index , i);
806 #endif
807  }
808 
809  Index -= dwSizes[i];
810  }
811 
812  return 0;
813 }
#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
#define FFS_BLOCK_TYPES
Definition: ffsdrv.h:67
uint64_t ULONGLONG
Definition: typedefs.h:65
#define Vcb
Definition: cdprocs.h:1425
static const UCHAR Index[8]
Definition: usbohci.c:18
#define DBG_ERROR
Definition: ffsdrv.h:1031
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
ULONGLONG FFSv2GetBlock(IN PFFS_VCB Vcb, ULONGLONG dwContent, ULONG Index, int layer)
Definition: ffs.c:647
unsigned int ULONG
Definition: retypes.h:1
ULONG FFSDataBlocks(PFFS_VCB Vcb, ULONG TotalBlocks)
Definition: ffs.c:2930
#define KdPrint(x)
Definition: env_spec_w32.h:288

Referenced by FFSv2BuildBDL().

◆ FFSv2BuildBDL()

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 at line 954 of file ffs.c.

961 {
962  ULONG nBeg, nEnd, nBlocks;
963  ULONGLONG dwBlk;
964  ULONG dwBytes = 0, i;
965  LONGLONG Lba;
966  LONGLONG AllocSize;
967  ULONG Totalblocks;
968 
969  PFFS_BDL ffsbdl;
970 
971  PAGED_CODE();
972 
973  *ffs_bdl = NULL;
974 
975 
976  Totalblocks = (ULONG)(dinode2->di_blocks);
977  AllocSize = FFSDataBlocks(Vcb, Totalblocks);
978  AllocSize = (AllocSize << BLOCK_BITS);
979 
980  if ((LONGLONG)Offset >= AllocSize)
981  {
982  FFSPrint((DBG_ERROR, "FFSv2BuildBDL: beyond the file range.\n"));
983  return 0;
984  }
985 
986  if ((LONGLONG)(Offset + Size) > AllocSize)
987  {
988  Size = (ULONG)(AllocSize - Offset);
989  }
990 
991  nBeg = (ULONG)(Offset >> BLOCK_BITS);
992  nEnd = (ULONG)((Size + Offset + Vcb->BlockSize - 1) >> BLOCK_BITS);
993 
994 #if 0
995  KdPrint(("FFSv2BuildBDL() Offset : %x\n", Offset));
996  KdPrint(("FFSv2BuildBDL() Size : %x\n", Size));
997  KdPrint(("FFSv2BuildBDL() nBeg : %d, nEnd : %d\n", nBeg, nEnd));
998 #endif
999 
1000  nBlocks = 0;
1001 
1002  if ((nEnd - nBeg) > 0)
1003  {
1004  ffsbdl = ExAllocatePoolWithTag(PagedPool, sizeof(FFS_BDL) * (nEnd - nBeg), FFS_POOL_TAG);
1005 
1006  if (ffsbdl)
1007  {
1008 
1009  RtlZeroMemory(ffsbdl, sizeof(FFS_BDL) * (nEnd - nBeg));
1010 
1011  for (i = nBeg; i < nEnd; i++)
1012  {
1013  dwBlk = FFSv2BlockMap(Vcb, dinode2, i);
1014 
1015  if (dwBlk > 0)
1016  {
1017  Lba = (LONGLONG)dwBlk;
1018  Lba = Lba * SUPER_BLOCK->fs_fsize; // fragment size
1019  Lba += Vcb->FSOffset[Vcb->PartitionNumber];
1020 
1021  if (nBeg == nEnd - 1) // ie. (nBeg == nEnd - 1)
1022  {
1023  dwBytes = Size;
1024  ffsbdl[nBlocks].Lba = Lba + (LONGLONG)(Offset % (Vcb->BlockSize));
1025  ffsbdl[nBlocks].Length = dwBytes;
1026  ffsbdl[nBlocks].Offset = 0;
1027 
1028  nBlocks++;
1029  }
1030  else
1031  {
1032  if (i == nBeg)
1033  {
1034  dwBytes = Vcb->BlockSize - (ULONG)(Offset % (Vcb->BlockSize));
1035  ffsbdl[nBlocks].Lba = Lba + (LONGLONG)(Offset % (Vcb->BlockSize));
1036  ffsbdl[nBlocks].Length = dwBytes;
1037  ffsbdl[nBlocks].Offset = 0;
1038 
1039  nBlocks++;
1040  }
1041  else if (i == nEnd - 1)
1042  {
1043  if (ffsbdl[nBlocks - 1].Lba + ffsbdl[nBlocks - 1].Length == Lba)
1044  {
1045  ffsbdl[nBlocks - 1].Length += Size - dwBytes;
1046  }
1047  else
1048  {
1049  ffsbdl[nBlocks].Lba = Lba;
1050  ffsbdl[nBlocks].Length = Size - dwBytes;
1051  ffsbdl[nBlocks].Offset = dwBytes;
1052  nBlocks++;
1053  }
1054 
1055  dwBytes = Size;
1056 
1057  }
1058  else
1059  {
1060  if (ffsbdl[nBlocks - 1].Lba + ffsbdl[nBlocks - 1].Length == Lba)
1061  {
1062  ffsbdl[nBlocks - 1].Length += Vcb->BlockSize;
1063  }
1064  else
1065  {
1066  ffsbdl[nBlocks].Lba = Lba;
1067  ffsbdl[nBlocks].Length = Vcb->BlockSize;
1068  ffsbdl[nBlocks].Offset = dwBytes;
1069  nBlocks++;
1070  }
1071 
1072  dwBytes += Vcb->BlockSize;
1073  }
1074  }
1075  }
1076  else
1077  {
1078  break;
1079  }
1080  }
1081 
1082  *ffs_bdl = ffsbdl;
1083  return nBlocks;
1084  }
1085  }
1086 
1087  // Error
1088  return 0;
1089 }
ULONG Offset
Definition: ffsdrv.h:800
#define PAGED_CODE()
Definition: video.h:57
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
#define BLOCK_BITS
Definition: stream.h:22
smooth NULL
Definition: ftsmooth.c:416
#define SUPER_BLOCK
Definition: ext2fs.h:90
int64_t LONGLONG
Definition: typedefs.h:66
ULONGLONG FFSv2BlockMap(IN PFFS_VCB Vcb, IN PFFSv2_INODE dinode2, IN ULONG Index)
Definition: ffs.c:759
uint64_t ULONGLONG
Definition: typedefs.h:65
#define Vcb
Definition: cdprocs.h:1425
LONGLONG Lba
Definition: ffsdrv.h:799
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define DBG_ERROR
Definition: ffsdrv.h:1031
#define FFS_POOL_TAG
Definition: ffsdrv.h:817
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
ULONG Length
Definition: ffsdrv.h:801
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
ULONG FFSDataBlocks(PFFS_VCB Vcb, ULONG TotalBlocks)
Definition: ffs.c:2930
#define KdPrint(x)
Definition: env_spec_w32.h:288

Referenced by FFSv2ReadInode().

◆ FFSv2GetBlock()

ULONGLONG FFSv2GetBlock ( IN PFFS_VCB  Vcb,
ULONGLONG  dwContent,
ULONG  Index,
int  layer 
)

Definition at line 647 of file ffs.c.

652 {
653  ULONGLONG *pData = NULL;
654  ULONG i = 0, j = 0, temp = 1;
655  ULONGLONG dwBlk = 0;
656 
657  PAGED_CODE();
658 
659  if (layer == 0)
660  {
661  dwBlk = dwContent;
662  }
663  else if (layer <= 3)
664  {
666  Vcb->BlockSize, FFS_POOL_TAG);
667  if (!pData)
668  {
669  FFSPrint((DBG_ERROR, "FFSv2GetBlock: no enough memory.\n"));
670  return dwBlk;
671  }
672 
673  KdPrint(("FFSv2GetBlock Index : %d, dwContent : %x, layer : %d\n", Index, dwContent, layer));
674 
675  if (!FFSv2LoadBlock(Vcb, dwContent, pData))
676  {
677  ExFreePool(pData);
678  return 0;
679  }
680 
681  if (Index >= (Vcb->BlockSize / 8) && layer == 2)
682  temp = 1 << ((BLOCK_BITS - 3) * (layer - 1));
683  else
684  temp = 1 << ((BLOCK_BITS - 2) * (layer - 1));
685 
686  i = Index / temp;
687  j = Index % temp;
688 
689  dwBlk = pData[i];
690 
691  ExFreePool(pData);
692 
693  dwBlk = FFSv2GetBlock(Vcb, dwBlk, j, layer - 1);
694  }
695 
696  return dwBlk;
697 }
#define PAGED_CODE()
Definition: video.h:57
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
#define BLOCK_BITS
Definition: stream.h:22
smooth NULL
Definition: ftsmooth.c:416
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 GLint GLint j
Definition: glfuncs.h:250
GLenum GLuint GLint GLint layer
Definition: glext.h:7007
uint64_t ULONGLONG
Definition: typedefs.h:65
#define Vcb
Definition: cdprocs.h:1425
static const UCHAR Index[8]
Definition: usbohci.c:18
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define DBG_ERROR
Definition: ffsdrv.h:1031
#define FFS_POOL_TAG
Definition: ffsdrv.h:817
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
ULONGLONG FFSv2GetBlock(IN PFFS_VCB Vcb, ULONGLONG dwContent, ULONG Index, int layer)
Definition: ffs.c:647
BOOLEAN FFSv2LoadBlock(IN PFFS_VCB Vcb, IN ULONGLONG dwBlk, IN PVOID Buffer)
Definition: ffs.c:490
static calc_node_t temp
Definition: rpn_ieee.c:38
unsigned int ULONG
Definition: retypes.h:1
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define KdPrint(x)
Definition: env_spec_w32.h:288
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by FFSv2BlockMap().

◆ FFSv2GetInodeLba()

BOOLEAN FFSv2GetInodeLba ( IN PFFS_VCB  Vcb,
IN ULONG  inode,
OUT PLONGLONG  offset 
)

Definition at line 273 of file ffs.c.

277 {
278  LONGLONG loc;
279 
280  PAGED_CODE();
281 
282 #if 0
284  {
285  FFSPrint((DBG_ERROR, "FFSv2GetInodeLba: Inode value %xh is invalid.\n",inode));
286  *offset = 0;
287  return FALSE;
288  }
289 #endif
290 
291  loc = cgimin(Vcb->ffs_super_block, ino_to_cg(Vcb->ffs_super_block, inode))
292  * Vcb->ffs_super_block->fs_fsize + ((inode % Vcb->ffs_super_block->fs_ipg) * 256);
293 
294  *offset = loc;
295  //KdPrint(("FFSv2GetInodeLba() inode : %d, loc : %x, offset : %x\n", inode, loc, offset));
296 
297  return TRUE;
298 }
#define TRUE
Definition: types.h:120
GLintptr offset
Definition: glext.h:5920
#define ino_to_cg(fs, x)
Definition: fs.h:579
#define PAGED_CODE()
Definition: video.h:57
Definition: fs.h:78
int64_t LONGLONG
Definition: typedefs.h:66
#define Vcb
Definition: cdprocs.h:1425
#define DBG_ERROR
Definition: ffsdrv.h:1031
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
#define INODES_COUNT
Definition: ext2fs.h:97
#define cgimin(fs, c)
Definition: fs.h:569

Referenced by FFSv2LoadInode().

◆ FFSv2LoadBlock()

BOOLEAN FFSv2LoadBlock ( IN PFFS_VCB  Vcb,
IN ULONGLONG  dwBlk,
IN PVOID  Buffer 
)

Definition at line 490 of file ffs.c.

494 {
497 
498  PAGED_CODE();
499 
500  Offset = (LONGLONG)dwBlk;
501  Offset = Offset * SUPER_BLOCK->fs_fsize; // fragment size
502 
503  Offset += Vcb->FSOffset[Vcb->PartitionNumber];
504 
505  if (!FFSCopyRead(
506  Vcb->StreamObj,
508  Vcb->BlockSize,
509  PIN_WAIT,
510  Buffer,
511  &IoStatus));
512 
513  if (!NT_SUCCESS(IoStatus.Status))
514  {
515  return FALSE;
516  }
517 
518  return TRUE;
519 }
#define TRUE
Definition: types.h:120
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
#define PIN_WAIT
#define PAGED_CODE()
Definition: video.h:57
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
Definition: bufpool.h:45
#define SUPER_BLOCK
Definition: ext2fs.h:90
int64_t LONGLONG
Definition: typedefs.h:66
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define Vcb
Definition: cdprocs.h:1425
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

Referenced by FFSv2GetBlock().

◆ FFSv2LoadInode()

BOOLEAN FFSv2LoadInode ( IN PFFS_VCB  Vcb,
IN ULONG  inode,
IN PFFSv2_INODE  dinode2 
)

Definition at line 336 of file ffs.c.

340 {
343 
344  PAGED_CODE();
345 
346  if (!FFSv2GetInodeLba(Vcb, inode, &Offset))
347  {
348  FFSPrint((DBG_ERROR, "FFSv2LoadInode: error get inode(%xh)'s addr.\n", inode));
349  return FALSE;
350  }
351 
352  Offset += (LONGLONG)Vcb->FSOffset[Vcb->PartitionNumber];
353 
354  if (!FFSCopyRead(
355  Vcb->StreamObj,
357  DINODE2_SIZE,
358  PIN_WAIT,
359  (PVOID)dinode2,
360  &IoStatus));
361 
362  if (!NT_SUCCESS(IoStatus.Status))
363  {
364  return FALSE;
365  }
366 
367  return TRUE;
368 }
#define TRUE
Definition: types.h:120
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
#define PIN_WAIT
#define PAGED_CODE()
Definition: video.h:57
Definition: fs.h:78
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
int64_t LONGLONG
Definition: typedefs.h:66
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define Vcb
Definition: cdprocs.h:1425
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
BOOLEAN FFSv2GetInodeLba(IN PFFS_VCB Vcb, IN ULONG inode, OUT PLONGLONG offset)
Definition: ffs.c:273
#define DBG_ERROR
Definition: ffsdrv.h:1031
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
#define DINODE2_SIZE
Definition: dinode.h:175

Referenced by FFSCreateFcbFromMcb(), FFSCreateFile(), FFSProcessDirEntry(), and FFSv2LookupFileName().

◆ FFSv2SaveInode()

__drv_mustHoldCriticalRegion BOOLEAN FFSv2SaveInode ( IN PFFS_IRP_CONTEXT  IrpContext,
IN PFFS_VCB  Vcb,
IN ULONG  Inode,
IN PFFSv2_INODE  dinode2 
)

Definition at line 445 of file ffs.c.

450 {
451  PAGED_CODE();
452 
453  return FALSE;
454 }
#define PAGED_CODE()
Definition: video.h:57

Referenced by FFSCreateFile(), and FFSSetInformation().

Variable Documentation

◆ FFSGlobal

PFFS_GLOBAL FFSGlobal

Definition at line 22 of file init.c.