mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 19:03:00 +00:00
[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 svn path=/trunk/; revision=68348
This commit is contained in:
parent
83159263f9
commit
53bbe9ea86
3 changed files with 27 additions and 12 deletions
|
@ -35,23 +35,28 @@
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
|
|
||||||
static ULONGLONG
|
ULONGLONG
|
||||||
NtfsGetFileSize(PDEVICE_EXTENSION DeviceExt,
|
NtfsGetFileSize(PDEVICE_EXTENSION DeviceExt,
|
||||||
PFILE_RECORD_HEADER FileRecord,
|
PFILE_RECORD_HEADER FileRecord,
|
||||||
PFILENAME_ATTRIBUTE FileName)
|
PCWSTR Stream,
|
||||||
|
ULONG StreamLength,
|
||||||
|
PULONGLONG AllocatedSize)
|
||||||
{
|
{
|
||||||
ULONGLONG Size;
|
ULONGLONG Size = 0ULL;
|
||||||
|
ULONGLONG Allocated = 0ULL;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PNTFS_ATTR_CONTEXT DataContext;
|
PNTFS_ATTR_CONTEXT DataContext;
|
||||||
|
|
||||||
Size = FileName->AllocatedSize;
|
Status = FindAttribute(DeviceExt, FileRecord, AttributeData, Stream, StreamLength, &DataContext);
|
||||||
Status = FindAttribute(DeviceExt, FileRecord, AttributeData, L"", 0, &DataContext);
|
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
Size = AttributeDataLength(&DataContext->Record);
|
Size = AttributeDataLength(&DataContext->Record);
|
||||||
|
Allocated = AttributeAllocatedLength(&DataContext->Record);
|
||||||
ReleaseAttributeContext(DataContext);
|
ReleaseAttributeContext(DataContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (AllocatedSize != NULL) *AllocatedSize = Allocated;
|
||||||
|
|
||||||
return Size;
|
return Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +135,7 @@ NtfsGetDirectoryInformation(PDEVICE_EXTENSION DeviceExt,
|
||||||
/* Convert file flags */
|
/* Convert file flags */
|
||||||
NtfsFileFlagsToAttributes(FileName->FileAttributes | StdInfo->FileAttribute, &Info->FileAttributes);
|
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->AllocationSize.QuadPart = ROUND_UP(Info->EndOfFile.QuadPart, DeviceExt->NtfsInfo.BytesPerCluster);
|
||||||
|
|
||||||
Info->FileIndex = MFTIndex;
|
Info->FileIndex = MFTIndex;
|
||||||
|
@ -180,7 +185,7 @@ NtfsGetFullDirectoryInformation(PDEVICE_EXTENSION DeviceExt,
|
||||||
/* Convert file flags */
|
/* Convert file flags */
|
||||||
NtfsFileFlagsToAttributes(FileName->FileAttributes | StdInfo->FileAttribute, &Info->FileAttributes);
|
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->AllocationSize.QuadPart = ROUND_UP(Info->EndOfFile.QuadPart, DeviceExt->NtfsInfo.BytesPerCluster);
|
||||||
|
|
||||||
Info->FileIndex = MFTIndex;
|
Info->FileIndex = MFTIndex;
|
||||||
|
@ -245,7 +250,7 @@ NtfsGetBothDirectoryInformation(PDEVICE_EXTENSION DeviceExt,
|
||||||
/* Convert file flags */
|
/* Convert file flags */
|
||||||
NtfsFileFlagsToAttributes(FileName->FileAttributes | StdInfo->FileAttribute, &Info->FileAttributes);
|
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->AllocationSize.QuadPart = ROUND_UP(Info->EndOfFile.QuadPart, DeviceExt->NtfsInfo.BytesPerCluster);
|
||||||
|
|
||||||
Info->FileIndex = MFTIndex;
|
Info->FileIndex = MFTIndex;
|
||||||
|
@ -362,7 +367,7 @@ NtfsQueryDirectory(PNTFS_IRP_CONTEXT IrpContext)
|
||||||
*/
|
*/
|
||||||
if (MFTRecord == OldMFTRecord)
|
if (MFTRecord == OldMFTRecord)
|
||||||
{
|
{
|
||||||
DPRINT("Ignoring duplicate MFT entry 0x%x\n", MFTRecord);
|
DPRINT1("Ignoring duplicate MFT entry 0x%x\n", MFTRecord);
|
||||||
Ccb->Entry++;
|
Ccb->Entry++;
|
||||||
ExFreePoolWithTag(FileRecord, TAG_NTFS);
|
ExFreePoolWithTag(FileRecord, TAG_NTFS);
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -421,6 +421,7 @@ NtfsMakeFCBFromDirEntry(PNTFS_VCB Vcb,
|
||||||
PFILENAME_ATTRIBUTE FileName;
|
PFILENAME_ATTRIBUTE FileName;
|
||||||
PSTANDARD_INFORMATION StdInfo;
|
PSTANDARD_INFORMATION StdInfo;
|
||||||
PNTFS_FCB rcFCB;
|
PNTFS_FCB rcFCB;
|
||||||
|
ULONGLONG Size, AllocatedSize;
|
||||||
|
|
||||||
DPRINT1("NtfsMakeFCBFromDirEntry(%p, %p, %wZ, %p, %p, %p)\n", Vcb, DirectoryFCB, Name, Stream, Record, fileFCB);
|
DPRINT1("NtfsMakeFCBFromDirEntry(%p, %p, %wZ, %p, %p, %p)\n", Vcb, DirectoryFCB, Name, Stream, Record, fileFCB);
|
||||||
|
|
||||||
|
@ -451,6 +452,8 @@ NtfsMakeFCBFromDirEntry(PNTFS_VCB Vcb,
|
||||||
pathName[FileName->NameLength] = UNICODE_NULL;
|
pathName[FileName->NameLength] = UNICODE_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Size = NtfsGetFileSize(Vcb, Record, Stream, wcslen(Stream), &AllocatedSize);
|
||||||
|
|
||||||
rcFCB = NtfsCreateFCB(pathName, Stream, Vcb);
|
rcFCB = NtfsCreateFCB(pathName, Stream, Vcb);
|
||||||
if (!rcFCB)
|
if (!rcFCB)
|
||||||
{
|
{
|
||||||
|
@ -459,9 +462,9 @@ NtfsMakeFCBFromDirEntry(PNTFS_VCB Vcb,
|
||||||
|
|
||||||
memcpy(&rcFCB->Entry, FileName, FIELD_OFFSET(FILENAME_ATTRIBUTE, NameLength));
|
memcpy(&rcFCB->Entry, FileName, FIELD_OFFSET(FILENAME_ATTRIBUTE, NameLength));
|
||||||
rcFCB->Entry.NameType = FileName->NameType;
|
rcFCB->Entry.NameType = FileName->NameType;
|
||||||
rcFCB->RFCB.FileSize.QuadPart = FileName->DataSize;
|
rcFCB->RFCB.FileSize.QuadPart = Size;
|
||||||
rcFCB->RFCB.ValidDataLength.QuadPart = FileName->DataSize;
|
rcFCB->RFCB.ValidDataLength.QuadPart = Size;
|
||||||
rcFCB->RFCB.AllocationSize.QuadPart = FileName->AllocatedSize;
|
rcFCB->RFCB.AllocationSize.QuadPart = AllocatedSize;
|
||||||
|
|
||||||
StdInfo = GetStandardInformationFromRecord(Record);
|
StdInfo = GetStandardInformationFromRecord(Record);
|
||||||
if (StdInfo != NULL)
|
if (StdInfo != NULL)
|
||||||
|
|
|
@ -550,6 +550,13 @@ NtfsDeviceControl(PNTFS_IRP_CONTEXT IrpContext);
|
||||||
|
|
||||||
/* dirctl.c */
|
/* dirctl.c */
|
||||||
|
|
||||||
|
ULONGLONG
|
||||||
|
NtfsGetFileSize(PDEVICE_EXTENSION DeviceExt,
|
||||||
|
PFILE_RECORD_HEADER FileRecord,
|
||||||
|
PCWSTR Stream,
|
||||||
|
ULONG StreamLength,
|
||||||
|
PULONGLONG AllocatedSize);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NtfsDirectoryControl(PNTFS_IRP_CONTEXT IrpContext);
|
NtfsDirectoryControl(PNTFS_IRP_CONTEXT IrpContext);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue