ReactOS  0.4.14-dev-606-g14ebc0b
fcb.c File Reference
#include "ntfs.h"
#include <debug.h>
Include dependency graph for fcb.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static PCWSTR NtfsGetNextPathElement (PCWSTR FileName)
 
static VOID NtfsWSubString (PWCHAR pTarget, PCWSTR pSource, size_t pLength)
 
PNTFS_FCB NtfsCreateFCB (PCWSTR FileName, PCWSTR Stream, PNTFS_VCB Vcb)
 
VOID NtfsDestroyFCB (PNTFS_FCB Fcb)
 
BOOLEAN NtfsFCBIsDirectory (PNTFS_FCB Fcb)
 
BOOLEAN NtfsFCBIsReparsePoint (PNTFS_FCB Fcb)
 
BOOLEAN NtfsFCBIsCompressed (PNTFS_FCB Fcb)
 
BOOLEAN NtfsFCBIsRoot (PNTFS_FCB Fcb)
 
VOID NtfsGrabFCB (PNTFS_VCB Vcb, PNTFS_FCB Fcb)
 
VOID NtfsReleaseFCB (PNTFS_VCB Vcb, PNTFS_FCB Fcb)
 
VOID NtfsAddFCBToTable (PNTFS_VCB Vcb, PNTFS_FCB Fcb)
 
PNTFS_FCB NtfsGrabFCBFromTable (PNTFS_VCB Vcb, PCWSTR FileName)
 
NTSTATUS NtfsFCBInitializeCache (PNTFS_VCB Vcb, PNTFS_FCB Fcb)
 
PNTFS_FCB NtfsMakeRootFCB (PNTFS_VCB Vcb)
 
PNTFS_FCB NtfsOpenRootFCB (PNTFS_VCB Vcb)
 
NTSTATUS NtfsMakeFCBFromDirEntry (PNTFS_VCB Vcb, PNTFS_FCB DirectoryFCB, PUNICODE_STRING Name, PCWSTR Stream, PFILE_RECORD_HEADER Record, ULONGLONG MFTIndex, PNTFS_FCB *fileFCB)
 
NTSTATUS NtfsAttachFCBToFileObject (PNTFS_VCB Vcb, PNTFS_FCB Fcb, PFILE_OBJECT FileObject)
 
static NTSTATUS NtfsDirFindFile (PNTFS_VCB Vcb, PNTFS_FCB DirectoryFcb, PWSTR FileToFind, BOOLEAN CaseSensitive, PNTFS_FCB *FoundFCB)
 
NTSTATUS NtfsGetFCBForFile (PNTFS_VCB Vcb, PNTFS_FCB *pParentFCB, PNTFS_FCB *pFCB, PCWSTR pFileName, BOOLEAN CaseSensitive)
 
NTSTATUS NtfsReadFCBAttribute (PNTFS_VCB Vcb, PNTFS_FCB pFCB, ULONG Type, PCWSTR Name, ULONG NameLength, PVOID *Data)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 32 of file fcb.c.

Function Documentation

◆ NtfsAddFCBToTable()

VOID NtfsAddFCBToTable ( PNTFS_VCB  Vcb,
PNTFS_FCB  Fcb 
)

Definition at line 198 of file fcb.c.

200 {
201  KIRQL oldIrql;
202 
203  KeAcquireSpinLock(&Vcb->FcbListLock, &oldIrql);
204  Fcb->Vcb = Vcb;
205  InsertTailList(&Vcb->FcbListHead, &Fcb->FcbListEntry);
206  KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
207 }
LIST_ENTRY FcbListEntry
Definition: ntfs.h:526
#define InsertTailList(ListHead, Entry)
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define Vcb
Definition: cdprocs.h:1425
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
PVCB Vcb
Definition: cdstruc.h:939
_In_ PFCB Fcb
Definition: cdprocs.h:151

Referenced by NtfsMakeFCBFromDirEntry(), and NtfsMakeRootFCB().

◆ NtfsAttachFCBToFileObject()

NTSTATUS NtfsAttachFCBToFileObject ( PNTFS_VCB  Vcb,
PNTFS_FCB  Fcb,
PFILE_OBJECT  FileObject 
)

Definition at line 453 of file fcb.c.

456 {
457  PNTFS_CCB newCCB;
458 
460  if (newCCB == NULL)
461  {
463  }
464 
465  RtlZeroMemory(newCCB, sizeof(NTFS_CCB));
466 
467  newCCB->Identifier.Type = NTFS_TYPE_CCB;
468  newCCB->Identifier.Size = sizeof(NTFS_TYPE_CCB);
469 
470  FileObject->SectionObjectPointer = &Fcb->SectionObjectPointers;
471  FileObject->FsContext = Fcb;
472  FileObject->FsContext2 = newCCB;
473  newCCB->PtrFileObject = FileObject;
474  Fcb->Vcb = Vcb;
475 
476  if (!(Fcb->Flags & FCB_CACHE_INITIALIZED))
477  {
478  _SEH2_TRY
479  {
482  FALSE,
484  Fcb);
485  }
487  {
488  FileObject->FsContext2 = NULL;
489  ExFreePoolWithTag(newCCB, TAG_CCB);
490  return _SEH2_GetExceptionCode();
491  }
492  _SEH2_END;
493 
495  }
496 
497  //DPRINT("file open: fcb:%x file size: %d\n", Fcb, Fcb->Entry.DataLengthL);
498 
499  return STATUS_SUCCESS;
500 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
PNTFS_GLOBAL_DATA NtfsGlobalData
Definition: ntfs.c:41
_SEH2_TRY
Definition: create.c:4250
Definition: ntfs.h:129
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
FSRTL_COMMON_FCB_HEADER RFCB
Definition: ntfs.h:513
PFILE_OBJECT PtrFileObject
Definition: ntfs.h:133
VOID NTAPI CcInitializeCacheMap(IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes, IN BOOLEAN PinAccess, IN PCACHE_MANAGER_CALLBACKS Callbacks, IN PVOID LazyWriteContext)
Definition: fssup.c:193
#define Vcb
Definition: cdprocs.h:1425
#define TAG_CCB
Definition: cdprocs.h:77
ULONG Flags
Definition: ntfs.h:532
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
ULONG Type
Definition: ntfs.h:95
#define NTFS_TYPE_CCB
Definition: ntfs.h:87
LARGE_INTEGER AllocationSize
Definition: env_spec_w32.h:755
NTFSIDENTIFIER Identifier
Definition: ntfs.h:131
#define FCB_CACHE_INITIALIZED
Definition: vfat.h:427
_SEH2_END
Definition: create.c:4424
CACHE_MANAGER_CALLBACKS CacheMgrCallbacks
Definition: ntfs.h:149
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
PVCB Vcb
Definition: cdstruc.h:939
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
_In_ PFCB Fcb
Definition: cdprocs.h:151
return STATUS_SUCCESS
Definition: btrfs.c:2938
SECTION_OBJECT_POINTERS SectionObjectPointers
Definition: ntfs.h:514
ULONG Size
Definition: ntfs.h:96

