fixed GetVolumeInformation()

svn path=/trunk/; revision=409
This commit is contained in:
Eric Kohl 1999-04-23 11:54:47 +00:00
parent 54378dbf2a
commit 67d7e92025
6 changed files with 199 additions and 43 deletions

View file

@ -1746,7 +1746,122 @@ NTSTATUS FsdSetInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp)
return RC;
}
NTSTATUS FsdGetFsVolumeInformation(PFILE_OBJECT FileObject,
PVfatFCB FCB,
PDEVICE_OBJECT DeviceObject,
PFILE_FS_VOLUME_INFORMATION FsVolumeInfo)
{
DPRINT("FsdGetFsVolumeInformation()\n");
DPRINT("FsVolumeInfo = %p\n", FsVolumeInfo);
if (!FsVolumeInfo)
return(STATUS_SUCCESS);
/* dummy entries */
FsVolumeInfo->VolumeCreationTime.LowPart = 0;
FsVolumeInfo->VolumeCreationTime.HighPart = 0;
FsVolumeInfo->VolumeSerialNumber = 0x01234567;
FsVolumeInfo->SupportsObjects = FALSE;
FsVolumeInfo->VolumeLabelLength = 5;
wcscpy (FsVolumeInfo->VolumeLabel, L"Label");
DPRINT("Finished FsdGetFsVolumeInformation()\n");
return(STATUS_SUCCESS);
}
NTSTATUS FsdGetFsAttributeInformation(PFILE_OBJECT FileObject,
PVfatFCB FCB,
PDEVICE_OBJECT DeviceObject,
PFILE_FS_ATTRIBUTE_INFORMATION FsAttributeInfo)
{
DPRINT("FsdGetFsAttributeInformation()\n");
DPRINT("FsAttributeInfo = %p\n", FsAttributeInfo);
if (!FsAttributeInfo)
return(STATUS_SUCCESS);
/* dummy entries */
FsAttributeInfo->FileSystemAttributes = 0;
FsAttributeInfo->MaximumComponentNameLength = 256;
FsAttributeInfo->FileSystemNameLength = 3;
wcscpy (FsAttributeInfo->FileSystemName, L"FAT");
DPRINT("Finished FsdGetFsAttributeInformation()\n");
return(STATUS_SUCCESS);
}
NTSTATUS FsdQueryVolumeInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp)
/*
* FUNCTION: Retrieve the specified file information
*/
{
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
FILE_INFORMATION_CLASS FileInformationClass =
Stack->Parameters.QueryVolume.FileInformationClass;
PFILE_OBJECT FileObject = NULL;
PVfatFCB FCB = NULL;
// PVfatCCB CCB = NULL;
NTSTATUS RC = STATUS_SUCCESS;
void *SystemBuffer;
/* PRECONDITION */
assert(DeviceObject != NULL);
assert(Irp != NULL);
DPRINT("FsdQueryVolumeInformation(DeviceObject %x, Irp %x)\n",
DeviceObject,Irp);
/* INITIALIZATION */
Stack = IoGetCurrentIrpStackLocation(Irp);
FileInformationClass = Stack->Parameters.QueryVolume.FileInformationClass;
FileObject = Stack->FileObject;
// CCB = (PVfatCCB)(FileObject->FsContext2);
// FCB = CCB->Buffer; // Should be CCB->FCB???
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("SystemBuffer %x\n",SystemBuffer);
switch(FileInformationClass) {
case FileFsVolumeInformation:
RC = FsdGetFsVolumeInformation(FileObject,
FCB,
DeviceObject,
SystemBuffer);
break;
case FileFsAttributeInformation:
RC = FsdGetFsAttributeInformation(FileObject,
FCB,
DeviceObject,
SystemBuffer);
break;
default:
RC=STATUS_NOT_IMPLEMENTED;
}
Irp->IoStatus.Status = RC;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return RC;
}
STDCALL NTSTATUS DriverEntry(PDRIVER_OBJECT _DriverObject,
PUNICODE_STRING RegistryPath)
/*
@ -1788,6 +1903,8 @@ STDCALL NTSTATUS DriverEntry(PDRIVER_OBJECT _DriverObject,
FsdSetInformation;
VFATDriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] =
FsdDirectoryControl;
VFATDriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] =
FsdQueryVolumeInformation;
VFATDriverObject->DriverUnload = NULL;

View file

@ -456,7 +456,7 @@ typedef struct _FILE_FS_ATTRIBUTE_INFORMATION {
LONG MaximumComponentNameLength;
ULONG FileSystemNameLength;
WCHAR FileSystemName[0];
} FILE_FS_ATTRIBUTE_INFORMATION;
} FILE_FS_ATTRIBUTE_INFORMATION, *PFILE_FS_ATTRIBUTE_INFORMATION;
/*
FileSystemAttributes is one of the following values:

View file

@ -4,9 +4,9 @@
* FILE: lib/kernel32/file/volume.c
* PURPOSE: File volume functions
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
Erik Bos, Alexandre Julliard :
DRIVE_IsValid, GetLogicalDriveStringsA,
GetLogicalDriveStringsW, GetLogicalDrives
* Erik Bos, Alexandre Julliard :
* DRIVE_IsValid, GetLogicalDriveStringsA,
* GetLogicalDriveStringsW, GetLogicalDrives
* UPDATE HISTORY:
* Created 01/11/98
*/
@ -23,8 +23,13 @@
#include <wchar.h>
#include <string.h>
#define NDEBUG
#include <kernel32/kernel32.h>
#define MAX_DOS_DRIVES 26
int DRIVE_IsValid( int drive )
{
char Drives[4];
@ -302,8 +307,8 @@ GetVolumeInformationW(
DWORD nFileSystemNameSize
)
{
FILE_FS_VOLUME_INFORMATION *FileFsVolume;
FILE_FS_ATTRIBUTE_INFORMATION *FileFsAttribute;
PFILE_FS_VOLUME_INFORMATION FileFsVolume;
PFILE_FS_ATTRIBUTE_INFORMATION FileFsAttribute;
IO_STATUS_BLOCK IoStatusBlock;
USHORT Buffer[FS_VOLUME_BUFFER_SIZE];
USHORT Buffer2[FS_ATTRIBUTE_BUFFER_SIZE];
@ -311,41 +316,65 @@ GetVolumeInformationW(
HANDLE hFile;
NTSTATUS errCode;
FileFsVolume = (FILE_FS_VOLUME_INFORMATION *)Buffer;
FileFsAttribute = (FILE_FS_VOLUME_INFORMATION *)Buffer2;
hFile = CreateFileW(
lpRootPathName,
GENERIC_ALL,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL
);
FileFsVolume = (PFILE_FS_VOLUME_INFORMATION)Buffer;
FileFsAttribute = (PFILE_FS_ATTRIBUTE_INFORMATION)Buffer2;
errCode = NtQueryVolumeInformationFile(hFile,&IoStatusBlock,FileFsVolume, FS_VOLUME_BUFFER_SIZE,FileFsVolumeInformation);
DPRINT("FileFsVolume %p\n", FileFsVolume);
DPRINT("FileFsAttribute %p\n", FileFsAttribute);
CHECKPOINT;
hFile = CreateFileW(lpRootPathName,
FILE_READ_ATTRIBUTES,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
DPRINT("hFile: %x\n", hFile);
errCode = NtQueryVolumeInformationFile(hFile,
&IoStatusBlock,
FileFsVolume,
FS_VOLUME_BUFFER_SIZE,
FileFsVolumeInformation);
CHECKPOINT;
if ( !NT_SUCCESS(errCode) ) {
CloseHandle(hFile);
DPRINT("Status: %x\n", errCode);
CloseHandle(hFile);
SetLastError(RtlNtStatusToDosError(errCode));
return FALSE;
}
memcpy(lpVolumeSerialNumber, &FileFsVolume->VolumeSerialNumber, sizeof(DWORD));
memcpy(lpVolumeNameBuffer, FileFsVolume->VolumeLabel,min(nVolumeNameSize,MAX_PATH));
CHECKPOINT;
if (lpVolumeSerialNumber)
*lpVolumeSerialNumber = FileFsVolume->VolumeSerialNumber;
CHECKPOINT;
if (lpVolumeNameBuffer)
wcsncpy(lpVolumeNameBuffer, FileFsVolume->VolumeLabel,min(nVolumeNameSize,MAX_PATH));
// memcpy(lpVolumeNameBuffer, FileFsVolume->VolumeLabel,min(nVolumeNameSize,MAX_PATH));
CHECKPOINT;
errCode = NtQueryVolumeInformationFile(hFile,&IoStatusBlock,FileFsAttribute, FS_ATTRIBUTE_BUFFER_SIZE,FileFsAttributeInformation);
CHECKPOINT;
if ( !NT_SUCCESS(errCode) ) {
DPRINT("Status: %x\n", errCode);
CloseHandle(hFile);
SetLastError(RtlNtStatusToDosError(errCode));
return FALSE;
}
memcpy(lpFileSystemFlags,&FileFsAttribute->FileSystemAttributes,sizeof(DWORD));
memcpy(lpMaximumComponentLength, &FileFsAttribute->MaximumComponentNameLength, sizeof(DWORD));
memcpy(lpFileSystemNameBuffer, FileFsAttribute->FileSystemName,min(nFileSystemNameSize,MAX_PATH));
CHECKPOINT;
if (lpFileSystemFlags)
*lpFileSystemFlags = FileFsAttribute->FileSystemAttributes;
// memcpy(lpFileSystemFlags,&FileFsAttribute->FileSystemAttributes,sizeof(DWORD));
CHECKPOINT;
if (lpMaximumComponentLength)
*lpMaximumComponentLength = FileFsAttribute->MaximumComponentNameLength;
// memcpy(lpMaximumComponentLength, &FileFsAttribute->MaximumComponentNameLength, sizeof(DWORD));
CHECKPOINT;
if (lpFileSystemNameBuffer)
wcsncpy(lpFileSystemNameBuffer, FileFsAttribute->FileSystemName,min(nFileSystemNameSize,MAX_PATH));
// memcpy(lpFileSystemNameBuffer, FileFsAttribute->FileSystemName,min(nFileSystemNameSize,MAX_PATH));
CHECKPOINT;
CloseHandle(hFile);
return TRUE;
}
WINBOOL

View file

@ -376,6 +376,7 @@ ZwWriteFile
sprintf
wcslen
wcschr
wcscpy
wcsncat
wcsncpy
CbInitDccb

View file

@ -15,6 +15,7 @@
#include <internal/string.h>
#include <internal/ob.h>
#define NDEBUG
#include <internal/debug.h>
/* FUNCTIONS *****************************************************************/
@ -64,7 +65,8 @@ PIRP IoBuildVolumeInformationIrp(ULONG MajorFunction,
return(NULL);
}
Irp->AssociatedIrp.SystemBuffer = FSInformation;
// Irp->AssociatedIrp.SystemBuffer = FSInformation;
Irp->UserBuffer = FSInformation;
StackPtr = IoGetNextIrpStackLocation(Irp);
StackPtr->MajorFunction = MajorFunction;
@ -76,18 +78,20 @@ PIRP IoBuildVolumeInformationIrp(ULONG MajorFunction,
Irp->UserEvent = Event;
Irp->UserIosb = IoStatusBlock;
if (MajorFunction == IRP_MJ_QUERY_VOLUME_INFORMATION)
{
StackPtr->Parameters.SetVolume.Length = Length;
StackPtr->Parameters.SetVolume.FileInformationClass =
FSInformationClass;
}
else
{
StackPtr->Parameters.QueryVolume.Length = Length;
StackPtr->Parameters.QueryVolume.FileInformationClass =
FSInformationClass;
}
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:
StackPtr->Parameters.QueryVolume.Length = Length;
StackPtr->Parameters.QueryVolume.FileInformationClass =
FSInformationClass;
break;
}
return(Irp);
}
@ -139,7 +143,9 @@ ZwQueryVolumeInformationFile(
PIRP Irp;
KEVENT Event;
NTSTATUS Status;
DPRINT("FSInformation %p\n", FSInformation);
Status = ObReferenceObjectByHandle(FileHandle,
FILE_READ_ATTRIBUTES,
NULL,

View file

@ -3,7 +3,10 @@ memcpy
strtok
toupper
wcschr
wcscpy
wcslen
wcsncpy
wcsncat
wtolower
DbgPrint
ExAllocatePool