Fixed some NT compatibility issues in Nt[Query/Set]VolumeInformationFile().

svn path=/trunk/; revision=1956
This commit is contained in:
Eric Kohl 2001-06-11 19:52:22 +00:00
parent 80f8038f24
commit bf1b360a1e
7 changed files with 311 additions and 225 deletions

View file

@ -1,4 +1,4 @@
/* $Id: iface.c,v 1.52 2001/05/04 01:21:45 rex Exp $ /* $Id: iface.c,v 1.53 2001/06/11 19:52:22 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -283,7 +283,8 @@ VfatFileSystemControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
NTSTATUS STDCALL NTSTATUS STDCALL
DriverEntry (PDRIVER_OBJECT _DriverObject, PUNICODE_STRING RegistryPath) DriverEntry(PDRIVER_OBJECT _DriverObject,
PUNICODE_STRING RegistryPath)
/* /*
* FUNCTION: Called by the system to initalize the driver * FUNCTION: Called by the system to initalize the driver
* ARGUMENTS: * ARGUMENTS:
@ -329,6 +330,8 @@ DriverEntry (PDRIVER_OBJECT _DriverObject, PUNICODE_STRING RegistryPath)
VfatDirectoryControl; VfatDirectoryControl;
VfatDriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] = VfatDriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] =
VfatQueryVolumeInformation; VfatQueryVolumeInformation;
VfatDriverObject->MajorFunction[IRP_MJ_SET_VOLUME_INFORMATION] =
VfatSetVolumeInformation;
VfatDriverObject->MajorFunction[IRP_MJ_SHUTDOWN] = VfatShutdown; VfatDriverObject->MajorFunction[IRP_MJ_SHUTDOWN] = VfatShutdown;
VfatDriverObject->MajorFunction[IRP_MJ_CLEANUP] = VfatCleanup; VfatDriverObject->MajorFunction[IRP_MJ_CLEANUP] = VfatCleanup;

View file

@ -1,4 +1,4 @@
/* $Id: vfat.h,v 1.29 2001/05/10 04:02:21 rex Exp $ */ /* $Id: vfat.h,v 1.30 2001/06/11 19:52:22 ekohl Exp $ */
#include <ddk/ntifs.h> #include <ddk/ntifs.h>
@ -162,6 +162,8 @@ NTSTATUS STDCALL
VfatShutdown(PDEVICE_OBJECT DeviceObject, PIRP Irp); VfatShutdown(PDEVICE_OBJECT DeviceObject, PIRP Irp);
NTSTATUS STDCALL NTSTATUS STDCALL
VfatQueryVolumeInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp); VfatQueryVolumeInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp);
NTSTATUS STDCALL
VfatSetVolumeInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp);
NTSTATUS NTSTATUS

View file

