[NTFS]
authorPierre Schweitzer <pierre@reactos.org>
Thu, 25 Sep 2014 20:15:00 +0000 (20:15 +0000)
committerPierre Schweitzer <pierre@reactos.org>
Thu, 25 Sep 2014 20:15:00 +0000 (20:15 +0000)
- Create the volume FCB and save it in VCB.
- Fix a memory leak

svn path=/trunk/; revision=64288

reactos/drivers/filesystems/ntfs/fsctl.c
reactos/drivers/filesystems/ntfs/ntfs.h

index 8235678..6110741 100644 (file)
@@ -181,6 +181,8 @@ NtfsGetVolumeData(PDEVICE_OBJECT DeviceObject,
     ULONG Size;
     PNTFS_INFO NtfsInfo = &DeviceExt->NtfsInfo;
     NTSTATUS Status;
+    PNTFS_FCB VolumeFcb;
+    PWSTR VolumeNameU;
 
     DPRINT("NtfsGetVolumeData() called\n");
 
@@ -286,6 +288,7 @@ NtfsGetVolumeData(PDEVICE_OBJECT DeviceObject,
                             MftRecord);
     if (!NT_SUCCESS(Status))
     {
+        ExFreePool(VolumeRecord);
         ExFreePool(MftRecord);
         return Status;
     }
@@ -308,12 +311,28 @@ NtfsGetVolumeData(PDEVICE_OBJECT DeviceObject,
         RtlCopyMemory(NtfsInfo->VolumeLabel,
                       (PVOID)((ULONG_PTR)Attribute + ((PRESIDENT_ATTRIBUTE)Attribute)->ValueOffset),
                       NtfsInfo->VolumeLabelLength);
+        VolumeNameU = NtfsInfo->VolumeLabel;
     }
     else
     {
         NtfsInfo->VolumeLabelLength = 0;
+        VolumeNameU = L"\0";
     }
 
+    VolumeFcb = NtfsCreateFCB(VolumeNameU, DeviceExt);
+    if (VolumeFcb == NULL)
+    {
+        ExFreePool(VolumeRecord);
+        ExFreePool(MftRecord);
+        return STATUS_INSUFFICIENT_RESOURCES;
+    }
+
+    VolumeFcb->Flags = FCB_IS_VOLUME;
+    VolumeFcb->RFCB.FileSize.QuadPart = DeviceExt->NtfsInfo.SectorCount * DeviceExt->NtfsInfo.BytesPerSector;
+    VolumeFcb->RFCB.ValidDataLength = VolumeFcb->RFCB.FileSize;
+    VolumeFcb->RFCB.AllocationSize = VolumeFcb->RFCB.FileSize;
+    DeviceExt->VolumeFcb = VolumeFcb;
+
     /* Get volume information */
     Attribute = FindAttribute (VolumeRecord, AttributeVolumeInformation, NULL);
     DPRINT("Attribute %p\n", Attribute);
index c21a0a1..cbdc3f0 100644 (file)
@@ -101,6 +101,8 @@ typedef struct
     PDEVICE_OBJECT StorageDevice;
     PFILE_OBJECT StreamFileObject;
 
+    struct _FCB *VolumeFcb;
+
     NTFS_INFO NtfsInfo;
 
 } DEVICE_EXTENSION, *PDEVICE_EXTENSION, NTFS_VCB, *PNTFS_VCB;