Referenced by NtfsCreateFile(), NtfsOpenFile(), and NtfsOpenFileById().

◆ NtfsCreateFCB()

PNTFS_FCB NtfsCreateFCB ( PCWSTR  FileName,
PCWSTR  Stream,
PNTFS_VCB  Vcb 
)

Definition at line 67 of file fcb.c.

70 {
71  PNTFS_FCB Fcb;
72 
73  ASSERT(Vcb);
74  ASSERT(Vcb->Identifier.Type == NTFS_TYPE_VCB);
75 
76  Fcb = ExAllocateFromNPagedLookasideList(&NtfsGlobalData->FcbLookasideList);
77  RtlZeroMemory(Fcb, sizeof(NTFS_FCB));
78 
80  Fcb->Identifier.Size = sizeof(NTFS_TYPE_FCB);
81 
82  Fcb->Vcb = Vcb;
83 
84  if (FileName)
85  {
87  if (wcsrchr(Fcb->PathName, '\\') != 0)
88  {
89  Fcb->ObjectName = wcsrchr(Fcb->PathName, '\\');
90  }
91  else
92  {
94  }
95  }
96 
97  if (Stream)
98  {
100  }
101  else
102  {
103  Fcb->Stream[0] = UNICODE_NULL;
104  }
105 
107 
109 
110  return Fcb;
111 }
#define NTFS_TYPE_VCB
Definition: ntfs.h:89
NPAGED_LOOKASIDE_LIST FcbLookasideList
Definition: ntfs.h:153
Definition: cdstruc.h:908
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
WCHAR PathName[MAX_PATH]
Definition: ntfs.h:521
PNTFS_GLOBAL_DATA NtfsGlobalData
Definition: ntfs.c:41
NTFSIDENTIFIER Identifier
Definition: ntfs.h:511
#define UNICODE_NULL
WCHAR Stream[MAX_PATH]
Definition: ntfs.h:519
WCHAR * ObjectName
Definition: ntfs.h:520
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcsrchr(_In_z_ const wchar_t *_Str, _In_ wchar_t _Ch)
FSRTL_COMMON_FCB_HEADER RFCB
Definition: ntfs.h:513
#define NTFS_TYPE_FCB
Definition: ntfs.h:88
#define Vcb
Definition: cdprocs.h:1425
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
ULONG Type
Definition: ntfs.h:95
ERESOURCE MainResource
Definition: ntfs.h:524
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
PVCB Vcb
Definition: cdstruc.h:939
_In_ PFCB Fcb
Definition: cdprocs.h:151
ULONG Size
Definition: ntfs.h:96
_Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING Stream
Definition: fltkernel.h:1092

Referenced by NtfsGetVolumeData(), NtfsMakeFCBFromDirEntry(), NtfsMakeRootFCB(), and NtfsMountVolume().

◆ NtfsDestroyFCB()

VOID NtfsDestroyFCB ( PNTFS_FCB  Fcb)

Definition at line 115 of file fcb.c.

116 {
117  ASSERT(Fcb);
119 
121 
122  ExFreeToNPagedLookasideList(&NtfsGlobalData->FcbLookasideList, Fcb);
123 }
NPAGED_LOOKASIDE_LIST FcbLookasideList
Definition: ntfs.h:153
NTSTATUS NTAPI ExDeleteResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1456
PNTFS_GLOBAL_DATA NtfsGlobalData
Definition: ntfs.c:41
NTFSIDENTIFIER Identifier
Definition: ntfs.h:511
#define NTFS_TYPE_FCB
Definition: ntfs.h:88
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ULONG Type
Definition: ntfs.h:95
ERESOURCE MainResource
Definition: ntfs.h:524
_In_ PFCB Fcb
Definition: cdprocs.h:151

Referenced by NtfsReleaseFCB().

◆ NtfsDirFindFile()

static NTSTATUS NtfsDirFindFile ( PNTFS_VCB  Vcb,
PNTFS_FCB  DirectoryFcb,
PWSTR  FileToFind,
BOOLEAN  CaseSensitive,
PNTFS_FCB FoundFCB 
)
static

Definition at line 504 of file fcb.c.

