2005-08-24 18:29:45 +00:00
|
|
|
/*
|
1999-12-11 21:14:49 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
2003-10-11 17:51:56 +00:00
|
|
|
* FILE: drivers/fs/vfat/volume.c
|
1999-12-11 21:14:49 +00:00
|
|
|
* PURPOSE: VFAT Filesystem
|
|
|
|
* PROGRAMMER: Jason Filby (jasonfilby@yahoo.com)
|
2004-12-05 16:31:51 +00:00
|
|
|
* Herve Poussineau (reactos@poussine.freesurf.fr)
|
1999-12-11 21:14:49 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include "vfat.h"
|
|
|
|
|
|
|
|
/* FUNCTIONS ****************************************************************/
|
|
|
|
|
2001-06-11 19:52:22 +00:00
|
|
|
static NTSTATUS
|
2001-11-02 22:47:36 +00:00
|
|
|
FsdGetFsVolumeInformation(PDEVICE_OBJECT DeviceObject,
|
2001-06-12 12:35:42 +00:00
|
|
|
PFILE_FS_VOLUME_INFORMATION FsVolumeInfo,
|
|
|
|
PULONG BufferLength)
|
1999-12-11 21:14:49 +00:00
|
|
|
{
|
2001-06-11 19:52:22 +00:00
|
|
|
DPRINT("FsdGetFsVolumeInformation()\n");
|
|
|
|
DPRINT("FsVolumeInfo = %p\n", FsVolumeInfo);
|
2001-06-12 12:35:42 +00:00
|
|
|
DPRINT("BufferLength %lu\n", *BufferLength);
|
2001-07-28 10:12:36 +00:00
|
|
|
|
2003-07-20 23:09:01 +00:00
|
|
|
DPRINT("Required length %lu\n", (sizeof(FILE_FS_VOLUME_INFORMATION) + DeviceObject->Vpb->VolumeLabelLength));
|
2003-11-12 15:26:44 +00:00
|
|
|
DPRINT("LabelLength %hu\n", DeviceObject->Vpb->VolumeLabelLength);
|
2003-07-20 23:09:01 +00:00
|
|
|
DPRINT("Label %*.S\n", DeviceObject->Vpb->VolumeLabelLength / sizeof(WCHAR), DeviceObject->Vpb->VolumeLabel);
|
2001-07-28 10:12:36 +00:00
|
|
|
|
2001-11-02 22:47:36 +00:00
|
|
|
if (*BufferLength < sizeof(FILE_FS_VOLUME_INFORMATION))
|
|
|
|
return STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
|
2003-07-20 23:09:01 +00:00
|
|
|
if (*BufferLength < (sizeof(FILE_FS_VOLUME_INFORMATION) + DeviceObject->Vpb->VolumeLabelLength))
|
2001-11-02 22:47:36 +00:00
|
|
|
return STATUS_BUFFER_OVERFLOW;
|
1999-12-11 21:14:49 +00:00
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
/* valid entries */
|
|
|
|
FsVolumeInfo->VolumeSerialNumber = DeviceObject->Vpb->SerialNumber;
|
2003-07-20 23:09:01 +00:00
|
|
|
FsVolumeInfo->VolumeLabelLength = DeviceObject->Vpb->VolumeLabelLength;
|
2004-12-05 16:31:51 +00:00
|
|
|
RtlCopyMemory(FsVolumeInfo->VolumeLabel, DeviceObject->Vpb->VolumeLabel, FsVolumeInfo->VolumeLabelLength);
|
2001-07-28 10:12:36 +00:00
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
/* dummy entries */
|
|
|
|
FsVolumeInfo->VolumeCreationTime.QuadPart = 0;
|
|
|
|
FsVolumeInfo->SupportsObjects = FALSE;
|
2001-07-28 10:12:36 +00:00
|
|
|
|
2001-06-11 19:52:22 +00:00
|
|
|
DPRINT("Finished FsdGetFsVolumeInformation()\n");
|
2001-07-28 10:12:36 +00:00
|
|
|
|
2003-07-20 23:09:01 +00:00
|
|
|
*BufferLength -= (sizeof(FILE_FS_VOLUME_INFORMATION) + DeviceObject->Vpb->VolumeLabelLength);
|
2001-07-28 10:12:36 +00:00
|
|
|
|
2001-06-12 12:35:42 +00:00
|
|
|
DPRINT("BufferLength %lu\n", *BufferLength);
|
2001-07-28 10:12:36 +00:00
|
|
|
|
2001-06-11 19:52:22 +00:00
|
|
|
return(STATUS_SUCCESS);
|
1999-12-11 21:14:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-11 19:52:22 +00:00
|
|
|
static NTSTATUS
|
2002-03-18 22:37:13 +00:00
|
|
|
FsdGetFsAttributeInformation(PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PFILE_FS_ATTRIBUTE_INFORMATION FsAttributeInfo,
|
2001-06-12 12:35:42 +00:00
|
|
|
PULONG BufferLength)
|
1999-12-11 21:14:49 +00:00
|
|
|
{
|
2005-11-11 19:59:38 +00:00
|
|
|
PCWSTR pName; ULONG Length;
|
2001-06-11 19:52:22 +00:00
|
|
|
DPRINT("FsdGetFsAttributeInformation()\n");
|
|
|
|
DPRINT("FsAttributeInfo = %p\n", FsAttributeInfo);
|
2001-06-12 12:35:42 +00:00
|
|
|
DPRINT("BufferLength %lu\n", *BufferLength);
|
2001-07-28 10:12:36 +00:00
|
|
|
|
2001-11-02 22:47:36 +00:00
|
|
|
if (*BufferLength < sizeof (FILE_FS_ATTRIBUTE_INFORMATION))
|
|
|
|
return STATUS_INFO_LENGTH_MISMATCH;
|
|
|
|
|
2003-07-20 18:36:53 +00:00
|
|
|
if (DeviceExt->FatInfo.FatType == FAT32)
|
|
|
|
{
|
|
|
|
Length = 10;
|
|
|
|
pName = L"FAT32";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Length = 6;
|
|
|
|
pName = L"FAT";
|
|
|
|
}
|
|
|
|
|
2004-08-01 21:57:18 +00:00
|
|
|
DPRINT("Required length %lu\n", (sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + Length));
|
|
|
|
|
2002-03-18 22:37:13 +00:00
|
|
|
if (*BufferLength < (sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + Length))
|
2001-11-02 22:47:36 +00:00
|
|
|
return STATUS_BUFFER_OVERFLOW;
|
2001-07-28 10:12:36 +00:00
|
|
|
|
2001-06-11 19:52:22 +00:00
|
|
|
FsAttributeInfo->FileSystemAttributes =
|
2001-06-12 12:35:42 +00:00
|
|
|
FILE_CASE_PRESERVED_NAMES | FILE_UNICODE_ON_DISK;
|
2003-07-20 18:36:53 +00:00
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
FsAttributeInfo->MaximumComponentNameLength = 255;
|
2003-07-20 18:36:53 +00:00
|
|
|
|
2002-03-18 22:37:13 +00:00
|
|
|
FsAttributeInfo->FileSystemNameLength = Length;
|
2003-07-20 18:36:53 +00:00
|
|
|
|
2004-12-05 16:31:51 +00:00
|
|
|
RtlCopyMemory(FsAttributeInfo->FileSystemName, pName, Length );
|
2001-07-28 10:12:36 +00:00
|
|
|
|
2001-06-11 19:52:22 +00:00
|
|
|
DPRINT("Finished FsdGetFsAttributeInformation()\n");
|
2001-07-28 10:12:36 +00:00
|
|
|
|
2002-03-18 22:37:13 +00:00
|
|
|
*BufferLength -= (sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + Length);
|
2001-06-12 12:35:42 +00:00
|
|
|
DPRINT("BufferLength %lu\n", *BufferLength);
|
2001-07-28 10:12:36 +00:00
|
|
|
|
2001-06-11 19:52:22 +00:00
|
|
|
return(STATUS_SUCCESS);
|
1999-12-11 21:14:49 +00:00
|
|
|
}
|
|
|
|
|
2001-06-12 12:35:42 +00:00
|
|
|
|
2001-06-11 19:52:22 +00:00
|
|
|
static NTSTATUS
|
|
|
|
FsdGetFsSizeInformation(PDEVICE_OBJECT DeviceObject,
|
2001-06-12 12:35:42 +00:00
|
|
|
PFILE_FS_SIZE_INFORMATION FsSizeInfo,
|
|
|
|
PULONG BufferLength)
|
1999-12-11 21:14:49 +00:00
|
|
|
{
|
2001-06-12 12:35:42 +00:00
|
|
|
PDEVICE_EXTENSION DeviceExt;
|
2001-06-14 10:02:59 +00:00
|
|
|
NTSTATUS Status;
|
2001-07-28 10:12:36 +00:00
|
|
|
|
2001-06-11 19:52:22 +00:00
|
|
|
DPRINT("FsdGetFsSizeInformation()\n");
|
|
|
|
DPRINT("FsSizeInfo = %p\n", FsSizeInfo);
|
2001-07-28 10:12:36 +00:00
|
|
|
|
2001-11-01 10:41:53 +00:00
|
|
|
if (*BufferLength < sizeof(FILE_FS_SIZE_INFORMATION))
|
|
|
|
return(STATUS_BUFFER_OVERFLOW);
|
2001-07-28 10:12:36 +00:00
|
|
|
|
2001-06-12 12:35:42 +00:00
|
|
|
DeviceExt = DeviceObject->DeviceExtension;
|
2002-03-18 22:37:13 +00:00
|
|
|
Status = CountAvailableClusters(DeviceExt, &FsSizeInfo->AvailableAllocationUnits);
|
2001-07-28 10:12:36 +00:00
|
|
|
|
2002-03-18 22:37:13 +00:00
|
|
|
FsSizeInfo->TotalAllocationUnits.QuadPart = DeviceExt->FatInfo.NumberOfClusters;
|
|
|
|
FsSizeInfo->SectorsPerAllocationUnit = DeviceExt->FatInfo.SectorsPerCluster;
|
|
|
|
FsSizeInfo->BytesPerSector = DeviceExt->FatInfo.BytesPerSector;
|
2001-11-01 10:41:53 +00:00
|
|
|
|
2001-06-11 19:52:22 +00:00
|
|
|
DPRINT("Finished FsdGetFsSizeInformation()\n");
|
2001-06-14 10:02:59 +00:00
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
*BufferLength -= sizeof(FILE_FS_SIZE_INFORMATION);
|
2001-11-01 10:41:53 +00:00
|
|
|
|
2001-06-14 10:02:59 +00:00
|
|
|
return(Status);
|
2001-06-12 12:35:42 +00:00
|
|
|
}
|
1999-12-11 21:14:49 +00:00
|
|
|
|
2001-06-12 12:35:42 +00:00
|
|
|
|
|
|
|
static NTSTATUS
|
2009-12-06 18:49:19 +00:00
|
|
|
FsdGetFsDeviceInformation
|
|
|
|
(
|
|
|
|
PDEVICE_OBJECT DeviceObject,
|
|
|
|
PFILE_FS_DEVICE_INFORMATION FsDeviceInfo,
|
|
|
|
PULONG BufferLength
|
|
|
|
)
|
2001-06-12 12:35:42 +00:00
|
|
|
{
|
|
|
|
DPRINT("FsdGetFsDeviceInformation()\n");
|
|
|
|
DPRINT("FsDeviceInfo = %p\n", FsDeviceInfo);
|
|
|
|
DPRINT("BufferLength %lu\n", *BufferLength);
|
|
|
|
DPRINT("Required length %lu\n", sizeof(FILE_FS_DEVICE_INFORMATION));
|
2001-11-01 10:41:53 +00:00
|
|
|
|
|
|
|
if (*BufferLength < sizeof(FILE_FS_DEVICE_INFORMATION))
|
|
|
|
return(STATUS_BUFFER_OVERFLOW);
|
|
|
|
|
2001-06-12 12:35:42 +00:00
|
|
|
FsDeviceInfo->DeviceType = FILE_DEVICE_DISK;
|
2009-12-06 18:49:19 +00:00
|
|
|
FsDeviceInfo->Characteristics = DeviceObject->Characteristics;
|
2001-11-01 10:41:53 +00:00
|
|
|
|
2001-06-12 12:35:42 +00:00
|
|
|
DPRINT("FsdGetFsDeviceInformation() finished.\n");
|
2001-11-01 10:41:53 +00:00
|
|
|
|
2001-06-12 12:35:42 +00:00
|
|
|
*BufferLength -= sizeof(FILE_FS_DEVICE_INFORMATION);
|
|
|
|
DPRINT("BufferLength %lu\n", *BufferLength);
|
2001-11-01 10:41:53 +00:00
|
|
|
|
2001-06-11 19:52:22 +00:00
|
|
|
return(STATUS_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static NTSTATUS
|
|
|
|
FsdSetFsLabelInformation(PDEVICE_OBJECT DeviceObject,
|
|
|
|
PFILE_FS_LABEL_INFORMATION FsLabelInfo)
|
|
|
|
{
|
2004-12-05 16:31:51 +00:00
|
|
|
PDEVICE_EXTENSION DeviceExt;
|
|
|
|
PVOID Context = NULL;
|
|
|
|
ULONG DirIndex = 0;
|
|
|
|
PDIR_ENTRY Entry;
|
|
|
|
PVFATFCB pRootFcb;
|
|
|
|
LARGE_INTEGER FileOffset;
|
2005-01-12 10:46:13 +00:00
|
|
|
BOOLEAN LabelFound = FALSE;
|
2004-12-05 16:31:51 +00:00
|
|
|
DIR_ENTRY VolumeLabelDirEntry;
|
|
|
|
ULONG VolumeLabelDirIndex;
|
|
|
|
ULONG LabelLen;
|
|
|
|
NTSTATUS Status = STATUS_UNSUCCESSFUL;
|
|
|
|
OEM_STRING StringO;
|
|
|
|
UNICODE_STRING StringW;
|
|
|
|
CHAR cString[43];
|
|
|
|
ULONG SizeDirEntry;
|
|
|
|
ULONG EntriesPerPage;
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2001-07-20 08:00:21 +00:00
|
|
|
DPRINT("FsdSetFsLabelInformation()\n");
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2004-12-05 16:31:51 +00:00
|
|
|
DeviceExt = (PDEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2004-12-05 16:31:51 +00:00
|
|
|
if (sizeof(DeviceObject->Vpb->VolumeLabel) < FsLabelInfo->VolumeLabelLength)
|
|
|
|
{
|
|
|
|
return STATUS_NAME_TOO_LONG;
|
|
|
|
}
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2004-12-05 16:31:51 +00:00
|
|
|
if (DeviceExt->Flags & VCB_IS_FATX)
|
|
|
|
{
|
|
|
|
if (FsLabelInfo->VolumeLabelLength / sizeof(WCHAR) > 42)
|
|
|
|
return STATUS_NAME_TOO_LONG;
|
|
|
|
SizeDirEntry = sizeof(FATX_DIR_ENTRY);
|
|
|
|
EntriesPerPage = FATX_ENTRIES_PER_PAGE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (FsLabelInfo->VolumeLabelLength / sizeof(WCHAR) > 11)
|
|
|
|
return STATUS_NAME_TOO_LONG;
|
|
|
|
SizeDirEntry = sizeof(FAT_DIR_ENTRY);
|
|
|
|
EntriesPerPage = FAT_ENTRIES_PER_PAGE;
|
|
|
|
}
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2004-12-05 16:31:51 +00:00
|
|
|
/* Create Volume label dir entry */
|
|
|
|
LabelLen = FsLabelInfo->VolumeLabelLength / sizeof(WCHAR);
|
|
|
|
RtlZeroMemory(&VolumeLabelDirEntry, SizeDirEntry);
|
|
|
|
StringW.Buffer = FsLabelInfo->VolumeLabel;
|
2005-02-24 20:47:07 +00:00
|
|
|
StringW.Length = StringW.MaximumLength = (USHORT)FsLabelInfo->VolumeLabelLength;
|
2004-12-05 16:31:51 +00:00
|
|
|
StringO.Buffer = cString;
|
|
|
|
StringO.Length = 0;
|
|
|
|
StringO.MaximumLength = 42;
|
|
|
|
Status = RtlUnicodeStringToOemString(&StringO, &StringW, FALSE);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
return Status;
|
|
|
|
if (DeviceExt->Flags & VCB_IS_FATX)
|
|
|
|
{
|
|
|
|
RtlCopyMemory(VolumeLabelDirEntry.FatX.Filename, cString, LabelLen);
|
|
|
|
memset(&VolumeLabelDirEntry.FatX.Filename[LabelLen], ' ', 42 - LabelLen);
|
|
|
|
VolumeLabelDirEntry.FatX.Attrib = 0x08;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RtlCopyMemory(VolumeLabelDirEntry.Fat.Filename, cString, LabelLen);
|
|
|
|
memset(&VolumeLabelDirEntry.Fat.Filename[LabelLen], ' ', 11 - LabelLen);
|
|
|
|
VolumeLabelDirEntry.Fat.Attrib = 0x08;
|
|
|
|
}
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2004-12-05 16:31:51 +00:00
|
|
|
pRootFcb = vfatOpenRootFCB(DeviceExt);
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2004-12-05 16:31:51 +00:00
|
|
|
/* Search existing volume entry on disk */
|
|
|
|
FileOffset.QuadPart = 0;
|
2010-08-30 11:51:17 +00:00
|
|
|
if (CcPinRead(pRootFcb->FileObject, &FileOffset, SizeDirEntry, TRUE, &Context, (PVOID*)&Entry))
|
2004-12-05 16:31:51 +00:00
|
|
|
{
|
|
|
|
while (TRUE)
|
|
|
|
{
|
|
|
|
if (ENTRY_VOLUME(DeviceExt, Entry))
|
|
|
|
{
|
|
|
|
/* Update entry */
|
|
|
|
LabelFound = TRUE;
|
|
|
|
RtlCopyMemory(Entry, &VolumeLabelDirEntry, SizeDirEntry);
|
|
|
|
CcSetDirtyPinnedData(Context, NULL);
|
|
|
|
Status = STATUS_SUCCESS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (ENTRY_END(DeviceExt, Entry))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
DirIndex++;
|
|
|
|
Entry = (PDIR_ENTRY)((ULONG_PTR)Entry + SizeDirEntry);
|
|
|
|
if ((DirIndex % EntriesPerPage) == 0)
|
|
|
|
{
|
2010-08-30 11:51:17 +00:00
|
|
|
CcUnpinData(Context);
|
|
|
|
FileOffset.u.LowPart += PAGE_SIZE;
|
|
|
|
if (!CcPinRead(pRootFcb->FileObject, &FileOffset, SizeDirEntry, TRUE, &Context, (PVOID*)&Entry))
|
|
|
|
{
|
|
|
|
Context = NULL;
|
|
|
|
break;
|
|
|
|
}
|
2004-12-05 16:31:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Context)
|
|
|
|
{
|
|
|
|
CcUnpinData(Context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!LabelFound)
|
|
|
|
{
|
|
|
|
/* Add new entry for label */
|
|
|
|
if (!vfatFindDirSpace(DeviceExt, pRootFcb, 1, &VolumeLabelDirIndex))
|
|
|
|
Status = STATUS_DISK_FULL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FileOffset.u.HighPart = 0;
|
|
|
|
FileOffset.u.LowPart = VolumeLabelDirIndex * SizeDirEntry;
|
2005-01-12 11:07:31 +00:00
|
|
|
CcPinRead(pRootFcb->FileObject, &FileOffset, SizeDirEntry,
|
2004-12-05 16:31:51 +00:00
|
|
|
TRUE, &Context, (PVOID*)&Entry);
|
|
|
|
RtlCopyMemory(Entry, &VolumeLabelDirEntry, SizeDirEntry);
|
|
|
|
CcSetDirtyPinnedData(Context, NULL);
|
|
|
|
CcUnpinData(Context);
|
|
|
|
Status = STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2004-12-05 16:31:51 +00:00
|
|
|
vfatReleaseFCB(DeviceExt, pRootFcb);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
return Status;
|
|
|
|
}
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2004-12-05 16:31:51 +00:00
|
|
|
/* Update volume label in memory */
|
2005-02-24 20:47:07 +00:00
|
|
|
DeviceObject->Vpb->VolumeLabelLength = (USHORT)FsLabelInfo->VolumeLabelLength;
|
2004-12-05 16:31:51 +00:00
|
|
|
RtlCopyMemory(DeviceObject->Vpb->VolumeLabel, FsLabelInfo->VolumeLabel, DeviceObject->Vpb->VolumeLabelLength);
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2004-12-05 16:31:51 +00:00
|
|
|
return Status;
|
1999-12-11 21:14:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-02 22:47:36 +00:00
|
|
|
NTSTATUS VfatQueryVolumeInformation(PVFAT_IRP_CONTEXT IrpContext)
|
1999-12-11 21:14:49 +00:00
|
|
|
/*
|
2001-06-11 19:52:22 +00:00
|
|
|
* FUNCTION: Retrieve the specified volume information
|
1999-12-11 21:14:49 +00:00
|
|
|
*/
|
|
|
|
{
|
2001-06-11 19:52:22 +00:00
|
|
|
FS_INFORMATION_CLASS FsInformationClass;
|
2000-12-29 23:17:12 +00:00
|
|
|
NTSTATUS RC = STATUS_SUCCESS;
|
2001-06-11 19:52:22 +00:00
|
|
|
PVOID SystemBuffer;
|
|
|
|
ULONG BufferLength;
|
1999-12-11 21:14:49 +00:00
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
/* PRECONDITION */
|
2004-11-06 13:44:57 +00:00
|
|
|
ASSERT(IrpContext);
|
1999-12-11 21:14:49 +00:00
|
|
|
|
2007-11-21 16:50:07 +00:00
|
|
|
DPRINT("VfatQueryVolumeInformation(IrpContext %p)\n", IrpContext);
|
2001-11-02 22:47:36 +00:00
|
|
|
|
2003-07-24 19:00:42 +00:00
|
|
|
if (!ExAcquireResourceSharedLite(&((PDEVICE_EXTENSION)IrpContext->DeviceObject->DeviceExtension)->DirResource,
|
|
|
|
(BOOLEAN)(IrpContext->Flags & IRPCONTEXT_CANWAIT)))
|
2001-11-02 22:47:36 +00:00
|
|
|
{
|
|
|
|
return VfatQueueRequest (IrpContext);
|
|
|
|
}
|
1999-12-11 21:14:49 +00:00
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
/* INITIALIZATION */
|
2001-11-02 22:47:36 +00:00
|
|
|
FsInformationClass = IrpContext->Stack->Parameters.QueryVolume.FsInformationClass;
|
|
|
|
BufferLength = IrpContext->Stack->Parameters.QueryVolume.Length;
|
|
|
|
SystemBuffer = IrpContext->Irp->AssociatedIrp.SystemBuffer;
|
|
|
|
|
1999-12-11 21:14:49 +00:00
|
|
|
|
2001-06-11 19:52:22 +00:00
|
|
|
DPRINT ("FsInformationClass %d\n", FsInformationClass);
|
2007-11-21 16:50:07 +00:00
|
|
|
DPRINT ("SystemBuffer %p\n", SystemBuffer);
|
1999-12-11 21:14:49 +00:00
|
|
|
|
2001-06-11 19:52:22 +00:00
|
|
|
switch (FsInformationClass)
|
2000-12-29 23:17:12 +00:00
|
|
|
{
|
|
|
|
case FileFsVolumeInformation:
|
2001-11-02 22:47:36 +00:00
|
|
|
RC = FsdGetFsVolumeInformation(IrpContext->DeviceObject,
|
2001-06-12 12:35:42 +00:00
|
|
|
SystemBuffer,
|
|
|
|
&BufferLength);
|
2000-12-29 23:17:12 +00:00
|
|
|
break;
|
1999-12-11 21:14:49 +00:00
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
case FileFsAttributeInformation:
|
2002-03-18 22:37:13 +00:00
|
|
|
RC = FsdGetFsAttributeInformation(IrpContext->DeviceObject->DeviceExtension,
|
|
|
|
SystemBuffer,
|
2001-06-12 12:35:42 +00:00
|
|
|
&BufferLength);
|
2000-12-29 23:17:12 +00:00
|
|
|
break;
|
1999-12-11 21:14:49 +00:00
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
case FileFsSizeInformation:
|
2001-11-02 22:47:36 +00:00
|
|
|
RC = FsdGetFsSizeInformation(IrpContext->DeviceObject,
|
2001-06-12 12:35:42 +00:00
|
|
|
SystemBuffer,
|
|
|
|
&BufferLength);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FileFsDeviceInformation:
|
2009-12-06 18:49:19 +00:00
|
|
|
RC = FsdGetFsDeviceInformation(IrpContext->DeviceObject,
|
|
|
|
SystemBuffer,
|
2001-06-12 12:35:42 +00:00
|
|
|
&BufferLength);
|
2000-12-29 23:17:12 +00:00
|
|
|
break;
|
1999-12-11 21:14:49 +00:00
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
default:
|
2001-06-12 12:35:42 +00:00
|
|
|
RC = STATUS_NOT_SUPPORTED;
|
2000-12-29 23:17:12 +00:00
|
|
|
}
|
1999-12-11 21:14:49 +00:00
|
|
|
|
2001-11-02 22:47:36 +00:00
|
|
|
ExReleaseResourceLite(&((PDEVICE_EXTENSION)IrpContext->DeviceObject->DeviceExtension)->DirResource);
|
|
|
|
IrpContext->Irp->IoStatus.Status = RC;
|
2001-06-12 12:35:42 +00:00
|
|
|
if (NT_SUCCESS(RC))
|
2001-11-02 22:47:36 +00:00
|
|
|
IrpContext->Irp->IoStatus.Information =
|
|
|
|
IrpContext->Stack->Parameters.QueryVolume.Length - BufferLength;
|
2001-06-12 12:35:42 +00:00
|
|
|
else
|
2001-11-02 22:47:36 +00:00
|
|
|
IrpContext->Irp->IoStatus.Information = 0;
|
|
|
|
IoCompleteRequest(IrpContext->Irp, IO_NO_INCREMENT);
|
|
|
|
VfatFreeIrpContext(IrpContext);
|
1999-12-11 21:14:49 +00:00
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
return RC;
|
1999-12-11 21:14:49 +00:00
|
|
|
}
|
2001-06-11 19:52:22 +00:00
|
|
|
|
|
|
|
|
2001-11-02 22:47:36 +00:00
|
|
|
NTSTATUS VfatSetVolumeInformation(PVFAT_IRP_CONTEXT IrpContext)
|
2001-06-11 19:52:22 +00:00
|
|
|
/*
|
|
|
|
* FUNCTION: Set the specified volume information
|
|
|
|
*/
|
|
|
|
{
|
2001-07-20 08:00:21 +00:00
|
|
|
FS_INFORMATION_CLASS FsInformationClass;
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
PVOID SystemBuffer;
|
|
|
|
ULONG BufferLength;
|
2004-12-23 12:39:16 +00:00
|
|
|
PIO_STACK_LOCATION Stack = IrpContext->Stack;
|
2001-07-20 08:00:21 +00:00
|
|
|
|
|
|
|
/* PRECONDITION */
|
2004-11-06 13:44:57 +00:00
|
|
|
ASSERT(IrpContext);
|
2001-11-02 22:47:36 +00:00
|
|
|
|
2007-11-21 16:50:07 +00:00
|
|
|
DPRINT ("VfatSetVolumeInformation(IrpContext %p)\n", IrpContext);
|
2001-07-20 08:00:21 +00:00
|
|
|
|
2003-07-24 19:00:42 +00:00
|
|
|
if (!ExAcquireResourceExclusiveLite(&((PDEVICE_EXTENSION)IrpContext->DeviceObject->DeviceExtension)->DirResource,
|
|
|
|
(BOOLEAN)(IrpContext->Flags & IRPCONTEXT_CANWAIT)))
|
2001-11-02 22:47:36 +00:00
|
|
|
{
|
|
|
|
return VfatQueueRequest (IrpContext);
|
|
|
|
}
|
2001-07-20 08:00:21 +00:00
|
|
|
|
2003-08-07 11:47:33 +00:00
|
|
|
FsInformationClass = Stack->Parameters.SetVolume.FsInformationClass;
|
|
|
|
BufferLength = Stack->Parameters.SetVolume.Length;
|
2001-11-02 22:47:36 +00:00
|
|
|
SystemBuffer = IrpContext->Irp->AssociatedIrp.SystemBuffer;
|
2001-07-20 08:00:21 +00:00
|
|
|
|
2004-12-05 16:31:51 +00:00
|
|
|
DPRINT ("FsInformationClass %d\n", FsInformationClass);
|
|
|
|
DPRINT ("BufferLength %d\n", BufferLength);
|
2007-11-21 16:50:07 +00:00
|
|
|
DPRINT ("SystemBuffer %p\n", SystemBuffer);
|
2001-07-20 08:00:21 +00:00
|
|
|
|
|
|
|
switch(FsInformationClass)
|
|
|
|
{
|
|
|
|
case FileFsLabelInformation:
|
2001-11-02 22:47:36 +00:00
|
|
|
Status = FsdSetFsLabelInformation(IrpContext->DeviceObject,
|
2001-07-20 08:00:21 +00:00
|
|
|
SystemBuffer);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
Status = STATUS_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
|
2001-11-02 22:47:36 +00:00
|
|
|
ExReleaseResourceLite(&((PDEVICE_EXTENSION)IrpContext->DeviceObject->DeviceExtension)->DirResource);
|
|
|
|
IrpContext->Irp->IoStatus.Status = Status;
|
|
|
|
IrpContext->Irp->IoStatus.Information = 0;
|
|
|
|
IoCompleteRequest(IrpContext->Irp, IO_NO_INCREMENT);
|
|
|
|
VfatFreeIrpContext(IrpContext);
|
2001-07-20 08:00:21 +00:00
|
|
|
|
|
|
|
return(Status);
|
2001-06-11 19:52:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|