2002-06-25 22:23:06 +00:00
/*
* ReactOS kernel
2014-11-02 21:50:40 +00:00
* Copyright ( C ) 2002 , 2014 ReactOS Team
2002-06-25 22:23:06 +00:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
2008-03-08 21:45:51 +00:00
* Foundation , Inc . , 51 Franklin St , Fifth Floor , Boston , MA 02110 - 1301 , USA .
2002-06-25 22:23:06 +00:00
*
* COPYRIGHT : See COPYING in the top level directory
* PROJECT : ReactOS kernel
2008-02-10 11:20:29 +00:00
* FILE : drivers / filesystem / ntfs / volume . c
2002-06-25 22:23:06 +00:00
* PURPOSE : NTFS filesystem driver
2014-11-02 21:50:40 +00:00
* PROGRAMMERS : Eric Kohl
* Pierre Schweitzer ( pierre @ reactos . org )
2002-06-25 22:23:06 +00:00
*/
/* INCLUDES *****************************************************************/
2006-01-07 06:20:59 +00:00
# include "ntfs.h"
2002-06-25 22:23:06 +00:00
2004-06-05 08:28:37 +00:00
# define NDEBUG
2002-06-25 22:23:06 +00:00
# include <debug.h>
/* FUNCTIONS ****************************************************************/
2014-10-19 17:43:37 +00:00
ULONGLONG
NtfsGetFreeClusters ( PDEVICE_EXTENSION DeviceExt )
{
2014-10-28 19:17:59 +00:00
NTSTATUS Status ;
PFILE_RECORD_HEADER BitmapRecord ;
PNTFS_ATTR_CONTEXT DataContext ;
ULONGLONG BitmapDataSize ;
PCHAR BitmapData ;
ULONGLONG FreeClusters = 0 ;
ULONG Read = 0 ;
RTL_BITMAP Bitmap ;
2019-06-15 16:24:27 +00:00
DPRINT ( " NtfsGetFreeClusters(%p) \n " , DeviceExt ) ;
2014-10-28 19:17:59 +00:00
2017-12-31 13:14:24 +00:00
BitmapRecord = ExAllocateFromNPagedLookasideList ( & DeviceExt - > FileRecLookasideList ) ;
2014-10-28 19:17:59 +00:00
if ( BitmapRecord = = NULL )
{
return 0 ;
}
Status = ReadFileRecord ( DeviceExt , NTFS_FILE_BITMAP , BitmapRecord ) ;
if ( ! NT_SUCCESS ( Status ) )
{
2017-12-31 13:14:24 +00:00
ExFreeToNPagedLookasideList ( & DeviceExt - > FileRecLookasideList , BitmapRecord ) ;
2014-10-28 19:17:59 +00:00
return 0 ;
}
2016-06-22 21:20:50 +00:00
Status = FindAttribute ( DeviceExt , BitmapRecord , AttributeData , L " " , 0 , & DataContext , NULL ) ;
2014-10-28 19:17:59 +00:00
if ( ! NT_SUCCESS ( Status ) )
{
2017-12-31 13:14:24 +00:00
ExFreeToNPagedLookasideList ( & DeviceExt - > FileRecLookasideList , BitmapRecord ) ;
2014-10-28 19:17:59 +00:00
return 0 ;
}
2017-08-06 02:54:15 +00:00
BitmapDataSize = AttributeDataLength ( DataContext - > pRecord ) ;
2014-12-14 14:38:44 +00:00
ASSERT ( ( BitmapDataSize * 8 ) > = DeviceExt - > NtfsInfo . ClusterCount ) ;
2014-11-02 17:53:18 +00:00
BitmapData = ExAllocatePoolWithTag ( NonPagedPool , ROUND_UP ( BitmapDataSize , DeviceExt - > NtfsInfo . BytesPerSector ) , TAG_NTFS ) ;
2014-10-28 19:17:59 +00:00
if ( BitmapData = = NULL )
{
ReleaseAttributeContext ( DataContext ) ;
2017-12-31 13:14:24 +00:00
ExFreeToNPagedLookasideList ( & DeviceExt - > FileRecLookasideList , BitmapRecord ) ;
2014-10-28 19:17:59 +00:00
return 0 ;
}
/* FIXME: Totally underoptimized! */
for ( ; Read < BitmapDataSize ; Read + = DeviceExt - > NtfsInfo . BytesPerSector )
{
ReadAttribute ( DeviceExt , DataContext , Read , ( PCHAR ) ( ( ULONG_PTR ) BitmapData + Read ) , DeviceExt - > NtfsInfo . BytesPerSector ) ;
}
ReleaseAttributeContext ( DataContext ) ;
2014-12-14 14:38:44 +00:00
DPRINT1 ( " Total clusters: %I64x \n " , DeviceExt - > NtfsInfo . ClusterCount ) ;
2014-10-28 19:17:59 +00:00
DPRINT1 ( " Total clusters in bitmap: %I64x \n " , BitmapDataSize * 8 ) ;
2014-12-14 14:38:44 +00:00
DPRINT1 ( " Diff in size: %I64d B \n " , ( ( BitmapDataSize * 8 ) - DeviceExt - > NtfsInfo . ClusterCount ) * DeviceExt - > NtfsInfo . SectorsPerCluster * DeviceExt - > NtfsInfo . BytesPerSector ) ;
2014-10-28 19:17:59 +00:00
2014-12-14 14:38:44 +00:00
RtlInitializeBitMap ( & Bitmap , ( PULONG ) BitmapData , DeviceExt - > NtfsInfo . ClusterCount ) ;
2014-10-28 19:17:59 +00:00
FreeClusters = RtlNumberOfClearBits ( & Bitmap ) ;
ExFreePoolWithTag ( BitmapData , TAG_NTFS ) ;
2017-12-31 13:14:24 +00:00
ExFreeToNPagedLookasideList ( & DeviceExt - > FileRecLookasideList , BitmapRecord ) ;
2014-10-28 19:17:59 +00:00
return FreeClusters ;
2014-10-19 17:43:37 +00:00
}
2021-06-11 12:29:21 +00:00
/**
* NtfsAllocateClusters
2016-06-29 16:35:36 +00:00
* Allocates a run of clusters . The run allocated might be smaller than DesiredClusters .
*/
NTSTATUS
NtfsAllocateClusters ( PDEVICE_EXTENSION DeviceExt ,
ULONG FirstDesiredCluster ,
2021-06-11 12:29:21 +00:00
ULONG DesiredClusters ,
PULONG FirstAssignedCluster ,
2016-06-29 16:35:36 +00:00
PULONG AssignedClusters )
{
NTSTATUS Status ;
PFILE_RECORD_HEADER BitmapRecord ;
PNTFS_ATTR_CONTEXT DataContext ;
ULONGLONG BitmapDataSize ;
2016-07-13 14:49:46 +00:00
PUCHAR BitmapData ;
2016-06-29 16:35:36 +00:00
ULONGLONG FreeClusters = 0 ;
RTL_BITMAP Bitmap ;
2016-07-13 14:49:46 +00:00
ULONG AssignedRun ;
ULONG LengthWritten ;
2016-06-29 16:35:36 +00:00
2019-06-15 16:24:27 +00:00
DPRINT ( " NtfsAllocateClusters(%p, %lu, %lu, %p, %p) \n " , DeviceExt , FirstDesiredCluster , DesiredClusters , FirstAssignedCluster , AssignedClusters ) ;
2016-06-29 16:35:36 +00:00
2017-12-31 13:14:24 +00:00
BitmapRecord = ExAllocateFromNPagedLookasideList ( & DeviceExt - > FileRecLookasideList ) ;
2016-06-29 16:35:36 +00:00
if ( BitmapRecord = = NULL )
{
2017-05-13 08:56:54 +00:00
return STATUS_INSUFFICIENT_RESOURCES ;
2016-06-29 16:35:36 +00:00
}
Status = ReadFileRecord ( DeviceExt , NTFS_FILE_BITMAP , BitmapRecord ) ;
if ( ! NT_SUCCESS ( Status ) )
{
2017-12-31 13:14:24 +00:00
ExFreeToNPagedLookasideList ( & DeviceExt - > FileRecLookasideList , BitmapRecord ) ;
2017-05-13 08:56:54 +00:00
return Status ;
2016-06-29 16:35:36 +00:00
}
Status = FindAttribute ( DeviceExt , BitmapRecord , AttributeData , L " " , 0 , & DataContext , NULL ) ;
if ( ! NT_SUCCESS ( Status ) )
{
2017-12-31 13:14:24 +00:00
ExFreeToNPagedLookasideList ( & DeviceExt - > FileRecLookasideList , BitmapRecord ) ;
2017-05-13 08:56:54 +00:00
return Status ;
2016-06-29 16:35:36 +00:00
}
2017-08-06 02:54:15 +00:00
BitmapDataSize = AttributeDataLength ( DataContext - > pRecord ) ;
2016-06-29 16:35:36 +00:00
BitmapDataSize = min ( BitmapDataSize , 0xffffffff ) ;
ASSERT ( ( BitmapDataSize * 8 ) > = DeviceExt - > NtfsInfo . ClusterCount ) ;
BitmapData = ExAllocatePoolWithTag ( NonPagedPool , ROUND_UP ( BitmapDataSize , DeviceExt - > NtfsInfo . BytesPerSector ) , TAG_NTFS ) ;
if ( BitmapData = = NULL )
{
ReleaseAttributeContext ( DataContext ) ;
2017-12-31 13:14:24 +00:00
ExFreeToNPagedLookasideList ( & DeviceExt - > FileRecLookasideList , BitmapRecord ) ;
2017-05-13 08:56:54 +00:00
return STATUS_INSUFFICIENT_RESOURCES ;
2016-06-29 16:35:36 +00:00
}
2019-06-15 16:24:27 +00:00
DPRINT ( " Total clusters: %I64x \n " , DeviceExt - > NtfsInfo . ClusterCount ) ;
DPRINT ( " Total clusters in bitmap: %I64x \n " , BitmapDataSize * 8 ) ;
DPRINT ( " Diff in size: %I64d B \n " , ( ( BitmapDataSize * 8 ) - DeviceExt - > NtfsInfo . ClusterCount ) * DeviceExt - > NtfsInfo . SectorsPerCluster * DeviceExt - > NtfsInfo . BytesPerSector ) ;
2016-06-29 16:35:36 +00:00
2016-07-05 07:00:43 +00:00
ReadAttribute ( DeviceExt , DataContext , 0 , ( PCHAR ) BitmapData , ( ULONG ) BitmapDataSize ) ;
2016-06-29 16:35:36 +00:00
RtlInitializeBitMap ( & Bitmap , ( PULONG ) BitmapData , DeviceExt - > NtfsInfo . ClusterCount ) ;
FreeClusters = RtlNumberOfClearBits ( & Bitmap ) ;
2016-07-08 12:05:19 +00:00
if ( FreeClusters < DesiredClusters )
{
ReleaseAttributeContext ( DataContext ) ;
ExFreePoolWithTag ( BitmapData , TAG_NTFS ) ;
2017-12-31 13:14:24 +00:00
ExFreeToNPagedLookasideList ( & DeviceExt - > FileRecLookasideList , BitmapRecord ) ;
2016-07-08 12:05:19 +00:00
return STATUS_DISK_FULL ;
}
2021-06-11 12:29:21 +00:00
2016-07-08 11:59:25 +00:00
// TODO: Observe MFT reservation zone
2016-06-29 16:35:36 +00:00
2016-07-08 11:59:25 +00:00
// Can we get one contiguous run?
2016-07-13 14:49:46 +00:00
AssignedRun = RtlFindClearBitsAndSet ( & Bitmap , DesiredClusters , FirstDesiredCluster ) ;
2016-06-29 16:35:36 +00:00
2016-07-08 11:59:25 +00:00
if ( AssignedRun ! = 0xFFFFFFFF )
{
* FirstAssignedCluster = AssignedRun ;
* AssignedClusters = DesiredClusters ;
}
else
{
// we can't get one contiguous run
* AssignedClusters = RtlFindNextForwardRunClear ( & Bitmap , FirstDesiredCluster , FirstAssignedCluster ) ;
2021-06-11 12:29:21 +00:00
2016-07-08 11:59:25 +00:00
if ( * AssignedClusters = = 0 )
2016-06-29 16:35:36 +00:00
{
2016-07-08 11:59:25 +00:00
// we couldn't find any runs starting at DesiredFirstCluster
* AssignedClusters = RtlFindLongestRunClear ( & Bitmap , FirstAssignedCluster ) ;
2016-06-29 16:35:36 +00:00
}
2021-06-11 12:29:21 +00:00
2016-06-29 16:35:36 +00:00
}
2021-06-11 12:29:21 +00:00
2017-08-15 19:32:20 +00:00
Status = WriteAttribute ( DeviceExt , DataContext , 0 , BitmapData , ( ULONG ) BitmapDataSize , & LengthWritten , BitmapRecord ) ;
2021-06-11 12:29:21 +00:00
2016-06-29 16:35:36 +00:00
ReleaseAttributeContext ( DataContext ) ;
ExFreePoolWithTag ( BitmapData , TAG_NTFS ) ;
2017-12-31 13:14:24 +00:00
ExFreeToNPagedLookasideList ( & DeviceExt - > FileRecLookasideList , BitmapRecord ) ;
2016-06-29 16:35:36 +00:00
return Status ;
}
2013-06-16 12:15:06 +00:00
static
NTSTATUS
2002-06-25 22:23:06 +00:00
NtfsGetFsVolumeInformation ( PDEVICE_OBJECT DeviceObject ,
2008-01-02 11:04:48 +00:00
PFILE_FS_VOLUME_INFORMATION FsVolumeInfo ,
PULONG BufferLength )
2002-06-25 22:23:06 +00:00
{
2013-06-16 12:15:06 +00:00
DPRINT ( " NtfsGetFsVolumeInformation() called \n " ) ;
DPRINT ( " FsVolumeInfo = %p \n " , FsVolumeInfo ) ;
DPRINT ( " BufferLength %lu \n " , * BufferLength ) ;
2002-06-25 22:23:06 +00:00
2013-06-16 12:15:06 +00:00
DPRINT ( " Vpb %p \n " , DeviceObject - > Vpb ) ;
2002-06-25 22:23:06 +00:00
2013-06-16 12:15:06 +00:00
DPRINT ( " Required length %lu \n " ,
sizeof ( FILE_FS_VOLUME_INFORMATION ) + DeviceObject - > Vpb - > VolumeLabelLength ) ;
DPRINT ( " LabelLength %hu \n " ,
DeviceObject - > Vpb - > VolumeLabelLength ) ;
2017-06-20 00:45:07 +00:00
DPRINT ( " Label %.*S \n " ,
2013-06-16 12:15:06 +00:00
DeviceObject - > Vpb - > VolumeLabelLength / sizeof ( WCHAR ) ,
DeviceObject - > Vpb - > VolumeLabel ) ;
2002-06-25 22:23:06 +00:00
2013-06-16 12:15:06 +00:00
if ( * BufferLength < sizeof ( FILE_FS_VOLUME_INFORMATION ) )
return STATUS_INFO_LENGTH_MISMATCH ;
2002-06-25 22:23:06 +00:00
2013-06-16 12:15:06 +00:00
if ( * BufferLength < ( sizeof ( FILE_FS_VOLUME_INFORMATION ) + DeviceObject - > Vpb - > VolumeLabelLength ) )
return STATUS_BUFFER_OVERFLOW ;
2002-06-25 22:23:06 +00:00
2013-06-16 12:15:06 +00:00
/* valid entries */
FsVolumeInfo - > VolumeSerialNumber = DeviceObject - > Vpb - > SerialNumber ;
FsVolumeInfo - > VolumeLabelLength = DeviceObject - > Vpb - > VolumeLabelLength ;
memcpy ( FsVolumeInfo - > VolumeLabel ,
DeviceObject - > Vpb - > VolumeLabel ,
DeviceObject - > Vpb - > VolumeLabelLength ) ;
2002-06-25 22:23:06 +00:00
2013-06-16 12:15:06 +00:00
/* dummy entries */
FsVolumeInfo - > VolumeCreationTime . QuadPart = 0 ;
FsVolumeInfo - > SupportsObjects = FALSE ;
2002-06-25 22:23:06 +00:00
2013-06-16 12:15:06 +00:00
* BufferLength - = ( sizeof ( FILE_FS_VOLUME_INFORMATION ) + DeviceObject - > Vpb - > VolumeLabelLength ) ;
2002-06-25 22:23:06 +00:00
2013-06-16 12:15:06 +00:00
DPRINT ( " BufferLength %lu \n " , * BufferLength ) ;
DPRINT ( " NtfsGetFsVolumeInformation() done \n " ) ;
2002-06-25 22:23:06 +00:00
2013-06-16 12:15:06 +00:00
return STATUS_SUCCESS ;
2002-06-25 22:23:06 +00:00
}
2013-06-16 12:15:06 +00:00
static
NTSTATUS
2002-06-25 22:23:06 +00:00
NtfsGetFsAttributeInformation ( PDEVICE_EXTENSION DeviceExt ,
2008-01-02 11:04:48 +00:00
PFILE_FS_ATTRIBUTE_INFORMATION FsAttributeInfo ,
PULONG BufferLength )
2002-06-25 22:23:06 +00:00
{
2013-07-24 15:24:41 +00:00
UNREFERENCED_PARAMETER ( DeviceExt ) ;
2013-06-16 12:15:06 +00:00
DPRINT ( " NtfsGetFsAttributeInformation() \n " ) ;
DPRINT ( " FsAttributeInfo = %p \n " , FsAttributeInfo ) ;
DPRINT ( " BufferLength %lu \n " , * BufferLength ) ;
DPRINT ( " Required length %lu \n " , ( sizeof ( FILE_FS_ATTRIBUTE_INFORMATION ) + 8 ) ) ;
2002-06-25 22:23:06 +00:00
2013-06-16 12:15:06 +00:00
if ( * BufferLength < sizeof ( FILE_FS_ATTRIBUTE_INFORMATION ) )
return STATUS_INFO_LENGTH_MISMATCH ;
2002-06-25 22:23:06 +00:00
2013-06-16 12:15:06 +00:00
if ( * BufferLength < ( sizeof ( FILE_FS_ATTRIBUTE_INFORMATION ) + 8 ) )
return STATUS_BUFFER_OVERFLOW ;
2002-06-25 22:23:06 +00:00
2013-06-16 12:15:06 +00:00
FsAttributeInfo - > FileSystemAttributes =
2015-05-31 21:31:14 +00:00
FILE_CASE_PRESERVED_NAMES | FILE_UNICODE_ON_DISK | FILE_READ_ONLY_VOLUME ;
2013-06-16 12:15:06 +00:00
FsAttributeInfo - > MaximumComponentNameLength = 255 ;
FsAttributeInfo - > FileSystemNameLength = 8 ;
2002-06-25 22:23:06 +00:00
2013-06-16 12:15:06 +00:00
memcpy ( FsAttributeInfo - > FileSystemName , L " NTFS " , 8 ) ;
2002-06-25 22:23:06 +00:00
2013-06-16 12:15:06 +00:00
DPRINT ( " Finished NtfsGetFsAttributeInformation() \n " ) ;
2002-06-25 22:23:06 +00:00
2013-06-16 12:15:06 +00:00
* BufferLength - = ( sizeof ( FILE_FS_ATTRIBUTE_INFORMATION ) + 8 ) ;
DPRINT ( " BufferLength %lu \n " , * BufferLength ) ;
2002-06-25 22:23:06 +00:00
2013-06-16 12:15:06 +00:00
return STATUS_SUCCESS ;
2002-06-25 22:23:06 +00:00
}
2013-06-16 12:15:06 +00:00
static
NTSTATUS
2002-06-25 22:23:06 +00:00
NtfsGetFsSizeInformation ( PDEVICE_OBJECT DeviceObject ,
2008-01-02 11:04:48 +00:00
PFILE_FS_SIZE_INFORMATION FsSizeInfo ,
PULONG BufferLength )
2002-06-25 22:23:06 +00:00
{
2013-06-16 12:15:06 +00:00
PDEVICE_EXTENSION DeviceExt ;
NTSTATUS Status = STATUS_SUCCESS ;
2002-06-25 22:23:06 +00:00
2013-06-16 12:15:06 +00:00
DPRINT ( " NtfsGetFsSizeInformation() \n " ) ;
DPRINT ( " FsSizeInfo = %p \n " , FsSizeInfo ) ;
2002-06-25 22:23:06 +00:00
2013-06-16 12:15:06 +00:00
if ( * BufferLength < sizeof ( FILE_FS_SIZE_INFORMATION ) )
return STATUS_BUFFER_OVERFLOW ;
2002-06-25 22:23:06 +00:00
2013-06-16 12:15:06 +00:00
DeviceExt = DeviceObject - > DeviceExtension ;
2002-06-25 22:23:06 +00:00
2014-10-19 17:43:37 +00:00
FsSizeInfo - > AvailableAllocationUnits . QuadPart = NtfsGetFreeClusters ( DeviceExt ) ;
2014-12-14 14:38:44 +00:00
FsSizeInfo - > TotalAllocationUnits . QuadPart = DeviceExt - > NtfsInfo . ClusterCount ;
2013-06-16 12:15:06 +00:00
FsSizeInfo - > SectorsPerAllocationUnit = DeviceExt - > NtfsInfo . SectorsPerCluster ;
FsSizeInfo - > BytesPerSector = DeviceExt - > NtfsInfo . BytesPerSector ;
2002-06-25 22:23:06 +00:00
2013-06-16 12:15:06 +00:00
DPRINT ( " Finished NtfsGetFsSizeInformation() \n " ) ;
if ( NT_SUCCESS ( Status ) )
* BufferLength - = sizeof ( FILE_FS_SIZE_INFORMATION ) ;
2002-06-25 22:23:06 +00:00
2013-06-16 12:15:06 +00:00
return Status ;
2002-06-25 22:23:06 +00:00
}
2013-06-16 12:15:06 +00:00
static
NTSTATUS
2014-10-19 17:43:37 +00:00
NtfsGetFsDeviceInformation ( PDEVICE_OBJECT DeviceObject ,
PFILE_FS_DEVICE_INFORMATION FsDeviceInfo ,
2008-01-02 11:04:48 +00:00
PULONG BufferLength )
2002-06-25 22:23:06 +00:00
{
2013-06-16 12:15:06 +00:00
DPRINT ( " NtfsGetFsDeviceInformation() \n " ) ;
DPRINT ( " FsDeviceInfo = %p \n " , FsDeviceInfo ) ;
DPRINT ( " BufferLength %lu \n " , * BufferLength ) ;
DPRINT ( " Required length %lu \n " , sizeof ( FILE_FS_DEVICE_INFORMATION ) ) ;
2002-06-25 22:23:06 +00:00
2013-06-16 12:15:06 +00:00
if ( * BufferLength < sizeof ( FILE_FS_DEVICE_INFORMATION ) )
return STATUS_BUFFER_OVERFLOW ;
2002-06-25 22:23:06 +00:00
2013-06-16 12:15:06 +00:00
FsDeviceInfo - > DeviceType = FILE_DEVICE_DISK ;
2014-10-19 17:43:37 +00:00
FsDeviceInfo - > Characteristics = DeviceObject - > Characteristics ;
2002-06-25 22:23:06 +00:00
2013-06-16 12:15:06 +00:00
DPRINT ( " NtfsGetFsDeviceInformation() finished. \n " ) ;
2002-06-25 22:23:06 +00:00
2013-06-16 12:15:06 +00:00
* BufferLength - = sizeof ( FILE_FS_DEVICE_INFORMATION ) ;
DPRINT ( " BufferLength %lu \n " , * BufferLength ) ;
2002-06-25 22:23:06 +00:00
2013-06-16 12:15:06 +00:00
return STATUS_SUCCESS ;
2002-06-25 22:23:06 +00:00
}
2008-02-10 11:20:29 +00:00
NTSTATUS
NtfsQueryVolumeInformation ( PNTFS_IRP_CONTEXT IrpContext )
2002-06-25 22:23:06 +00:00
{
2013-06-16 12:15:06 +00:00
PIRP Irp ;
PDEVICE_OBJECT DeviceObject ;
FS_INFORMATION_CLASS FsInformationClass ;
PIO_STACK_LOCATION Stack ;
NTSTATUS Status = STATUS_SUCCESS ;
PVOID SystemBuffer ;
ULONG BufferLength ;
2016-02-23 22:19:38 +00:00
PDEVICE_EXTENSION DeviceExt ;
2013-06-16 12:15:06 +00:00
DPRINT ( " NtfsQueryVolumeInformation() called \n " ) ;
ASSERT ( IrpContext ) ;
Irp = IrpContext - > Irp ;
DeviceObject = IrpContext - > DeviceObject ;
2016-02-23 22:19:38 +00:00
DeviceExt = DeviceObject - > DeviceExtension ;
2015-05-03 18:36:58 +00:00
Stack = IrpContext - > Stack ;
2016-02-23 22:19:38 +00:00
if ( ! ExAcquireResourceSharedLite ( & DeviceExt - > DirResource ,
BooleanFlagOn ( IrpContext - > Flags , IRPCONTEXT_CANWAIT ) ) )
{
return NtfsMarkIrpContextForQueue ( IrpContext ) ;
}
2013-06-16 12:15:06 +00:00
FsInformationClass = Stack - > Parameters . QueryVolume . FsInformationClass ;
BufferLength = Stack - > Parameters . QueryVolume . Length ;
SystemBuffer = Irp - > AssociatedIrp . SystemBuffer ;
RtlZeroMemory ( SystemBuffer , BufferLength ) ;
DPRINT ( " FsInformationClass %d \n " , FsInformationClass ) ;
DPRINT ( " SystemBuffer %p \n " , SystemBuffer ) ;
switch ( FsInformationClass )
{
case FileFsVolumeInformation :
Status = NtfsGetFsVolumeInformation ( DeviceObject ,
SystemBuffer ,
& BufferLength ) ;
break ;
case FileFsAttributeInformation :
Status = NtfsGetFsAttributeInformation ( DeviceObject - > DeviceExtension ,
SystemBuffer ,
& BufferLength ) ;
break ;
case FileFsSizeInformation :
Status = NtfsGetFsSizeInformation ( DeviceObject ,
SystemBuffer ,
& BufferLength ) ;
break ;
case FileFsDeviceInformation :
2014-10-19 17:43:37 +00:00
Status = NtfsGetFsDeviceInformation ( DeviceObject ,
SystemBuffer ,
2013-06-16 12:15:06 +00:00
& BufferLength ) ;
break ;
default :
Status = STATUS_NOT_SUPPORTED ;
}
2016-02-23 22:19:38 +00:00
ExReleaseResourceLite ( & DeviceExt - > DirResource ) ;
2013-06-16 12:15:06 +00:00
if ( NT_SUCCESS ( Status ) )
Irp - > IoStatus . Information =
Stack - > Parameters . QueryVolume . Length - BufferLength ;
else
Irp - > IoStatus . Information = 0 ;
return Status ;
2002-06-25 22:23:06 +00:00
}
2008-02-10 11:20:29 +00:00
NTSTATUS
NtfsSetVolumeInformation ( PNTFS_IRP_CONTEXT IrpContext )
2002-06-25 22:23:06 +00:00
{
2013-06-16 12:15:06 +00:00
PIRP Irp ;
2002-06-25 22:23:06 +00:00
2013-06-16 12:15:06 +00:00
DPRINT ( " NtfsSetVolumeInformation() called \n " ) ;
2008-02-10 11:20:29 +00:00
2013-06-16 12:15:06 +00:00
ASSERT ( IrpContext ) ;
Irp = IrpContext - > Irp ;
Irp - > IoStatus . Status = STATUS_NOT_SUPPORTED ;
Irp - > IoStatus . Information = 0 ;
2002-06-25 22:23:06 +00:00
2013-06-16 12:15:06 +00:00
return STATUS_NOT_SUPPORTED ;
2002-06-25 22:23:06 +00:00
}
/* EOF */