509 {
511  ULONGLONG CurrentDir;
513  PFILE_RECORD_HEADER FileRecord;
514  ULONGLONG MFTIndex;
515  PWSTR Colon, OldColon;
516  PNTFS_ATTR_CONTEXT DataContext;
517  USHORT Length = 0;
518 
519  DPRINT("NtfsDirFindFile(%p, %p, %S, %s, %p)\n",
520  Vcb,
521  DirectoryFcb,
522  FileToFind,
523  CaseSensitive ? "TRUE" : "FALSE",
524  FoundFCB);
525 
526  *FoundFCB = NULL;
527  RtlInitUnicodeString(&File, FileToFind);
528  CurrentDir = DirectoryFcb->MFTIndex;
529 
530  Colon = wcsrchr(FileToFind, L':');
531  if (Colon != NULL)
532  {
533  Length = File.Length;
534  File.Length = (Colon - FileToFind) * sizeof(WCHAR);
535 
536  if (_wcsicmp(Colon + 1, L"$DATA") == 0)
537  {
538  OldColon = Colon;
539  Colon[0] = UNICODE_NULL;
540  Colon = wcsrchr(FileToFind, L':');
541  if (Colon != NULL)
542  {
543  Length = File.Length;
544  File.Length = (Colon - FileToFind) * sizeof(WCHAR);
545  }
546  else
547  {
548  Colon = OldColon;
549  Colon[0] = L':';
550  }
551  }
552 
553  /* Skip colon */
554  ++Colon;
555  DPRINT1("Will now look for file '%wZ' with stream '%S'\n", &File, Colon);
556  }
557 
558  Status = NtfsLookupFileAt(Vcb, &File, CaseSensitive, &FileRecord, &MFTIndex, CurrentDir);
559  if (!NT_SUCCESS(Status))
560  {
561  return Status;
562  }
563 
564  if (Length != 0)
565  {
566  File.Length = Length;
567  }
568 
569  if ((FileRecord->Flags & FRH_DIRECTORY) && Colon != 0)
570  {
571  ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, FileRecord);
573  }
574  else if (Colon != 0)
575  {
576  Status = FindAttribute(Vcb, FileRecord, AttributeData, Colon, wcslen(Colon), &DataContext, NULL);
577  if (!NT_SUCCESS(Status))
578  {
580  }
581  ReleaseAttributeContext(DataContext);
582  }
583 
584  Status = NtfsMakeFCBFromDirEntry(Vcb, DirectoryFcb, &File, Colon, FileRecord, MFTIndex, FoundFCB);
585  ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, FileRecord);
586 
587  return Status;
588 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
uint16_t * PWSTR
Definition: typedefs.h:54
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NtfsMakeFCBFromDirEntry(PNTFS_VCB Vcb, PNTFS_FCB DirectoryFCB, PUNICODE_STRING Name, PCWSTR Stream, PFILE_RECORD_HEADER Record, ULONGLONG MFTIndex, PNTFS_FCB *fileFCB)
Definition: fcb.c:378
NTSTATUS NtfsLookupFileAt(PDEVICE_EXTENSION Vcb, PUNICODE_STRING PathName, BOOLEAN CaseSensitive, PFILE_RECORD_HEADER *FileRecord, PULONGLONG MFTIndex, ULONGLONG CurrentMFTIndex)
Definition: mft.c:3229
NTSTATUS FindAttribute(PDEVICE_EXTENSION Vcb, PFILE_RECORD_HEADER MftRecord, ULONG Type, PCWSTR Name, ULONG NameLength, PNTFS_ATTR_CONTEXT *AttrCtx, PULONG Offset)
Definition: mft.c:131
ULONGLONG MFTIndex
Definition: ntfs.h:535
#define UNICODE_NULL
_In_opt_ PVOID _In_ PCSTR File
Definition: iofuncs.h:615
#define FRH_DIRECTORY
Definition: ntfs.h:264
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcsrchr(_In_z_ const wchar_t *_Str, _In_ wchar_t _Ch)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
uint64_t ULONGLONG
Definition: typedefs.h:65
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
VOID ReleaseAttributeContext(PNTFS_ATTR_CONTEXT Context)
Definition: mft.c:104
unsigned short USHORT
Definition: pedump.c:61
USHORT Flags
Definition: ntfs.h:252
#define DPRINT1
Definition: precomp.h:8
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
Definition: File.h:15
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

Referenced by NtfsGetFCBForFile().

◆ NtfsFCBInitializeCache()

NTSTATUS NtfsFCBInitializeCache ( PNTFS_VCB  Vcb,
PNTFS_FCB  Fcb 
)

Definition at line 254 of file fcb.c.

256 {
259  PNTFS_CCB newCCB;
260 
261  FileObject = IoCreateStreamFileObject(NULL, Vcb->StorageDevice);
262 
264  if (newCCB == NULL)
265  {
267  }
268 
269  RtlZeroMemory(newCCB, sizeof(NTFS_CCB));
270 
271  newCCB->Identifier.Type = NTFS_TYPE_CCB;
272  newCCB->Identifier.Size = sizeof(NTFS_TYPE_CCB);
273 
274  FileObject->SectionObjectPointer = &Fcb->SectionObjectPointers;
275  FileObject->FsContext = Fcb;
276  FileObject->FsContext2 = newCCB;
277  newCCB->PtrFileObject = FileObject;
279  Fcb->Vcb = Vcb;
280 
282  _SEH2_TRY
283  {
286  FALSE,
288  Fcb);
289  }
291  {
292  FileObject->FsContext2 = NULL;
293  ExFreePoolWithTag(newCCB, TAG_CCB);
295  Fcb->FileObject = NULL;
296  return _SEH2_GetExceptionCode();
297  }
298  _SEH2_END;
299 
302 
303  return Status;
304 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
PFILE_OBJECT FileObject
Definition: ntfs.h:516
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
PNTFS_GLOBAL_DATA NtfsGlobalData
Definition: ntfs.c:41
_SEH2_TRY
Definition: create.c:4250
Definition: ntfs.h:129
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
PFILE_OBJECT NTAPI IoCreateStreamFileObject(IN PFILE_OBJECT FileObject, IN PDEVICE_OBJECT DeviceObject)
Definition: file.c:3186
FSRTL_COMMON_FCB_HEADER RFCB
Definition: ntfs.h:513
PFILE_OBJECT PtrFileObject
Definition: ntfs.h:133
VOID NTAPI CcInitializeCacheMap(IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes, IN BOOLEAN PinAccess, IN PCACHE_MANAGER_CALLBACKS Callbacks, IN PVOID LazyWriteContext)
Definition: fssup.c:193
#define Vcb
Definition: cdprocs.h:1425
#define TAG_CCB
Definition: cdprocs.h:77
* PFILE_OBJECT
Definition: iotypes.h:1955
ULONG Flags
Definition: ntfs.h:532
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
ULONG Type
Definition: ntfs.h:95
#define NTFS_TYPE_CCB
Definition: ntfs.h:87
LARGE_INTEGER AllocationSize
Definition: env_spec_w32.h:755
NTFSIDENTIFIER Identifier
Definition: ntfs.h:131
Status
Definition: gdiplustypes.h:24
#define FCB_CACHE_INITIALIZED
Definition: vfat.h:427
_SEH2_END
Definition: create.c:4424
CACHE_MANAGER_CALLBACKS CacheMgrCallbacks
Definition: ntfs.h:149
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
PVCB Vcb
Definition: cdstruc.h:939
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
_In_ PFCB Fcb
Definition: cdprocs.h:151
return STATUS_SUCCESS
Definition: btrfs.c:2938
SECTION_OBJECT_POINTERS SectionObjectPointers
Definition: ntfs.h:514
ULONG Size
Definition: ntfs.h:96

