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

@ -1747,6 +1747,121 @@ NTSTATUS FsdSetInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp)
} }
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, STDCALL NTSTATUS DriverEntry(PDRIVER_OBJECT _DriverObject,
PUNICODE_STRING RegistryPath) PUNICODE_STRING RegistryPath)
/* /*
@ -1788,6 +1903,8 @@ STDCALL NTSTATUS DriverEntry(PDRIVER_OBJECT _DriverObject,
FsdSetInformation; FsdSetInformation;
VFATDriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] = VFATDriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] =
FsdDirectoryControl; FsdDirectoryControl;
VFATDriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] =
FsdQueryVolumeInformation;
VFATDriverObject->DriverUnload = NULL; VFATDriverObject->DriverUnload = NULL;

View file

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

View file

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

View file

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

View file

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

View file

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