2002-08-14 20:58:39 +00:00
|
|
|
/*
|
|
|
|
* ReactOS kernel
|
|
|
|
* Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
2009-10-27 10:34:16 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2002-08-14 20:58:39 +00:00
|
|
|
*/
|
2005-08-24 18:29:45 +00:00
|
|
|
/*
|
1998-10-05 04:00:59 +00:00
|
|
|
* PROJECT: ReactOS kernel
|
2003-10-11 17:51:56 +00:00
|
|
|
* FILE: drivers/fs/vfat/iface.c
|
1998-10-05 04:00:59 +00:00
|
|
|
* PURPOSE: VFAT Filesystem
|
|
|
|
* PROGRAMMER: Jason Filby (jasonfilby@yahoo.com)
|
1999-12-11 21:14:49 +00:00
|
|
|
*/
|
1998-12-20 19:41:39 +00:00
|
|
|
|
1999-12-11 21:14:49 +00:00
|
|
|
/* INCLUDES *****************************************************************/
|
1998-12-20 19:41:39 +00:00
|
|
|
|
1999-12-11 21:14:49 +00:00
|
|
|
#define NDEBUG
|
|
|
|
#include "vfat.h"
|
1998-12-20 19:41:39 +00:00
|
|
|
|
1999-12-11 21:14:49 +00:00
|
|
|
/* GLOBALS *****************************************************************/
|
1998-10-05 04:00:59 +00:00
|
|
|
|
2002-03-18 22:37:13 +00:00
|
|
|
PVFAT_GLOBAL_DATA VfatGlobalData;
|
1998-10-05 04:00:59 +00:00
|
|
|
|
1999-12-11 21:14:49 +00:00
|
|
|
/* FUNCTIONS ****************************************************************/
|
1999-06-27 23:06:50 +00:00
|
|
|
|
2005-10-03 07:15:12 +00:00
|
|
|
NTSTATUS NTAPI
|
2002-03-18 22:37:13 +00:00
|
|
|
DriverEntry(PDRIVER_OBJECT DriverObject,
|
2001-06-11 19:52:22 +00:00
|
|
|
PUNICODE_STRING RegistryPath)
|
1998-10-05 04:00:59 +00:00
|
|
|
/*
|
2005-01-12 10:46:13 +00:00
|
|
|
* FUNCTION: Called by the system to initialize the driver
|
1998-10-05 04:00:59 +00:00
|
|
|
* ARGUMENTS:
|
|
|
|
* DriverObject = object describing this driver
|
|
|
|
* RegistryPath = path to our configuration entries
|
|
|
|
* RETURNS: Success or failure
|
|
|
|
*/
|
|
|
|
{
|
2001-03-06 08:19:58 +00:00
|
|
|
PDEVICE_OBJECT DeviceObject;
|
2005-01-12 12:33:57 +00:00
|
|
|
UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Fat");
|
2001-03-06 08:19:58 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
|
2013-05-11 11:03:12 +00:00
|
|
|
UNREFERENCED_PARAMETER(RegistryPath);
|
|
|
|
|
2002-03-18 22:37:13 +00:00
|
|
|
Status = IoCreateDevice(DriverObject,
|
|
|
|
sizeof(VFAT_GLOBAL_DATA),
|
2001-03-06 08:19:58 +00:00
|
|
|
&DeviceName,
|
2002-03-18 22:37:13 +00:00
|
|
|
FILE_DEVICE_DISK_FILE_SYSTEM,
|
2001-03-06 08:19:58 +00:00
|
|
|
0,
|
|
|
|
FALSE,
|
|
|
|
&DeviceObject);
|
2008-05-11 19:47:50 +00:00
|
|
|
|
|
|
|
if (Status == STATUS_OBJECT_NAME_EXISTS ||
|
|
|
|
Status == STATUS_OBJECT_NAME_COLLISION)
|
|
|
|
{
|
|
|
|
/* Try an other name, if 'Fat' is already in use. 'Fat' is also used by fastfat.sys on W2K */
|
|
|
|
RtlInitUnicodeString(&DeviceName, L"\\RosFat");
|
|
|
|
Status = IoCreateDevice(DriverObject,
|
|
|
|
sizeof(VFAT_GLOBAL_DATA),
|
|
|
|
&DeviceName,
|
|
|
|
FILE_DEVICE_DISK_FILE_SYSTEM,
|
|
|
|
0,
|
|
|
|
FALSE,
|
|
|
|
&DeviceObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-03-06 08:19:58 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2008-05-11 19:47:50 +00:00
|
|
|
return (Status);
|
2001-03-06 08:19:58 +00:00
|
|
|
}
|
2008-05-11 19:47:50 +00:00
|
|
|
|
2002-03-18 22:37:13 +00:00
|
|
|
VfatGlobalData = DeviceObject->DeviceExtension;
|
|
|
|
RtlZeroMemory (VfatGlobalData, sizeof(VFAT_GLOBAL_DATA));
|
|
|
|
VfatGlobalData->DriverObject = DriverObject;
|
|
|
|
VfatGlobalData->DeviceObject = DeviceObject;
|
2001-03-06 08:19:58 +00:00
|
|
|
|
2005-08-24 18:29:45 +00:00
|
|
|
DeviceObject->Flags |= DO_DIRECT_IO;
|
2004-02-10 16:22:57 +00:00
|
|
|
DriverObject->MajorFunction[IRP_MJ_CLOSE] = VfatBuildRequest;
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_CREATE] = VfatBuildRequest;
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_READ] = VfatBuildRequest;
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_WRITE] = VfatBuildRequest;
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] = VfatBuildRequest;
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] = VfatBuildRequest;
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_SET_INFORMATION] = VfatBuildRequest;
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] = VfatBuildRequest;
|
2005-05-08 02:16:32 +00:00
|
|
|
DriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] =
|
2004-02-10 16:22:57 +00:00
|
|
|
VfatBuildRequest;
|
2005-05-08 02:16:32 +00:00
|
|
|
DriverObject->MajorFunction[IRP_MJ_SET_VOLUME_INFORMATION] =
|
2004-02-10 16:22:57 +00:00
|
|
|
VfatBuildRequest;
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_SHUTDOWN] = VfatShutdown;
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_LOCK_CONTROL] = VfatBuildRequest;
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = VfatBuildRequest;
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = VfatBuildRequest;
|
[FASTFAT]
Make our FAT driver PNP aware.
On PNP requests it should handle, it will return STATUS_NOT_IMPLEMENTED.
On the others, it will pass them to lower driver.
This is the first step outside the kernel into getting IoGetRelatedTargetDevice (and so notifications) working.
It doesn't work at the moment, as class2 doesn't handle PNP.
[NTOSKRNL]
Some fixes to IRP cancelation process:
- Renamed IopRemoveThreadIrp() to IopDisassociateThreadIrp() to match Windows 2k3
- Made dead IRP global, to make its debug easier.
- IopDisassociateThreadIrp(), Handle dead IRP at dispatch level, using IoCompletionLock.
- IopDisassociateThreadIrp(), Use the proper error code to write the entry to logs.
- IoCancelIrp(), removed non needed ASSERT, which is even not present on Windows, removed corresponding var as well.
- IoCancelIrp(), fixed parameters to KeBugCheckEx() call.
- IoCancelThreadIo() is pageable.
- IoCancelThreadIo() under Windows isn't using given thread, but using current. Do the same here.
All that stuff doesn't fix bug #5550, it comes from outside.
Patch by Pierre Schweitzer, modified by me to make it compile. If it breaks anything, don't blame me!
svn path=/trunk/; revision=48560
2010-08-18 23:21:15 +00:00
|
|
|
DriverObject->MajorFunction[IRP_MJ_PNP] = VfatBuildRequest;
|
2002-03-18 22:37:13 +00:00
|
|
|
|
|
|
|
DriverObject->DriverUnload = NULL;
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2005-01-12 13:00:43 +00:00
|
|
|
/* Cache manager */
|
|
|
|
VfatGlobalData->CacheMgrCallbacks.AcquireForLazyWrite = VfatAcquireForLazyWrite;
|
|
|
|
VfatGlobalData->CacheMgrCallbacks.ReleaseFromLazyWrite = VfatReleaseFromLazyWrite;
|
|
|
|
VfatGlobalData->CacheMgrCallbacks.AcquireForReadAhead = VfatAcquireForReadAhead;
|
|
|
|
VfatGlobalData->CacheMgrCallbacks.ReleaseFromReadAhead = VfatReleaseFromReadAhead;
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2005-01-12 13:00:43 +00:00
|
|
|
/* Fast I/O */
|
2005-01-25 21:12:52 +00:00
|
|
|
VfatInitFastIoRoutines(&VfatGlobalData->FastIoDispatch);
|
|
|
|
DriverObject->FastIoDispatch = &VfatGlobalData->FastIoDispatch;
|
2001-03-06 08:19:58 +00:00
|
|
|
|
2005-01-12 13:00:43 +00:00
|
|
|
/* Private lists */
|
2005-05-08 02:16:32 +00:00
|
|
|
ExInitializeNPagedLookasideList(&VfatGlobalData->FcbLookasideList,
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
NULL, NULL, 0, sizeof(VFATFCB), TAG_FCB, 0);
|
2005-05-08 02:16:32 +00:00
|
|
|
ExInitializeNPagedLookasideList(&VfatGlobalData->CcbLookasideList,
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
NULL, NULL, 0, sizeof(VFATCCB), TAG_CCB, 0);
|
2005-05-08 02:16:32 +00:00
|
|
|
ExInitializeNPagedLookasideList(&VfatGlobalData->IrpContextLookasideList,
|
* Used look aside lists to allocate memory for VFATFCB, VFATCCB and VFAT_IRP_CONTEXT.
* Removed IsLastEntry, IsVolEntry, IsDeletedEntry, vfat_wstrlen, vfatGrabFCB,
vfat_initstr, vfat_wcsncat, vfat_wcsncpy, vfat_movestr, wstrcmpi and replaced
this functions with existing equivalents or functions from ntoskrnl.
* Merged GetEntryName into vfatGetNextDirEntry for reducing some overhead.
* Implemented a file name cache to speed up the searching for existing fcb.
* Removed some calls to FsdDosDateTimeToFileTime.
* Moved the call to CcZeroData behind the initializing of the cache (in VfatWrite).
* Using existing fcbs in FindFile if there is no '*?' within the search name.
svn path=/trunk/; revision=3740
2002-11-11 21:49:18 +00:00
|
|
|
NULL, NULL, 0, sizeof(VFAT_IRP_CONTEXT), TAG_IRP, 0);
|
2003-02-09 18:02:56 +00:00
|
|
|
|
|
|
|
ExInitializeResourceLite(&VfatGlobalData->VolumeListLock);
|
|
|
|
InitializeListHead(&VfatGlobalData->VolumeListHead);
|
2001-03-06 08:19:58 +00:00
|
|
|
IoRegisterFileSystem(DeviceObject);
|
2002-08-14 20:58:39 +00:00
|
|
|
return(STATUS_SUCCESS);
|
1998-10-05 04:00:59 +00:00
|
|
|
}
|
2001-03-06 08:19:58 +00:00
|
|
|
|
|
|
|
/* EOF */
|
2002-03-18 22:37:13 +00:00
|
|
|
|