Referenced by NtfsMakeFCBFromDirEntry(), and NtfsMakeRootFCB().

◆ NtfsFCBIsCompressed()

BOOLEAN NtfsFCBIsCompressed ( PNTFS_FCB  Fcb)

Definition at line 141 of file fcb.c.

142 {
144 }
ULONG FileAttributes
Definition: ntfs.h:363
#define NTFS_FILE_TYPE_COMPRESSED
Definition: ntfs.h:227
_In_ PFCB Fcb
Definition: cdprocs.h:151
FILENAME_ATTRIBUTE Entry
Definition: ntfs.h:538

Referenced by NtfsQueryDirectory(), NtfsReadFile(), and NtfsWriteFile().

◆ NtfsFCBIsDirectory()

BOOLEAN NtfsFCBIsDirectory ( PNTFS_FCB  Fcb)

Definition at line 127 of file fcb.c.

128 {
130 }
#define NTFS_FILE_TYPE_DIRECTORY
Definition: ntfs.h:228
ULONG FileAttributes
Definition: ntfs.h:363
_In_ PFCB Fcb
Definition: cdprocs.h:151
FILENAME_ATTRIBUTE Entry
Definition: ntfs.h:538

Referenced by NtfsCreateFile(), NtfsGetFCBForFile(), NtfsGetStandardInformation(), NtfsMakeAbsoluteFilename(), and NtfsReleaseFCB().

◆ NtfsFCBIsReparsePoint()

BOOLEAN NtfsFCBIsReparsePoint ( PNTFS_FCB  Fcb)

Definition at line 134 of file fcb.c.

135 {
137 }
ULONG FileAttributes
Definition: ntfs.h:363
#define NTFS_FILE_TYPE_REPARSE
Definition: ntfs.h:226
_In_ PFCB Fcb
Definition: cdprocs.h:151
FILENAME_ATTRIBUTE Entry
Definition: ntfs.h:538

Referenced by NtfsCreateFile().

◆ NtfsFCBIsRoot()

BOOLEAN NtfsFCBIsRoot ( PNTFS_FCB  Fcb)

Definition at line 147 of file fcb.c.

148 {
149  return (wcscmp(Fcb->PathName, L"\\") == 0);
150 }
WCHAR PathName[MAX_PATH]
Definition: ntfs.h:521
static const WCHAR L[]
Definition: oid.c:1250
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_In_ PFCB Fcb
Definition: cdprocs.h:151

Referenced by NtfsMakeAbsoluteFilename(), and NtfsMakeFCBFromDirEntry().

◆ NtfsGetFCBForFile()

NTSTATUS NtfsGetFCBForFile ( PNTFS_VCB  Vcb,
PNTFS_FCB pParentFCB,
PNTFS_FCB pFCB,
PCWSTR  pFileName,
BOOLEAN  CaseSensitive 
)

Definition at line 592 of file fcb.c.

