Author: pschweitzer
Date: Mon Oct 6 20:51:41 2014
New Revision: 64577
URL:
http://svn.reactos.org/svn/reactos?rev=64577&view=rev
Log:
[NTFS]
- Implement NtfsDirFindFile()
- Enable again NtfsMakeFCBFromDirEntry() and fix its prototype but disable its
implementation yet
Modified:
trunk/reactos/drivers/filesystems/ntfs/fcb.c
Modified: trunk/reactos/drivers/filesystems/ntfs/fcb.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/ntfs/f…
==============================================================================
--- trunk/reactos/drivers/filesystems/ntfs/fcb.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/ntfs/fcb.c [iso-8859-1] Mon Oct 6 20:51:41 2014
@@ -348,15 +348,17 @@
DPRINT("Name '%S'\n", Name);
}
+#endif
NTSTATUS
-NtfsMakeFCBFromDirEntry(PVCB Vcb,
- PFCB DirectoryFCB,
+NtfsMakeFCBFromDirEntry(PNTFS_VCB Vcb,
+ PNTFS_FCB DirectoryFCB,
PWSTR Name,
- PDIR_RECORD Record,
- PFCB * fileFCB)
-{
+ PFILE_RECORD_HEADER Record,
+ PNTFS_FCB * fileFCB)
+{
+#if 0
WCHAR pathName[MAX_PATH];
PFCB rcFCB;
ULONG Size;
@@ -400,8 +402,10 @@
*fileFCB = rcFCB;
return(STATUS_SUCCESS);
-}
+#else
+ return STATUS_NOT_IMPLEMENTED;
#endif
+}
NTSTATUS
@@ -451,113 +455,26 @@
PWSTR FileToFind,
PNTFS_FCB *FoundFCB)
{
-#if 0
- WCHAR TempName[2];
- WCHAR Name[256];
- PVOID Block;
- ULONG FirstSector;
- ULONG DirSize;
- PDIR_RECORD Record;
- ULONG Offset;
- ULONG BlockOffset;
- NTSTATUS Status;
-
- LARGE_INTEGER StreamOffset;
- PVOID Context;
-
- ASSERT(DeviceExt);
- ASSERT(DirectoryFcb);
- ASSERT(FileToFind);
-
- DPRINT("NtfsDirFindFile(VCB:%08x, dirFCB:%08x, File:%S)\n",
- DeviceExt,
- DirectoryFcb,
- FileToFind);
- DPRINT("Dir Path:%S\n", DirectoryFcb->PathName);
-
- /* default to '.' if no filename specified */
- if (wcslen(FileToFind) == 0)
- {
- TempName[0] = L'.';
- TempName[1] = 0;
- FileToFind = TempName;
- }
-
- DirSize = DirectoryFcb->Entry.DataLengthL;
- StreamOffset.QuadPart = (LONGLONG)DirectoryFcb->Entry.ExtentLocationL *
(LONGLONG)BLOCKSIZE;
-
- if(!CcMapData(DeviceExt->StreamFileObject, &StreamOffset,
- BLOCKSIZE, TRUE, &Context, &Block))
- {
- DPRINT("CcMapData() failed\n");
- return(STATUS_UNSUCCESSFUL);
- }
-
- Offset = 0;
- BlockOffset = 0;
- Record = (PDIR_RECORD)Block;
- while(TRUE)
- {
- if (Record->RecordLength == 0)
- {
- DPRINT("RecordLength == 0 Stopped!\n");
- break;
- }
-
- DPRINT("RecordLength %u ExtAttrRecordLength %u NameLength %u\n",
- Record->RecordLength, Record->ExtAttrRecordLength, Record->FileIdLength);
-
- NtfsGetDirEntryName(DeviceExt, Record, Name);
- DPRINT("Name '%S'\n", Name);
-
- if (wstrcmpjoki(Name, FileToFind))
- {
- DPRINT("Match found, %S\n", Name);
- Status = NtfsMakeFCBFromDirEntry(DeviceExt,
- DirectoryFcb,
- Name,
- Record,
- FoundFCB);
-
- CcUnpinData(Context);
-
- return(Status);
- }
-
- Offset += Record->RecordLength;
- BlockOffset += Record->RecordLength;
- Record = (PDIR_RECORD)(Block + BlockOffset);
- if (BlockOffset >= BLOCKSIZE || Record->RecordLength == 0)
- {
- DPRINT("Map next sector\n");
- CcUnpinData(Context);
- StreamOffset.QuadPart += BLOCKSIZE;
- Offset = ROUND_UP(Offset, BLOCKSIZE);
- BlockOffset = 0;
-
- if (!CcMapData(DeviceExt->StreamFileObject,
- &StreamOffset,
- BLOCKSIZE, TRUE,
- &Context, &Block))
- {
- DPRINT("CcMapData() failed\n");
- return(STATUS_UNSUCCESSFUL);
- }
- Record = (PDIR_RECORD)(Block + BlockOffset);
- }
-
- if (Offset >= DirSize)
- break;
- }
-
- CcUnpinData(Context);
-#else
- UNREFERENCED_PARAMETER(Vcb);
- UNREFERENCED_PARAMETER(DirectoryFcb);
- UNREFERENCED_PARAMETER(FileToFind);
- UNREFERENCED_PARAMETER(FoundFCB);
-#endif
- return STATUS_OBJECT_NAME_NOT_FOUND;
+ NTSTATUS Status;
+ ULONGLONG CurrentDir;
+ UNICODE_STRING File;
+ PFILE_RECORD_HEADER FileRecord;
+ PNTFS_ATTR_CONTEXT DataContext;
+
+ *FoundFCB = NULL;
+ RtlInitUnicodeString(&File, FileToFind);
+ CurrentDir = DirectoryFcb->MFTIndex;
+
+ Status = NtfsLookupFileAt(Vcb, &File, &FileRecord, &DataContext,
CurrentDir);
+ if (!NT_SUCCESS(Status))
+ {
+ return Status;
+ }
+
+ Status = NtfsMakeFCBFromDirEntry(Vcb, DirectoryFcb, FileToFind, FileRecord,
FoundFCB);
+ ExFreePoolWithTag(FileRecord, TAG_NTFS);
+
+ return Status;
}