@ -1,4 +1,4 @@
/* $Id: volume.c,v 1.7 2001/03/01 07:48:17 dwelch Exp $ /* $Id: volume.c,v 1.8 2001/06/11 19:52:22 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -19,14 +19,14 @@
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
NTSTATUS static NTSTATUS
FsdGetFsVolumeInformation (PFILE_OBJECT FileObject, FsdGetFsVolumeInformation(PFILE_OBJECT FileObject,
PVFATFCB FCB, PVFATFCB FCB,
PDEVICE_OBJECT DeviceObject, PDEVICE_OBJECT DeviceObject,
PFILE_FS_VOLUME_INFORMATION FsVolumeInfo) PFILE_FS_VOLUME_INFORMATION FsVolumeInfo)
{ {
DPRINT ("FsdGetFsVolumeInformation()\n"); DPRINT("FsdGetFsVolumeInformation()\n");
DPRINT ("FsVolumeInfo = %p\n", FsVolumeInfo); DPRINT("FsVolumeInfo = %p\n", FsVolumeInfo);
if (!FsVolumeInfo) if (!FsVolumeInfo)
return (STATUS_SUCCESS); return (STATUS_SUCCESS);
@ -35,48 +35,49 @@ FsdGetFsVolumeInformation (PFILE_OBJECT FileObject,
/* valid entries */ /* valid entries */
FsVolumeInfo->VolumeSerialNumber = DeviceObject->Vpb->SerialNumber; FsVolumeInfo->VolumeSerialNumber = DeviceObject->Vpb->SerialNumber;
FsVolumeInfo->VolumeLabelLength = DeviceObject->Vpb->VolumeLabelLength; FsVolumeInfo->VolumeLabelLength = DeviceObject->Vpb->VolumeLabelLength;
wcscpy (FsVolumeInfo->VolumeLabel, DeviceObject->Vpb->VolumeLabel); wcscpy(FsVolumeInfo->VolumeLabel, DeviceObject->Vpb->VolumeLabel);
/* dummy entries */ /* dummy entries */
FsVolumeInfo->VolumeCreationTime.QuadPart = 0; FsVolumeInfo->VolumeCreationTime.QuadPart = 0;
FsVolumeInfo->SupportsObjects = FALSE; FsVolumeInfo->SupportsObjects = FALSE;
DPRINT ("Finished FsdGetFsVolumeInformation()\n"); DPRINT("Finished FsdGetFsVolumeInformation()\n");
return (STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
NTSTATUS static NTSTATUS
FsdGetFsAttributeInformation (PFILE_FS_ATTRIBUTE_INFORMATION FsAttributeInfo) FsdGetFsAttributeInformation(PFILE_FS_ATTRIBUTE_INFORMATION FsAttributeInfo)
{ {
DPRINT ("FsdGetFsAttributeInformation()\n"); DPRINT("FsdGetFsAttributeInformation()\n");
DPRINT ("FsAttributeInfo = %p\n", FsAttributeInfo); DPRINT("FsAttributeInfo = %p\n", FsAttributeInfo);
if (!FsAttributeInfo) if (!FsAttributeInfo)
return (STATUS_SUCCESS); return (STATUS_SUCCESS);
FsAttributeInfo->FileSystemAttributes = FS_CASE_IS_PRESERVED; FsAttributeInfo->FileSystemAttributes =
FILE_CASE_PRESERVED_NAMES || FILE_UNICODE_ON_DISK;
FsAttributeInfo->MaximumComponentNameLength = 255; FsAttributeInfo->MaximumComponentNameLength = 255;
FsAttributeInfo->FileSystemNameLength = 3; FsAttributeInfo->FileSystemNameLength = 6;
wcscpy (FsAttributeInfo->FileSystemName, L"FAT"); wcscpy(FsAttributeInfo->FileSystemName, L"FAT");
DPRINT ("Finished FsdGetFsAttributeInformation()\n"); DPRINT("Finished FsdGetFsAttributeInformation()\n");
return (STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
NTSTATUS static NTSTATUS
FsdGetFsSizeInformation (PDEVICE_OBJECT DeviceObject, FsdGetFsSizeInformation(PDEVICE_OBJECT DeviceObject,
PFILE_FS_SIZE_INFORMATION FsSizeInfo) PFILE_FS_SIZE_INFORMATION FsSizeInfo)
{ {
PDEVICE_EXTENSION DeviceExt = DeviceObject->DeviceExtension; PDEVICE_EXTENSION DeviceExt = DeviceObject->DeviceExtension;
DPRINT ("FsdGetFsSizeInformation()\n"); DPRINT("FsdGetFsSizeInformation()\n");
DPRINT ("FsSizeInfo = %p\n", FsSizeInfo); DPRINT("FsSizeInfo = %p\n", FsSizeInfo);
if (!FsSizeInfo) if (!FsSizeInfo)
return (STATUS_SUCCESS); return(STATUS_SUCCESS);
if (DeviceExt->FatType == FAT32) if (DeviceExt->FatType == FAT32)
{ {
@ -112,62 +113,70 @@ FsdGetFsSizeInformation (PDEVICE_OBJECT DeviceObject,
FsSizeInfo->BytesPerSector = BootSect->BytesPerSector; FsSizeInfo->BytesPerSector = BootSect->BytesPerSector;
} }
DPRINT ("Finished FsdGetFsSizeInformation()\n"); DPRINT("Finished FsdGetFsSizeInformation()\n");
return (STATUS_SUCCESS); return(STATUS_SUCCESS);
}
static NTSTATUS
FsdSetFsLabelInformation(PDEVICE_OBJECT DeviceObject,
PFILE_FS_LABEL_INFORMATION FsLabelInfo)
{
DPRINT1("FsdSetFsLabelInformation()\n");
return STATUS_NOT_IMPLEMENTED;
} }
NTSTATUS STDCALL NTSTATUS STDCALL
VfatQueryVolumeInformation (PDEVICE_OBJECT DeviceObject, PIRP Irp) VfatQueryVolumeInformation(PDEVICE_OBJECT DeviceObject,
PIRP Irp)
/* /*
* FUNCTION: Retrieve the specified file information * FUNCTION: Retrieve the specified volume information
*/ */
{ {
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation (Irp); PIO_STACK_LOCATION Stack;
FILE_INFORMATION_CLASS FileInformationClass = FS_INFORMATION_CLASS FsInformationClass;
Stack->Parameters.QueryVolume.FileInformationClass;
PFILE_OBJECT FileObject = NULL; PFILE_OBJECT FileObject = NULL;
PVFATFCB FCB = NULL; PVFATFCB FCB = NULL;
// PVfatCCB CCB = NULL;
NTSTATUS RC = STATUS_SUCCESS; NTSTATUS RC = STATUS_SUCCESS;
void *SystemBuffer; PVOID SystemBuffer;
ULONG BufferLength;
/* PRECONDITION */ /* PRECONDITION */
assert (DeviceObject != NULL); assert(DeviceObject != NULL);
assert (Irp != NULL); assert(Irp != NULL);
DPRINT ("FsdQueryVolumeInformation(DeviceObject %x, Irp %x)\n", DPRINT("FsdQueryVolumeInformation(DeviceObject %x, Irp %x)\n",
DeviceObject, Irp); DeviceObject, Irp);
/* INITIALIZATION */ /* INITIALIZATION */
Stack = IoGetCurrentIrpStackLocation (Irp); Stack = IoGetCurrentIrpStackLocation (Irp);
FileInformationClass = Stack->Parameters.QueryVolume.FileInformationClass; FsInformationClass = Stack->Parameters.QueryVolume.FsInformationClass;
BufferLength = Stack->Parameters.QueryVolume.Length;
SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
FileObject = Stack->FileObject; FileObject = Stack->FileObject;
// CCB = (PVfatCCB)(FileObject->FsContext2); // CCB = (PVfatCCB)(FileObject->FsContext2);
// FCB = CCB->Buffer; // Should be CCB->FCB??? // FCB = CCB->Buffer; // Should be CCB->FCB???
FCB = ((PVFATCCB) (FileObject->FsContext2))->pFcb; FCB = ((PVFATCCB) (FileObject->FsContext2))->pFcb;
// FIXME : determine Buffer for result :
if (Irp->MdlAddress)
SystemBuffer = MmGetSystemAddressForMdl (Irp->MdlAddress);
else
SystemBuffer = Irp->UserBuffer;
// SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
DPRINT ("FileInformationClass %d\n", FileInformationClass); DPRINT ("FsInformationClass %d\n", FsInformationClass);
DPRINT ("SystemBuffer %x\n", SystemBuffer); DPRINT ("SystemBuffer %x\n", SystemBuffer);
switch (FileInformationClass) switch (FsInformationClass)
{ {
case FileFsVolumeInformation: case FileFsVolumeInformation:
RC = FsdGetFsVolumeInformation (FileObject, RC = FsdGetFsVolumeInformation(FileObject,
FCB, DeviceObject, SystemBuffer); FCB,
DeviceObject,
SystemBuffer);
break; break;
case FileFsAttributeInformation: case FileFsAttributeInformation:
RC = FsdGetFsAttributeInformation (SystemBuffer); RC = FsdGetFsAttributeInformation(SystemBuffer);
break; break;
case FileFsSizeInformation: case FileFsSizeInformation:
@ -184,3 +193,60 @@ VfatQueryVolumeInformation (PDEVICE_OBJECT DeviceObject, PIRP Irp)
return RC; return RC;
} }
NTSTATUS STDCALL
VfatSetVolumeInformation(PDEVICE_OBJECT DeviceObject,
PIRP Irp)
/*
* FUNCTION: Set the specified volume information
*/
{
PIO_STACK_LOCATION Stack;
FS_INFORMATION_CLASS FsInformationClass;
// PFILE_OBJECT FileObject = NULL;
// PVFATFCB FCB = NULL;
NTSTATUS Status = STATUS_SUCCESS;
PVOID SystemBuffer;
ULONG BufferLength;
/* PRECONDITION */
assert(DeviceObject != NULL);
assert(Irp != NULL);
DPRINT("FsdSetVolumeInformation(DeviceObject %x, Irp %x)\n",
DeviceObject,
Irp);
Stack = IoGetCurrentIrpStackLocation (Irp);
FsInformationClass = Stack->Parameters.SetVolume.FsInformationClass;
BufferLength = Stack->Parameters.SetVolume.Length;
SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
// FileObject = Stack->FileObject;
// FCB = ((PVFATCCB) (FileObject->FsContext2))->pFcb;
DPRINT("FsInformationClass %d\n", FsInformationClass);
DPRINT("BufferLength %d\n", BufferLength);
DPRINT("SystemBuffer %x\n", SystemBuffer);
switch (FsInformationClass)
{
case FileFsLabelInformation:
Status = FsdSetFsLabelInformation(DeviceObject,
SystemBuffer);
break;
default:
Status = STATUS_NOT_SUPPORTED;
}
Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp,
IO_NO_INCREMENT);
return(Status);
}
/* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: iotypes.h,v 1.29 2001/05/24 22:18:16 ekohl Exp $ /* $Id: iotypes.h,v 1.30 2001/06/11 19:45:29 ekohl Exp $
* *
*/ */
@ -308,12 +308,12 @@ typedef struct _IO_STACK_LOCATION
struct struct
{ {
ULONG Length; ULONG Length;
FS_INFORMATION_CLASS FileInformationClass; FS_INFORMATION_CLASS FsInformationClass;
} QueryVolume; } QueryVolume;
struct struct
{ {
ULONG Length; ULONG Length;
FS_INFORMATION_CLASS FileInformationClass; FS_INFORMATION_CLASS FsInformationClass;
} SetVolume; } SetVolume;
struct struct
{ {
@ -338,21 +338,6 @@ typedef struct _IO_STACK_LOCATION
FILE_INFORMATION_CLASS FileInformationClass; FILE_INFORMATION_CLASS FileInformationClass;
ULONG FileIndex; ULONG FileIndex;
} QueryDirectory; } QueryDirectory;
/*
struct
{
ULONG CreateDisposition;
ULONG CreateOptions;
ULONG ShareAccess;
BOOLEAN WriteModeMessage;
BOOLEAN ReadModeMessage;
BOOLEAN NonBlocking;
ULONG MaxInstances;
ULONG InBufferSize;
ULONG OutBufferSize;
LARGE_INTEGER TimeOut;
} CreateNamedPipe;
*/
// Parameters for IRP_MN_QUERY_DEVICE_RELATIONS // Parameters for IRP_MN_QUERY_DEVICE_RELATIONS
struct { struct {

View file

@ -1,5 +1,5 @@
/* $Id: zw.h,v 1.45 2001/05/27 11:09:35 ekohl Exp $ /* $Id: zw.h,v 1.46 2001/06/11 19:45:29 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -3532,11 +3532,12 @@ ZwQueryVirtualMemory(
/* /*
* FUNCTION: Queries the volume information * FUNCTION: Queries the volume information
* ARGUMENTS: * ARGUMENTS:
* FileHandle = Handle to a file object on the target volume * FileHandle = Handle to a file object on the target volume
ReturnLength = DataWritten * IoStatusBlock = Caller should supply storage for additional status information
FsInformation = Caller should supply storage for the information structure. * ReturnLength = DataWritten
Length = Size of the information structure * FsInformation = Caller should supply storage for the information structure.
FsInformationClass = Index to a information structure * Length = Size of the information structure
* FsInformationClass = Index to a information structure
FileFsVolumeInformation FILE_FS_VOLUME_INFORMATION FileFsVolumeInformation FILE_FS_VOLUME_INFORMATION
FileFsLabelInformation FILE_FS_LABEL_INFORMATION FileFsLabelInformation FILE_FS_LABEL_INFORMATION
@ -4625,30 +4626,33 @@ ZwSetValueKey(
); );
/* /*
* FUNCTION: Sets the volume information of a file. * FUNCTION: Sets the volume information.
* ARGUMENTS: * ARGUMENTS:
* FileHandle = Handle to the file * FileHandle = Handle to the file
* VolumeInformationClass = specifies the particular volume information to set * IoStatusBlock = Caller should supply storage for additional status information
* VolumeInformation = pointer to a structure containing the new volume information * VolumeInformation = pointer to a structure containing the new volume information
* Length = size of the structure. * Length = size of the structure.
* VolumeInformationClass = specifies the particular volume information to set
* RETURNS: Status * RETURNS: Status
*/ */
NTSTATUS NTSTATUS
STDCALL STDCALL
NtSetVolumeInformationFile( NtSetVolumeInformationFile(
IN HANDLE FileHandle, IN HANDLE FileHandle,
IN CINT VolumeInformationClass, OUT PIO_STATUS_BLOCK IoStatusBlock,
PVOID VolumeInformation, IN PVOID FsInformation,
ULONG Length IN ULONG Length,
IN FS_INFORMATION_CLASS FsInformationClass
); );
NTSTATUS NTSTATUS
STDCALL STDCALL
ZwSetVolumeInformationFile( ZwSetVolumeInformationFile(
IN HANDLE FileHandle, IN HANDLE FileHandle,
IN CINT VolumeInformationClass, OUT PIO_STATUS_BLOCK IoStatusBlock,
PVOID VolumeInformation, IN PVOID FsInformation,
ULONG Length IN ULONG Length,
IN FS_INFORMATION_CLASS FsInformationClass
); );
/* /*

View file

@ -104,5 +104,13 @@
#define FS_FILE_COMPRESSION (16) #define FS_FILE_COMPRESSION (16)
#define FS_VOL_IS_COMPRESSED (32768) #define FS_VOL_IS_COMPRESSED (32768)
/* NtQueryVolumeInformationFile */
#define FILE_CASE_SENSITIVE_SEARCH (0x00000001)
#define FILE_CASE_PRESERVED_NAMES (0x00000002)
#define FILE_UNICODE_ON_DISK (0x00000004)
#define FILE_PERSISTENT_ACLS (0x00000008)
#define FILE_FILE_COMPRESSION (0x00000010)
#define FILE_VOLUME_IS_COMPRESSED (0x00008000)
#endif /* __INCLUDE_FILE_H */ #endif /* __INCLUDE_FILE_H */

View file

@ -1,4 +1,4 @@
/* $Id: vpb.c,v 1.11 2001/03/07 16:48:42 dwelch Exp $ /* $Id: vpb.c,v 1.12 2001/06/11 19:48:58 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -13,8 +13,10 @@
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <internal/io.h> #include <internal/io.h>
#include <internal/mm.h>
#include <internal/pool.h> #include <internal/pool.h>
#define NDEBUG #define NDEBUG
#include <internal/debug.h> #include <internal/debug.h>
@ -23,23 +25,25 @@
static KSPIN_LOCK IoVpbLock; static KSPIN_LOCK IoVpbLock;
#define TAG_VPB TAG('V', 'P', 'B', ' ') #define TAG_VPB TAG('V', 'P', 'B', ' ')
#define TAG_SYSB TAG('S', 'Y', 'S', 'B')
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
VOID VOID
IoInitVpbImplementation ( IoInitVpbImplementation(VOID)
VOID
)
{ {
KeInitializeSpinLock(&IoVpbLock); KeInitializeSpinLock(&IoVpbLock);
} }
NTSTATUS IoAttachVpb(PDEVICE_OBJECT DeviceObject) NTSTATUS
IoAttachVpb(PDEVICE_OBJECT DeviceObject)
{ {
PVPB Vpb; PVPB Vpb;
Vpb = ExAllocatePoolWithTag(NonPagedPool, sizeof(VPB), TAG_VPB); Vpb = ExAllocatePoolWithTag(NonPagedPool,
if (Vpb==NULL) sizeof(VPB),
TAG_VPB);
if (Vpb == NULL)
{ {
return(STATUS_UNSUCCESSFUL); return(STATUS_UNSUCCESSFUL);
} }
@ -48,86 +52,33 @@ NTSTATUS IoAttachVpb(PDEVICE_OBJECT DeviceObject)
Vpb->Size = sizeof(VPB) / sizeof(DWORD); Vpb->Size = sizeof(VPB) / sizeof(DWORD);
Vpb->Flags = 0; Vpb->Flags = 0;
Vpb->VolumeLabelLength = 0; Vpb->VolumeLabelLength = 0;
Vpb->DeviceObject = NULL; Vpb->DeviceObject = NULL;
Vpb->RealDevice = DeviceObject; Vpb->RealDevice = DeviceObject;
Vpb->SerialNumber = 0; Vpb->SerialNumber = 0;
Vpb->ReferenceCount = 0; Vpb->ReferenceCount = 0;
RtlZeroMemory(Vpb->VolumeLabel,sizeof(WCHAR)*MAXIMUM_VOLUME_LABEL_LENGTH); RtlZeroMemory(Vpb->VolumeLabel,
sizeof(WCHAR) * MAXIMUM_VOLUME_LABEL_LENGTH);
DeviceObject->Vpb = Vpb; DeviceObject->Vpb = Vpb;
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
PIRP IoBuildVolumeInformationIrp(ULONG MajorFunction,
PFILE_OBJECT FileObject,
PVOID FSInformation,
ULONG Length,
CINT FSInformationClass,
PIO_STATUS_BLOCK IoStatusBlock,
PKEVENT Event)
{
PIRP Irp;
PIO_STACK_LOCATION StackPtr;
PDEVICE_OBJECT DeviceObject;
DeviceObject = FileObject->DeviceObject;
Irp = IoAllocateIrp(DeviceObject->StackSize,TRUE);
if (Irp==NULL)
{
return(NULL);
}
// Irp->AssociatedIrp.SystemBuffer = FSInformation;
Irp->UserBuffer = FSInformation;
StackPtr = IoGetNextIrpStackLocation(Irp);
StackPtr->MajorFunction = MajorFunction;
StackPtr->MinorFunction = 0;
StackPtr->Flags = 0;
StackPtr->Control = 0;
StackPtr->DeviceObject = DeviceObject;
StackPtr->FileObject = FileObject;
Irp->UserEvent = Event;
Irp->UserIosb = IoStatusBlock;
switch (MajorFunction)
{
case IRP_MJ_SET_VOLUME_INFORMATION:
StackPtr->Parameters.SetVolume.Length = Length;
StackPtr->Parameters.SetVolume.FileInformationClass =
FSInformationClass;
break;
case IRP_MJ_QUERY_VOLUME_INFORMATION: NTSTATUS STDCALL
StackPtr->Parameters.QueryVolume.Length = Length; NtQueryVolumeInformationFile(IN HANDLE FileHandle,
StackPtr->Parameters.QueryVolume.FileInformationClass = OUT PIO_STATUS_BLOCK IoStatusBlock,
FSInformationClass; OUT PVOID FSInformation,
break; IN ULONG Length,
} IN FS_INFORMATION_CLASS FSInformationClass)
return(Irp);
}
NTSTATUS
STDCALL
NtQueryVolumeInformationFile (
IN HANDLE FileHandle,
OUT PIO_STATUS_BLOCK IoStatusBlock,
OUT PVOID FSInformation,
IN ULONG Length,
IN FS_INFORMATION_CLASS FSInformationClass
)
/* /*
* FUNCTION: Queries the volume information * FUNCTION: Queries the volume information
* ARGUMENTS: * ARGUMENTS:
* FileHandle = Handle to a file object on the target volume * FileHandle = Handle to a file object on the target volume
* ReturnLength = DataWritten * ReturnLength = DataWritten
* FSInformation = Caller should supply storage for the information * FSInformation = Caller should supply storage for the information
* structure. * structure.
* Length = Size of the information structure * Length = Size of the information structure
* FSInformationClass = Index to a information structure * FSInformationClass = Index to a information structure
* *
@ -149,6 +100,8 @@ NtQueryVolumeInformationFile (
PIRP Irp; PIRP Irp;
KEVENT Event; KEVENT Event;
NTSTATUS Status; NTSTATUS Status;
PIO_STACK_LOCATION StackPtr;
PVOID SystemBuffer;
DPRINT("FSInformation %p\n", FSInformation); DPRINT("FSInformation %p\n", FSInformation);
@ -157,125 +110,190 @@ NtQueryVolumeInformationFile (
NULL, NULL,
UserMode, UserMode,
(PVOID*)&FileObject, (PVOID*)&FileObject,
NULL); NULL);
if (Status != STATUS_SUCCESS) if (!NT_SUCCESS(Status))
{ {
return(Status); return(Status);
} }
DeviceObject = FileObject->DeviceObject; DeviceObject = FileObject->DeviceObject;
KeInitializeEvent(&Event,NotificationEvent,FALSE); KeInitializeEvent(&Event,
NotificationEvent,
FALSE);
Irp = IoBuildVolumeInformationIrp(IRP_MJ_QUERY_VOLUME_INFORMATION, Irp = IoAllocateIrp(DeviceObject->StackSize,
FileObject, TRUE);
FSInformation, if (Irp == NULL)
Length, {
FSInformationClass, ObDereferenceObject(FileObject);
IoStatusBlock, return(STATUS_INSUFFICIENT_RESOURCES);
&Event); }
Status = IoCallDriver(DeviceObject,Irp);
SystemBuffer = ExAllocatePoolWithTag(NonPagedPool,
Length,
TAG_SYSB);
if (SystemBuffer == NULL)
{
IoFreeIrp(Irp);
ObDereferenceObject(FileObject);
return(STATUS_INSUFFICIENT_RESOURCES);
}
Irp->AssociatedIrp.SystemBuffer = SystemBuffer;
Irp->UserEvent = &Event;
Irp->UserIosb = IoStatusBlock;
StackPtr = IoGetNextIrpStackLocation(Irp);
StackPtr->MajorFunction = IRP_MJ_QUERY_VOLUME_INFORMATION;
StackPtr->MinorFunction = 0;
StackPtr->Flags = 0;
StackPtr->Control = 0;
StackPtr->DeviceObject = DeviceObject;
StackPtr->FileObject = FileObject;
StackPtr->Parameters.QueryVolume.Length = Length;
StackPtr->Parameters.QueryVolume.FsInformationClass =
FSInformationClass;
Status = IoCallDriver(DeviceObject,
Irp);
if (Status == STATUS_PENDING) if (Status == STATUS_PENDING)
{ {
KeWaitForSingleObject(&Event,UserRequest,KernelMode,FALSE,NULL); KeWaitForSingleObject(&Event,
UserRequest,
KernelMode,
FALSE,
NULL);
Status = IoStatusBlock->Status; Status = IoStatusBlock->Status;
} }
MmSafeCopyToUser(FSInformation,
SystemBuffer,
Length);
ExFreePool(SystemBuffer);
return(Status); return(Status);
} }
NTSTATUS NTSTATUS STDCALL
STDCALL IoQueryVolumeInformation(IN PFILE_OBJECT FileObject,
IoQueryVolumeInformation ( IN FS_INFORMATION_CLASS FsInformationClass,
IN PFILE_OBJECT FileObject, IN ULONG Length,
IN FS_INFORMATION_CLASS FsInformationClass, OUT PVOID FsInformation,
IN ULONG Length, OUT PULONG ReturnedLength)
OUT PVOID FsInformation,
OUT PULONG ReturnedLength
)
{ {
UNIMPLEMENTED; UNIMPLEMENTED;
return (STATUS_NOT_IMPLEMENTED); return(STATUS_NOT_IMPLEMENTED);
} }
NTSTATUS NTSTATUS STDCALL
STDCALL NtSetVolumeInformationFile(IN HANDLE FileHandle,
NtSetVolumeInformationFile ( OUT PIO_STATUS_BLOCK IoStatusBlock,
IN HANDLE FileHandle, IN PVOID FsInformation,
IN CINT VolumeInformationClass, IN ULONG Length,
PVOID VolumeInformation, IN FS_INFORMATION_CLASS FsInformationClass)
ULONG Length
)
{ {
PFILE_OBJECT FileObject; PFILE_OBJECT FileObject;
PDEVICE_OBJECT DeviceObject; PDEVICE_OBJECT DeviceObject;
PIRP Irp; PIRP Irp;
KEVENT Event; KEVENT Event;
NTSTATUS Status; NTSTATUS Status;
PIO_STACK_LOCATION StackPtr;
PVOID SystemBuffer;
Status = ObReferenceObjectByHandle(FileHandle, Status = ObReferenceObjectByHandle(FileHandle,
FILE_WRITE_ATTRIBUTES, FILE_WRITE_ATTRIBUTES,
NULL, NULL,
UserMode, UserMode,
(PVOID*)&FileObject, (PVOID*)&FileObject,
NULL); NULL);
if (Status != STATUS_SUCCESS) if (Status != STATUS_SUCCESS)
{ {
return(Status); return(Status);
} }
DeviceObject = FileObject->DeviceObject; DeviceObject = FileObject->DeviceObject;
KeInitializeEvent(&Event,NotificationEvent,FALSE); KeInitializeEvent(&Event,
NotificationEvent,
Irp = IoBuildVolumeInformationIrp(IRP_MJ_SET_VOLUME_INFORMATION, FALSE);
FileObject,
VolumeInformation, Irp = IoAllocateIrp(DeviceObject->StackSize,TRUE);
Length, if (Irp == NULL)
VolumeInformationClass, {
NULL, ObDereferenceObject(FileObject);
&Event); return(STATUS_INSUFFICIENT_RESOURCES);
}
SystemBuffer = ExAllocatePoolWithTag(NonPagedPool,
Length,
TAG_SYSB);
if (SystemBuffer == NULL)
{
IoFreeIrp(Irp);
ObDereferenceObject(FileObject);
return(STATUS_INSUFFICIENT_RESOURCES);
}
MmSafeCopyFromUser(SystemBuffer,
FsInformation,
Length);
Irp->AssociatedIrp.SystemBuffer = SystemBuffer;
Irp->UserEvent = &Event;
Irp->UserIosb = IoStatusBlock;
StackPtr = IoGetNextIrpStackLocation(Irp);
StackPtr->MajorFunction = IRP_MJ_SET_VOLUME_INFORMATION;
StackPtr->MinorFunction = 0;
StackPtr->Flags = 0;
StackPtr->Control = 0;
StackPtr->DeviceObject = DeviceObject;
StackPtr->FileObject = FileObject;
StackPtr->Parameters.SetVolume.Length = Length;
StackPtr->Parameters.SetVolume.FsInformationClass =
FsInformationClass;
Status = IoCallDriver(DeviceObject,Irp); Status = IoCallDriver(DeviceObject,Irp);
if (Status == STATUS_PENDING) if (Status == STATUS_PENDING)
{ {
KeWaitForSingleObject(&Event,UserRequest,KernelMode,FALSE,NULL); KeWaitForSingleObject(&Event,
UserRequest,
KernelMode,
FALSE,
NULL);
} }
ExFreePool(SystemBuffer);
return(Status); return(Status);
} }
VOID VOID STDCALL
STDCALL IoAcquireVpbSpinLock(OUT PKIRQL Irql)
IoAcquireVpbSpinLock (
OUT PKIRQL Irql
)
{ {
KeAcquireSpinLock (&IoVpbLock, KeAcquireSpinLock(&IoVpbLock,
Irql); Irql);
} }
VOID VOID STDCALL
STDCALL IoReleaseVpbSpinLock(IN KIRQL Irql)
IoReleaseVpbSpinLock (
IN KIRQL Irql
)
{ {
KeReleaseSpinLock (&IoVpbLock, KeReleaseSpinLock(&IoVpbLock,
Irql); Irql);
} }
NTSTATUS NTSTATUS STDCALL
STDCALL IoVerifyVolume(IN PDEVICE_OBJECT DeviceObject,
IoVerifyVolume ( IN BOOLEAN AllowRawMount)
IN PDEVICE_OBJECT DeviceObject,
IN BOOLEAN AllowRawMount
)
{ {
UNIMPLEMENTED; UNIMPLEMENTED;
return (STATUS_NOT_IMPLEMENTED); return(STATUS_NOT_IMPLEMENTED);
} }