597 {
599  WCHAR pathName [MAX_PATH];
600  WCHAR elementName [MAX_PATH];
601  PCWSTR currentElement;
602  PNTFS_FCB FCB;
603  PNTFS_FCB parentFCB;
604 
605  DPRINT("NtfsGetFCBForFile(%p, %p, %p, '%S', %s)\n",
606  Vcb,
607  pParentFCB,
608  pFCB,
609  pFileName,
610  CaseSensitive ? "TRUE" : "FALSE");
611 
612  /* Dummy code */
613 // FCB = NtfsOpenRootFCB(Vcb);
614 // *pFCB = FCB;
615 // *pParentFCB = NULL;
616 
617 #if 1
618  /* Trivial case, open of the root directory on volume */
619  if (pFileName[0] == L'\0' || wcscmp(pFileName, L"\\") == 0)
620  {
621  DPRINT("returning root FCB\n");
622 
624  *pFCB = FCB;
625  *pParentFCB = NULL;
626 
628  }
629  else
630  {
631  currentElement = pFileName + 1;
632  wcscpy (pathName, L"\\");
633  FCB = NtfsOpenRootFCB (Vcb);
634  }
635 
636  parentFCB = NULL;
637 
638  /* Parse filename and check each path element for existence and access */
639  while (NtfsGetNextPathElement(currentElement) != 0)
640  {
641  /* Skip blank directory levels */
642  if ((NtfsGetNextPathElement(currentElement) - currentElement) == 0)
643  {
644  currentElement++;
645  continue;
646  }
647 
648  DPRINT("Parsing, currentElement:%S\n", currentElement);
649  DPRINT(" parentFCB:%p FCB:%p\n", parentFCB, FCB);
650 
651  /* Descend to next directory level */
652  if (parentFCB)
653  {
654  NtfsReleaseFCB(Vcb, parentFCB);
655  parentFCB = NULL;
656  }
657 
658  /* fail if element in FCB is not a directory */
659  if (!NtfsFCBIsDirectory(FCB))
660  {
661  DPRINT("Element in requested path is not a directory\n");
662 
664  FCB = 0;
665  *pParentFCB = NULL;
666  *pFCB = NULL;
667 
669  }
670 
671  parentFCB = FCB;
672 
673  /* Extract next directory level into dirName */
674  NtfsWSubString(pathName,
675  pFileName,
676  NtfsGetNextPathElement(currentElement) - pFileName);
677  DPRINT(" pathName:%S\n", pathName);
678 
679  FCB = NtfsGrabFCBFromTable(Vcb, pathName);
680  if (FCB == NULL)
681  {
682  NtfsWSubString(elementName,
683  currentElement,
684  NtfsGetNextPathElement(currentElement) - currentElement);
685  DPRINT(" elementName:%S\n", elementName);
686 
687  Status = NtfsDirFindFile(Vcb, parentFCB, elementName, CaseSensitive, &FCB);
689  {
690  *pParentFCB = parentFCB;
691  *pFCB = NULL;
692  currentElement = NtfsGetNextPathElement(currentElement);
693  if (*currentElement == L'\0' || NtfsGetNextPathElement(currentElement + 1) == 0)
694  {
696  }
697  else
698  {
700  }
701  }
702  else if (!NT_SUCCESS(Status))
703  {
704  NtfsReleaseFCB(Vcb, parentFCB);
705  *pParentFCB = NULL;
706  *pFCB = NULL;
707 
708  return Status;
709  }
710  }
711 
712  currentElement = NtfsGetNextPathElement(currentElement);
713  }
714 
715  *pParentFCB = parentFCB;
716  *pFCB = FCB;
717 #endif
718 
719  return STATUS_SUCCESS;
720 }
VOID NtfsReleaseFCB(PNTFS_VCB Vcb, PNTFS_FCB Fcb)
Definition: fcb.c:171
const uint16_t * PCWSTR
Definition: typedefs.h:55
PNTFS_FCB NtfsOpenRootFCB(PNTFS_VCB Vcb)
Definition: fcb.c:363
Definition: cdstruc.h:908
LONG NTSTATUS
Definition: precomp.h:26
PNTFS_FCB NtfsGrabFCBFromTable(PNTFS_VCB Vcb, PCWSTR FileName)
Definition: fcb.c:211
BOOLEAN NtfsFCBIsDirectory(PNTFS_FCB Fcb)
Definition: fcb.c:127
struct _FCB FCB
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
static PCWSTR NtfsGetNextPathElement(PCWSTR FileName)
Definition: fcb.c:39
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static NTSTATUS NtfsDirFindFile(PNTFS_VCB Vcb, PNTFS_FCB DirectoryFcb, PWSTR FileToFind, BOOLEAN CaseSensitive, PNTFS_FCB *FoundFCB)
Definition: fcb.c:504
#define Vcb
Definition: cdprocs.h:1425
#define MAX_PATH
Definition: compat.h:26
#define STATUS_OBJECT_PATH_NOT_FOUND
Definition: udferr_usr.h:151
static VOID NtfsWSubString(PWCHAR pTarget, PCWSTR pSource, size_t pLength)
Definition: fcb.c:57
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by NtfsOpenFile().

◆ NtfsGetNextPathElement()

static PCWSTR NtfsGetNextPathElement ( PCWSTR  FileName)
static

Definition at line 39 of file fcb.c.

40 {
41  if (*FileName == L'\0')
42  {
43  return NULL;
44  }
45 
46  while (*FileName != L'\0' && *FileName != L'\\')
47  {
48  FileName++;
49  }
50 
51  return FileName;
52 }
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR L[]
Definition: oid.c:1250
struct _FileName FileName
Definition: fatprocs.h:884

Referenced by NtfsGetFCBForFile().

◆ NtfsGrabFCB()

VOID NtfsGrabFCB ( PNTFS_VCB  Vcb,
PNTFS_FCB  Fcb 
)

Definition at line 154 of file fcb.c.

156 {
157  KIRQL oldIrql;
158 
159  DPRINT("grabbing FCB at %p: %S, refCount:%d\n",
160  Fcb,
161  Fcb->PathName,
162  Fcb->RefCount);
163 
164  KeAcquireSpinLock(&Vcb->FcbListLock, &oldIrql);
165  Fcb->RefCount++;
166  KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
167 }
WCHAR PathName[MAX_PATH]
Definition: ntfs.h:521
UCHAR KIRQL
Definition: env_spec_w32.h:591
LONG RefCount
Definition: ntfs.h:531
void DPRINT(...)
Definition: polytest.cpp:61
#define Vcb
Definition: cdprocs.h:1425
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
_In_ PFCB Fcb
Definition: cdprocs.h:151

Referenced by NtfsMakeRootFCB().

◆ NtfsGrabFCBFromTable()

PNTFS_FCB NtfsGrabFCBFromTable ( PNTFS_VCB  Vcb,
PCWSTR  FileName 
)

Definition at line 211 of file fcb.c.

