Author: pschweitzer
Date: Sun Jul 5 19:04:05 2015
New Revision: 68348
URL:
http://svn.reactos.org/svn/reactos?rev=68348&view=rev
Log:
[NTFS]
Continue streams integration:
- NtfsGetFileSize() will now return the file size depending on the open data stream
- NtfsGetFileSize() will also optionally return allocated size
- In NtfsMakeFCBFromDirEntry(), when initializing FSRTL_COMMON_FCB_HEADER entry, use data
stream sizes
Modified:
trunk/reactos/drivers/filesystems/ntfs/dirctl.c
trunk/reactos/drivers/filesystems/ntfs/fcb.c
trunk/reactos/drivers/filesystems/ntfs/ntfs.h
Modified: trunk/reactos/drivers/filesystems/ntfs/dirctl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/ntfs/d…
==============================================================================
--- trunk/reactos/drivers/filesystems/ntfs/dirctl.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/ntfs/dirctl.c [iso-8859-1] Sun Jul 5 19:04:05 2015
@@ -35,22 +35,27 @@
/* FUNCTIONS ****************************************************************/
-static ULONGLONG
+ULONGLONG
NtfsGetFileSize(PDEVICE_EXTENSION DeviceExt,
PFILE_RECORD_HEADER FileRecord,
- PFILENAME_ATTRIBUTE FileName)
-{
- ULONGLONG Size;
+ PCWSTR Stream,
+ ULONG StreamLength,
+ PULONGLONG AllocatedSize)
+{
+ ULONGLONG Size = 0ULL;
+ ULONGLONG Allocated = 0ULL;
NTSTATUS Status;
PNTFS_ATTR_CONTEXT DataContext;
- Size = FileName->AllocatedSize;
- Status = FindAttribute(DeviceExt, FileRecord, AttributeData, L"", 0,
&DataContext);
+ Status = FindAttribute(DeviceExt, FileRecord, AttributeData, Stream, StreamLength,
&DataContext);
if (NT_SUCCESS(Status))
{
Size = AttributeDataLength(&DataContext->Record);
+ Allocated = AttributeAllocatedLength(&DataContext->Record);
ReleaseAttributeContext(DataContext);
}
+
+ if (AllocatedSize != NULL) *AllocatedSize = Allocated;
return Size;
}
@@ -130,7 +135,7 @@
/* Convert file flags */
NtfsFileFlagsToAttributes(FileName->FileAttributes | StdInfo->FileAttribute,
&Info->FileAttributes);
- Info->EndOfFile.QuadPart = NtfsGetFileSize(DeviceExt, FileRecord, FileName);
+ Info->EndOfFile.QuadPart = NtfsGetFileSize(DeviceExt, FileRecord, L"",
0, NULL);
Info->AllocationSize.QuadPart = ROUND_UP(Info->EndOfFile.QuadPart,
DeviceExt->NtfsInfo.BytesPerCluster);
Info->FileIndex = MFTIndex;
@@ -180,7 +185,7 @@
/* Convert file flags */
NtfsFileFlagsToAttributes(FileName->FileAttributes | StdInfo->FileAttribute,
&Info->FileAttributes);
- Info->EndOfFile.QuadPart = NtfsGetFileSize(DeviceExt, FileRecord, FileName);
+ Info->EndOfFile.QuadPart = NtfsGetFileSize(DeviceExt, FileRecord, L"",
0, NULL);
Info->AllocationSize.QuadPart = ROUND_UP(Info->EndOfFile.QuadPart,
DeviceExt->NtfsInfo.BytesPerCluster);
Info->FileIndex = MFTIndex;
@@ -245,7 +250,7 @@
/* Convert file flags */
NtfsFileFlagsToAttributes(FileName->FileAttributes | StdInfo->FileAttribute,
&Info->FileAttributes);
- Info->EndOfFile.QuadPart = NtfsGetFileSize(DeviceExt, FileRecord, FileName);
+ Info->EndOfFile.QuadPart = NtfsGetFileSize(DeviceExt, FileRecord, L"",
0, NULL);
Info->AllocationSize.QuadPart = ROUND_UP(Info->EndOfFile.QuadPart,
DeviceExt->NtfsInfo.BytesPerCluster);
Info->FileIndex = MFTIndex;
@@ -362,7 +367,7 @@
*/
if (MFTRecord == OldMFTRecord)
{
- DPRINT("Ignoring duplicate MFT entry 0x%x\n", MFTRecord);
+ DPRINT1("Ignoring duplicate MFT entry 0x%x\n", MFTRecord);
Ccb->Entry++;
ExFreePoolWithTag(FileRecord, TAG_NTFS);
continue;
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] Sun Jul 5 19:04:05 2015
@@ -421,6 +421,7 @@
PFILENAME_ATTRIBUTE FileName;
PSTANDARD_INFORMATION StdInfo;
PNTFS_FCB rcFCB;
+ ULONGLONG Size, AllocatedSize;
DPRINT1("NtfsMakeFCBFromDirEntry(%p, %p, %wZ, %p, %p, %p)\n", Vcb,
DirectoryFCB, Name, Stream, Record, fileFCB);
@@ -451,6 +452,8 @@
pathName[FileName->NameLength] = UNICODE_NULL;
}
+ Size = NtfsGetFileSize(Vcb, Record, Stream, wcslen(Stream), &AllocatedSize);
+
rcFCB = NtfsCreateFCB(pathName, Stream, Vcb);
if (!rcFCB)
{
@@ -459,9 +462,9 @@
memcpy(&rcFCB->Entry, FileName, FIELD_OFFSET(FILENAME_ATTRIBUTE,
NameLength));
rcFCB->Entry.NameType = FileName->NameType;
- rcFCB->RFCB.FileSize.QuadPart = FileName->DataSize;
- rcFCB->RFCB.ValidDataLength.QuadPart = FileName->DataSize;
- rcFCB->RFCB.AllocationSize.QuadPart = FileName->AllocatedSize;
+ rcFCB->RFCB.FileSize.QuadPart = Size;
+ rcFCB->RFCB.ValidDataLength.QuadPart = Size;
+ rcFCB->RFCB.AllocationSize.QuadPart = AllocatedSize;
StdInfo = GetStandardInformationFromRecord(Record);
if (StdInfo != NULL)
Modified: trunk/reactos/drivers/filesystems/ntfs/ntfs.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/ntfs/n…
==============================================================================
--- trunk/reactos/drivers/filesystems/ntfs/ntfs.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/ntfs/ntfs.h [iso-8859-1] Sun Jul 5 19:04:05 2015
@@ -550,6 +550,13 @@
/* dirctl.c */
+ULONGLONG
+NtfsGetFileSize(PDEVICE_EXTENSION DeviceExt,
+ PFILE_RECORD_HEADER FileRecord,
+ PCWSTR Stream,
+ ULONG StreamLength,
+ PULONGLONG AllocatedSize);
+
NTSTATUS
NtfsDirectoryControl(PNTFS_IRP_CONTEXT IrpContext);