2000-12-29 23:17:12 +00:00
|
|
|
/* $Id: finfo.c,v 1.5 2000/12/29 23:17:12 dwelch Exp $
|
1999-12-11 21:14:49 +00:00
|
|
|
*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
|
|
|
* FILE: services/fs/vfat/finfo.c
|
|
|
|
* PURPOSE: VFAT Filesystem
|
|
|
|
* PROGRAMMER: Jason Filby (jasonfilby@yahoo.com)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *****************************************************************/
|
|
|
|
|
2000-02-22 02:02:08 +00:00
|
|
|
#include <ddk/ntddk.h>
|
1999-12-11 21:14:49 +00:00
|
|
|
#include <wchar.h>
|
|
|
|
|
|
|
|
#define NDEBUG
|
2000-06-29 23:35:53 +00:00
|
|
|
#include <debug.h>
|
1999-12-11 21:14:49 +00:00
|
|
|
|
|
|
|
#include "vfat.h"
|
|
|
|
|
|
|
|
/* FUNCTIONS ****************************************************************/
|
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatGetStandardInformation (PVFATFCB FCB, PDEVICE_OBJECT DeviceObject,
|
|
|
|
PFILE_STANDARD_INFORMATION StandardInfo)
|
1999-12-11 21:14:49 +00:00
|
|
|
/*
|
|
|
|
* FUNCTION: Retrieve the standard file information
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
PDEVICE_EXTENSION DeviceExtension;
|
|
|
|
unsigned long AllocSize;
|
|
|
|
|
|
|
|
DeviceExtension = DeviceObject->DeviceExtension;
|
|
|
|
/* PRECONDITION */
|
2000-12-29 23:17:12 +00:00
|
|
|
assert (DeviceExtension != NULL);
|
|
|
|
assert (DeviceExtension->BytesPerCluster != 0);
|
|
|
|
assert (StandardInfo != NULL);
|
|
|
|
assert (FCB != NULL);
|
1999-12-11 21:14:49 +00:00
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
RtlZeroMemory (StandardInfo, sizeof (FILE_STANDARD_INFORMATION));
|
1999-12-11 21:14:49 +00:00
|
|
|
|
|
|
|
/* Make allocsize a rounded up multiple of BytesPerCluster */
|
2000-12-29 23:17:12 +00:00
|
|
|
AllocSize = ((FCB->entry.FileSize + DeviceExtension->BytesPerCluster - 1) /
|
|
|
|
DeviceExtension->BytesPerCluster) *
|
|
|
|
DeviceExtension->BytesPerCluster;
|
|
|
|
|
|
|
|
StandardInfo->AllocationSize = RtlConvertUlongToLargeInteger (AllocSize);
|
|
|
|
StandardInfo->EndOfFile =
|
|
|
|
RtlConvertUlongToLargeInteger (FCB->entry.FileSize);
|
|
|
|
StandardInfo->NumberOfLinks = 0;
|
|
|
|
StandardInfo->DeletePending = FALSE;
|
|
|
|
if ((FCB->entry.Attrib & 0x10) > 0)
|
|
|
|
{
|
|
|
|
StandardInfo->Directory = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
StandardInfo->Directory = FALSE;
|
|
|
|
}
|
1999-12-11 21:14:49 +00:00
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatSetPositionInformation (PFILE_OBJECT FileObject,
|
|
|
|
PVFATFCB FCB,
|
|
|
|
PDEVICE_OBJECT DeviceObject,
|
|
|
|
PFILE_POSITION_INFORMATION PositionInfo)
|
1999-12-11 21:14:49 +00:00
|
|
|
{
|
2000-12-29 23:17:12 +00:00
|
|
|
DPRINT ("FsdSetPositionInformation()\n");
|
1999-12-11 21:14:49 +00:00
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
DPRINT ("PositionInfo %x\n", PositionInfo);
|
|
|
|
DPRINT ("Setting position %d\n", PositionInfo->CurrentByteOffset.u.LowPart);
|
|
|
|
memcpy (&FileObject->CurrentByteOffset, &PositionInfo->CurrentByteOffset,
|
|
|
|
sizeof (LARGE_INTEGER));
|
1999-12-11 21:14:49 +00:00
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
return (STATUS_SUCCESS);
|
|
|
|
}
|
1999-12-11 21:14:49 +00:00
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatGetPositionInformation (PFILE_OBJECT FileObject,
|
|
|
|
PVFATFCB FCB,
|
|
|
|
PDEVICE_OBJECT DeviceObject,
|
|
|
|
PFILE_POSITION_INFORMATION PositionInfo)
|
|
|
|
{
|
|
|
|
DPRINT ("VfatGetPositionInformation()\n");
|
1999-12-11 21:14:49 +00:00
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
memcpy (&PositionInfo->CurrentByteOffset, &FileObject->CurrentByteOffset,
|
|
|
|
sizeof (LARGE_INTEGER));
|
|
|
|
DPRINT ("Getting position %x\n", PositionInfo->CurrentByteOffset.u.LowPart);
|
|
|
|
return (STATUS_SUCCESS);
|
1999-12-11 21:14:49 +00:00
|
|
|
}
|
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
NTSTATUS
|
|
|
|
VfatGetBasicInformation (PFILE_OBJECT FileObject,
|
|
|
|
PVFATFCB FCB,
|
|
|
|
PDEVICE_OBJECT DeviceObject,
|
|
|
|
PFILE_BASIC_INFORMATION BasicInfo)
|
|
|
|
{
|
|
|
|
DPRINT ("VfatGetBasicInformation()\n");
|
|
|
|
|
|
|
|
FsdDosDateTimeToFileTime (FCB->entry.CreationDate, FCB->entry.CreationTime,
|
|
|
|
&BasicInfo->CreationTime);
|
|
|
|
FsdDosDateTimeToFileTime (FCB->entry.AccessDate, 0,
|
|
|
|
&BasicInfo->LastAccessTime);
|
|
|
|
FsdDosDateTimeToFileTime (FCB->entry.UpdateDate, FCB->entry.UpdateTime,
|
|
|
|
&BasicInfo->LastWriteTime);
|
|
|
|
FsdDosDateTimeToFileTime (FCB->entry.UpdateDate, FCB->entry.UpdateTime,
|
|
|
|
&BasicInfo->ChangeTime);
|
|
|
|
|
|
|
|
BasicInfo->FileAttributes = FCB->entry.Attrib;
|
|
|
|
|
|
|
|
DPRINT ("Getting attributes %x\n", BasicInfo->FileAttributes);
|
1999-12-11 21:14:49 +00:00
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
return (STATUS_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
VfatSetDispositionInformation (PFILE_OBJECT FileObject,
|
|
|
|
PVFATFCB FCB,
|
|
|
|
PDEVICE_OBJECT DeviceObject,
|
|
|
|
PFILE_DISPOSITION_INFORMATION DispositionInfo)
|
1999-12-11 21:14:49 +00:00
|
|
|
{
|
2000-12-29 23:17:12 +00:00
|
|
|
DPRINT ("FsdSetDispositionInformation()\n");
|
1999-12-11 21:14:49 +00:00
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
FileObject->DeletePending = DispositionInfo->DoDeleteFile;
|
|
|
|
|
|
|
|
return (STATUS_SUCCESS);
|
1999-12-11 21:14:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
NTSTATUS STDCALL
|
|
|
|
VfatQueryInformation (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
1999-12-11 21:14:49 +00:00
|
|
|
/*
|
|
|
|
* FUNCTION: Retrieve the specified file information
|
|
|
|
*/
|
|
|
|
{
|
2000-12-29 23:17:12 +00:00
|
|
|
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation (Irp);
|
|
|
|
FILE_INFORMATION_CLASS FileInformationClass =
|
|
|
|
Stack->Parameters.QueryFile.FileInformationClass;
|
|
|
|
PFILE_OBJECT FileObject = NULL;
|
|
|
|
PVFATFCB FCB = NULL;
|
1999-12-11 21:14:49 +00:00
|
|
|
// PVFATCCB CCB = NULL;
|
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
NTSTATUS RC = STATUS_SUCCESS;
|
|
|
|
void *SystemBuffer;
|
1999-12-11 21:14:49 +00:00
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
/* PRECONDITION */
|
|
|
|
assert (DeviceObject != NULL);
|
|
|
|
assert (Irp != NULL);
|
1999-12-11 21:14:49 +00:00
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
/* INITIALIZATION */
|
|
|
|
Stack = IoGetCurrentIrpStackLocation (Irp);
|
|
|
|
FileInformationClass = Stack->Parameters.QueryFile.FileInformationClass;
|
|
|
|
FileObject = Stack->FileObject;
|
1999-12-11 21:14:49 +00:00
|
|
|
// CCB = (PVFATCCB)(FileObject->FsContext2);
|
|
|
|
// FCB = CCB->Buffer; // Should be CCB->FCB???
|
2000-12-29 23:17:12 +00:00
|
|
|
FCB = ((PVFATCCB) (FileObject->FsContext2))->pFcb;
|
1999-12-11 21:14:49 +00:00
|
|
|
|
|
|
|
// FIXME : determine Buffer for result :
|
2000-12-29 23:17:12 +00:00
|
|
|
if (Irp->MdlAddress)
|
|
|
|
SystemBuffer = MmGetSystemAddressForMdl (Irp->MdlAddress);
|
1999-12-11 21:14:49 +00:00
|
|
|
else
|
|
|
|
SystemBuffer = Irp->UserBuffer;
|
|
|
|
// SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
|
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
switch (FileInformationClass)
|
|
|
|
{
|
|
|
|
case FileStandardInformation:
|
|
|
|
RC = VfatGetStandardInformation (FCB, DeviceObject, SystemBuffer);
|
1999-12-11 21:14:49 +00:00
|
|
|
break;
|
2000-12-29 23:17:12 +00:00
|
|
|
case FilePositionInformation:
|
|
|
|
RC = VfatGetPositionInformation (FileObject,
|
|
|
|
FCB, DeviceObject, SystemBuffer);
|
1999-12-11 21:14:49 +00:00
|
|
|
break;
|
2000-12-29 23:17:12 +00:00
|
|
|
case FileBasicInformation:
|
|
|
|
RC = VfatGetBasicInformation (FileObject,
|
|
|
|
FCB, DeviceObject, SystemBuffer);
|
1999-12-11 21:14:49 +00:00
|
|
|
break;
|
2000-12-29 23:17:12 +00:00
|
|
|
default:
|
|
|
|
RC = STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
1999-12-11 21:14:49 +00:00
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
Irp->IoStatus.Status = RC;
|
|
|
|
Irp->IoStatus.Information = 0;
|
|
|
|
IoCompleteRequest (Irp, IO_NO_INCREMENT);
|
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
|
|
|
}
|
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
NTSTATUS STDCALL
|
|
|
|
VfatSetInformation (PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
1999-12-11 21:14:49 +00:00
|
|
|
/*
|
|
|
|
* FUNCTION: Retrieve the specified file information
|
|
|
|
*/
|
|
|
|
{
|
2000-12-29 23:17:12 +00:00
|
|
|
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation (Irp);
|
|
|
|
FILE_INFORMATION_CLASS FileInformationClass;
|
|
|
|
PFILE_OBJECT FileObject = NULL;
|
|
|
|
PVFATFCB FCB = NULL;
|
1999-12-11 21:14:49 +00:00
|
|
|
// PVFATCCB CCB = NULL;
|
2000-12-29 23:17:12 +00:00
|
|
|
NTSTATUS RC = STATUS_SUCCESS;
|
|
|
|
PVOID SystemBuffer;
|
1999-12-11 21:14:49 +00:00
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
/* PRECONDITION */
|
|
|
|
assert (DeviceObject != NULL);
|
|
|
|
assert (Irp != NULL);
|
|
|
|
|
|
|
|
DPRINT ("VfatSetInformation(DeviceObject %x, Irp %x)\n", DeviceObject, Irp);
|
|
|
|
|
|
|
|
/* INITIALIZATION */
|
|
|
|
Stack = IoGetCurrentIrpStackLocation (Irp);
|
|
|
|
FileInformationClass = Stack->Parameters.SetFile.FileInformationClass;
|
|
|
|
FileObject = Stack->FileObject;
|
|
|
|
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 FilePositionInformation:
|
|
|
|
RC = VfatSetPositionInformation (FileObject,
|
|
|
|
FCB, DeviceObject, SystemBuffer);
|
|
|
|
break;
|
|
|
|
case FileDispositionInformation:
|
|
|
|
RC = VfatSetDispositionInformation (FileObject,
|
|
|
|
FCB, DeviceObject, SystemBuffer);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
RC = STATUS_NOT_IMPLEMENTED;
|
|
|
|
}
|
1999-12-11 21:14:49 +00:00
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
Irp->IoStatus.Status = RC;
|
|
|
|
Irp->IoStatus.Information = 0;
|
|
|
|
IoCompleteRequest (Irp, IO_NO_INCREMENT);
|
1999-12-11 21:14:49 +00:00
|
|
|
|
2000-12-29 23:17:12 +00:00
|
|
|
return RC;
|
|
|
|
}
|