213 {
214  KIRQL oldIrql;
215  PNTFS_FCB Fcb;
216  PLIST_ENTRY current_entry;
217 
218  KeAcquireSpinLock(&Vcb->FcbListLock, &oldIrql);
219 
220  if (FileName == NULL || *FileName == 0)
221  {
222  DPRINT("Return FCB for stream file object\n");
223  Fcb = Vcb->StreamFileObject->FsContext;
224  Fcb->RefCount++;
225  KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
226  return Fcb;
227  }
228 
229  current_entry = Vcb->FcbListHead.Flink;
230  while (current_entry != &Vcb->FcbListHead)
231  {
232  Fcb = CONTAINING_RECORD(current_entry, NTFS_FCB, FcbListEntry);
233 
234  DPRINT("Comparing '%S' and '%S'\n", FileName, Fcb->PathName);
235  if (_wcsicmp(FileName, Fcb->PathName) == 0)
236  {
237  Fcb->RefCount++;
238  KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
239  return Fcb;
240  }
241 
242  //FIXME: need to compare against short name in FCB here
243 
244  current_entry = current_entry->Flink;
245  }
246 
247  KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
248 
249  return NULL;
250 }
Definition: cdstruc.h:908
WCHAR PathName[MAX_PATH]
Definition: ntfs.h:521
UCHAR KIRQL
Definition: env_spec_w32.h:591
LONG RefCount
Definition: ntfs.h:531
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define Vcb
Definition: cdprocs.h:1425
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
Definition: typedefs.h:117
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
_In_ PFCB Fcb
Definition: cdprocs.h:151
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

Referenced by NtfsGetFCBForFile(), NtfsOpenFile(), NtfsOpenFileById(), and NtfsOpenRootFCB().

◆ NtfsMakeFCBFromDirEntry()

NTSTATUS NtfsMakeFCBFromDirEntry ( PNTFS_VCB  Vcb,
PNTFS_FCB  DirectoryFCB,
PUNICODE_STRING  Name,
PCWSTR  Stream,
PFILE_RECORD_HEADER  Record,
ULONGLONG  MFTIndex,
PNTFS_FCB fileFCB 
)

Definition at line 378 of file fcb.c.

385 {
386  WCHAR pathName[MAX_PATH];
388  PSTANDARD_INFORMATION StdInfo;
389  PNTFS_FCB rcFCB;
390  ULONGLONG Size, AllocatedSize;
391 
392  DPRINT("NtfsMakeFCBFromDirEntry(%p, %p, %wZ, %p, %p, %p)\n", Vcb, DirectoryFCB, Name, Stream, Record, fileFCB);
393 
395  if (!FileName)
396  {
397  return STATUS_OBJECT_NAME_NOT_FOUND; // Not sure that's the best here
398  }
399 
400  if (DirectoryFCB && Name)
401  {
402  if (Name->Buffer[0] != 0 && wcslen(DirectoryFCB->PathName) +
403  sizeof(WCHAR) + Name->Length / sizeof(WCHAR) > MAX_PATH)
404  {
406  }
407 
408  wcscpy(pathName, DirectoryFCB->PathName);
409  if (!NtfsFCBIsRoot(DirectoryFCB))
410  {
411  wcscat(pathName, L"\\");
412  }
413  wcscat(pathName, Name->Buffer);
414  }
415  else
416  {
417  RtlCopyMemory(pathName, FileName->Name, FileName->NameLength * sizeof (WCHAR));
418  pathName[FileName->NameLength] = UNICODE_NULL;
419  }
420 
421  Size = NtfsGetFileSize(Vcb, Record, (Stream ? Stream : L""), (Stream ? wcslen(Stream) : 0), &AllocatedSize);
422 
423  rcFCB = NtfsCreateFCB(pathName, Stream, Vcb);
424  if (!rcFCB)
425  {
427  }
428 
429  memcpy(&rcFCB->Entry, FileName, FIELD_OFFSET(FILENAME_ATTRIBUTE, NameLength));
430  rcFCB->Entry.NameType = FileName->NameType;
431  rcFCB->RFCB.FileSize.QuadPart = Size;
433  rcFCB->RFCB.AllocationSize.QuadPart = AllocatedSize;
434 
436  if (StdInfo != NULL)
437  {
438  rcFCB->Entry.FileAttributes |= StdInfo->FileAttribute;
439  }
440 
441  NtfsFCBInitializeCache(Vcb, rcFCB);
442  rcFCB->RefCount = 1;
443  rcFCB->MFTIndex = MFTIndex;
444  rcFCB->LinkCount = Record->LinkCount;
445  NtfsAddFCBToTable(Vcb, rcFCB);
446  *fileFCB = rcFCB;
447 
448  return STATUS_SUCCESS;
449 }
PFILENAME_ATTRIBUTE GetBestFileNameFromRecord(PDEVICE_EXTENSION Vcb, PFILE_RECORD_HEADER FileRecord)
Definition: attrib.c:1985
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
Definition: cdstruc.h:908
ULONG FileAttribute
Definition: ntfs.h:330
VOID NtfsAddFCBToTable(PNTFS_VCB Vcb, PNTFS_FCB Fcb)
Definition: fcb.c:198
PNTFS_FCB NtfsCreateFCB(PCWSTR FileName, PCWSTR Stream, PNTFS_VCB Vcb)
Definition: fcb.c:67
USHORT LinkCount
Definition: ntfs.h:536
WCHAR PathName[MAX_PATH]
Definition: ntfs.h:521
ULONGLONG MFTIndex
Definition: ntfs.h:535
NTSTATUS NtfsFCBInitializeCache(PNTFS_VCB Vcb, PNTFS_FCB Fcb)
Definition: fcb.c:254
PSTANDARD_INFORMATION GetStandardInformationFromRecord(PDEVICE_EXTENSION Vcb, PFILE_RECORD_HEADER FileRecord)
Definition: attrib.c:1940
ULONG FileAttributes
Definition: ntfs.h:363
_In_ struct _KBUGCHECK_REASON_CALLBACK_RECORD * Record
Definition: ketypes.h:256
#define UNICODE_NULL
LONG RefCount
Definition: ntfs.h:531
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
FSRTL_COMMON_FCB_HEADER RFCB
Definition: ntfs.h:513
ULONGLONG NtfsGetFileSize(PDEVICE_EXTENSION DeviceExt, PFILE_RECORD_HEADER FileRecord, PCWSTR Stream, ULONG StreamLength, PULONGLONG AllocatedSize)
Definition: dirctl.c:38
TCHAR Name[MAX_PATH]
Definition: filecomp.c:349
__wchar_t WCHAR
Definition: xmlstorage.h:180
uint64_t ULONGLONG
Definition: typedefs.h:65
#define Vcb
Definition: cdprocs.h:1425
#define MAX_PATH
Definition: compat.h:26
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
LARGE_INTEGER AllocationSize
Definition: env_spec_w32.h:755
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
struct _FileName FileName
Definition: fatprocs.h:884
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define STATUS_OBJECT_NAME_INVALID
Definition: udferr_usr.h:148
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
LARGE_INTEGER ValidDataLength
Definition: env_spec_w32.h:757
return STATUS_SUCCESS
Definition: btrfs.c:2938
FILENAME_ATTRIBUTE Entry
Definition: ntfs.h:538
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING Stream
Definition: fltkernel.h:1092
BOOLEAN NtfsFCBIsRoot(PNTFS_FCB Fcb)
Definition: fcb.c:147
LONGLONG QuadPart
Definition: typedefs.h:112
UCHAR NameType
Definition: ntfs.h:374

Referenced by NtfsDirFindFile(), and NtfsOpenFileById().

◆ NtfsMakeRootFCB()

PNTFS_FCB NtfsMakeRootFCB ( PNTFS_VCB  Vcb)

Definition at line 308 of file fcb.c.

309 {
310  PNTFS_FCB Fcb;
311  PFILE_RECORD_HEADER MftRecord;
313 
314  MftRecord = ExAllocateFromNPagedLookasideList(&Vcb->FileRecLookasideList);
315  if (MftRecord == NULL)
316  {
317  return NULL;
318  }
319 
320  if (!NT_SUCCESS(ReadFileRecord(Vcb, NTFS_FILE_ROOT, MftRecord)))
321  {
322  ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, MftRecord);
323  return NULL;
324  }
325 
327  if (!FileName)
328  {
329  ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, MftRecord);
330  return NULL;
331  }
332 
333  Fcb = NtfsCreateFCB(L"\\", NULL, Vcb);
334  if (!Fcb)
335  {
336  ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, MftRecord);
337  return NULL;
338  }
339 
341  Fcb->Entry.NameType = FileName->NameType;
342  Fcb->Entry.NameLength = 0;
343  Fcb->Entry.Name[0] = UNICODE_NULL;
344  Fcb->RefCount = 1;
345  Fcb->DirIndex = 0;
346  Fcb->RFCB.FileSize.QuadPart = FileName->DataSize;
348  Fcb->RFCB.AllocationSize.QuadPart = FileName->AllocatedSize;
350  Fcb->LinkCount = MftRecord->LinkCount;
351 
354  NtfsGrabFCB(Vcb, Fcb);
355 
356  ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, MftRecord);
357 
358  return Fcb;
359 }
WCHAR Name[1]
Definition: ntfs.h:375
Definition: cdstruc.h:908
PFILENAME_ATTRIBUTE GetFileNameFromRecord(PDEVICE_EXTENSION Vcb, PFILE_RECORD_HEADER FileRecord, UCHAR NameType)
Definition: attrib.c:1809
ULONG DirIndex
Definition: ntfs.h:529
VOID NtfsAddFCBToTable(PNTFS_VCB Vcb, PNTFS_FCB Fcb)
Definition: fcb.c:198
PNTFS_FCB NtfsCreateFCB(PCWSTR FileName, PCWSTR Stream, PNTFS_VCB Vcb)
Definition: fcb.c:67
USHORT LinkCount
Definition: ntfs.h:536
UCHAR NameLength
Definition: ntfs.h:373
ULONGLONG MFTIndex
Definition: ntfs.h:535
NTSTATUS NtfsFCBInitializeCache(PNTFS_VCB Vcb, PNTFS_FCB Fcb)
Definition: fcb.c:254
#define UNICODE_NULL
LONG RefCount
Definition: ntfs.h:531
smooth NULL
Definition: ftsmooth.c:416
USHORT LinkCount
Definition: ntfs.h:250
FSRTL_COMMON_FCB_HEADER RFCB
Definition: ntfs.h:513
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define Vcb
Definition: cdprocs.h:1425
static const WCHAR L[]
Definition: oid.c:1250
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
LARGE_INTEGER AllocationSize
Definition: env_spec_w32.h:755
struct _FileName FileName
Definition: fatprocs.h:884
NTSTATUS ReadFileRecord(PDEVICE_EXTENSION Vcb, ULONGLONG index, PFILE_RECORD_HEADER file)
Definition: mft.c:1631
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define NTFS_FILE_NAME_WIN32
Definition: ntfs.h:64
_In_ PFCB Fcb
Definition: cdprocs.h:151
LARGE_INTEGER ValidDataLength
Definition: env_spec_w32.h:757
FILENAME_ATTRIBUTE Entry
Definition: ntfs.h:538
VOID NtfsGrabFCB(PNTFS_VCB Vcb, PNTFS_FCB Fcb)
Definition: fcb.c:154
LONGLONG QuadPart
Definition: typedefs.h:112
UCHAR NameType
Definition: ntfs.h:374
#define NTFS_FILE_ROOT
Definition: ntfs.h:28

Referenced by NtfsOpenRootFCB().

◆ NtfsOpenRootFCB()

PNTFS_FCB NtfsOpenRootFCB ( PNTFS_VCB  Vcb)

Definition at line 363 of file fcb.c.

364 {
365  PNTFS_FCB Fcb;
366 
367  Fcb = NtfsGrabFCBFromTable(Vcb, L"\\");
368  if (Fcb == NULL)
369  {
371  }
372 
373  return Fcb;
374 }
Definition: cdstruc.h:908
PNTFS_FCB NtfsGrabFCBFromTable(PNTFS_VCB Vcb, PCWSTR FileName)
Definition: fcb.c:211
PNTFS_FCB NtfsMakeRootFCB(PNTFS_VCB Vcb)
Definition: fcb.c:308
smooth NULL
Definition: ftsmooth.c:416
#define Vcb
Definition: cdprocs.h:1425
static const WCHAR L[]
Definition: oid.c:1250
_In_ PFCB Fcb
Definition: cdprocs.h:151

Referenced by NtfsGetFCBForFile().

◆ NtfsReadFCBAttribute()

NTSTATUS NtfsReadFCBAttribute ( PNTFS_VCB  Vcb,
PNTFS_FCB  pFCB,
ULONG  Type,
PCWSTR  Name,
ULONG  NameLength,
PVOID Data 
)

Definition at line 724 of file fcb.c.

730 {
732  PFILE_RECORD_HEADER FileRecord;
733  PNTFS_ATTR_CONTEXT AttrCtxt;
734  ULONGLONG AttrLength;
735 
736  FileRecord = ExAllocateFromNPagedLookasideList(&Vcb->FileRecLookasideList);
737  if (FileRecord == NULL)
738  {
740  }
741 
742  Status = ReadFileRecord(Vcb, pFCB->MFTIndex, FileRecord);
743  if (!NT_SUCCESS(Status))
744  {
745  ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, FileRecord);
746  return Status;
747  }
748 
749  Status = FindAttribute(Vcb, FileRecord, Type, Name, NameLength, &AttrCtxt, NULL);
750  if (!NT_SUCCESS(Status))
751  {
752  ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, FileRecord);
753  return Status;
754  }
755 
756  AttrLength = AttributeDataLength(AttrCtxt->pRecord);
758  if (*Data == NULL)
759  {
760  ReleaseAttributeContext(AttrCtxt);
761  ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, FileRecord);
763  }
764 
765  ReadAttribute(Vcb, AttrCtxt, 0, *Data, AttrLength);
766 
767  ReleaseAttributeContext(AttrCtxt);
768  ExFreeToNPagedLookasideList(&Vcb->FileRecLookasideList, FileRecord);
769 
770  return STATUS_SUCCESS;
771 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
Type
Definition: Type.h:6
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS FindAttribute(PDEVICE_EXTENSION Vcb, PFILE_RECORD_HEADER MftRecord, ULONG Type, PCWSTR Name, ULONG NameLength, PNTFS_ATTR_CONTEXT *AttrCtx, PULONG Offset)
Definition: mft.c:131
ULONGLONG MFTIndex
Definition: ntfs.h:535
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
uint64_t ULONGLONG
Definition: typedefs.h:65
#define Vcb
Definition: cdprocs.h:1425
#define TAG_NTFS
Definition: ntfs.h:12
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
Status
Definition: gdiplustypes.h:24
NTSTATUS ReadFileRecord(PDEVICE_EXTENSION Vcb, ULONGLONG index, PFILE_RECORD_HEADER file)
Definition: mft.c:1631
VOID ReleaseAttributeContext(PNTFS_ATTR_CONTEXT Context)
Definition: mft.c:104
ULONG ReadAttribute(PDEVICE_EXTENSION Vcb, PNTFS_ATTR_CONTEXT Context, ULONGLONG Offset, PCHAR Buffer, ULONG Length)
Definition: mft.c:1065
return STATUS_SUCCESS
Definition: btrfs.c:2938
ULONGLONG AttributeDataLength(PNTFS_ATTR_RECORD AttrRecord)
Definition: mft.c:259

Referenced by NtfsCreateFile().

◆ NtfsReleaseFCB()

VOID NtfsReleaseFCB ( PNTFS_VCB  Vcb,
PNTFS_FCB  Fcb 
)

Definition at line 171 of file fcb.c.

173 {
174  KIRQL oldIrql;
175 
176  DPRINT("releasing FCB at %p: %S, refCount:%d\n",
177  Fcb,
178  Fcb->PathName,
179  Fcb->RefCount);
180 
181  KeAcquireSpinLock(&Vcb->FcbListLock, &oldIrql);
182  Fcb->RefCount--;
183  if (Fcb->RefCount <= 0 && !NtfsFCBIsDirectory(Fcb))
184  {
186  KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
189  }
190  else
191  {
192  KeReleaseSpinLock(&Vcb->FcbListLock, oldIrql);
193  }
194 }
LIST_ENTRY FcbListEntry
Definition: ntfs.h:526
PFILE_OBJECT FileObject
Definition: ntfs.h:516
WCHAR PathName[MAX_PATH]
Definition: ntfs.h:521
BOOLEAN NtfsFCBIsDirectory(PNTFS_FCB Fcb)
Definition: fcb.c:127
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
LONG RefCount
Definition: ntfs.h:531
VOID NtfsDestroyFCB(PNTFS_FCB Fcb)
Definition: fcb.c:115
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define Vcb
Definition: cdprocs.h:1425
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
BOOLEAN NTAPI CcUninitializeCacheMap(IN PFILE_OBJECT FileObject, IN OPTIONAL PLARGE_INTEGER TruncateSize, IN OPTIONAL PCACHE_UNINITIALIZE_EVENT UninitializeEvent)
Definition: fssup.c:284
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
_In_ PFCB Fcb
Definition: cdprocs.h:151

Referenced by NtfsCloseFile(), NtfsGetFCBForFile(), and NtfsOpenFile().

◆ NtfsWSubString()

static VOID NtfsWSubString ( PWCHAR  pTarget,
PCWSTR  pSource,
size_t  pLength 
)
static

Definition at line 57 of file fcb.c.

60 {
61  wcsncpy(pTarget, pSource, pLength);
62  pTarget[pLength] = L'\0';
63 }
static const WCHAR L[]
Definition: oid.c:1250
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)

Referenced by NtfsGetFCBForFile().