[FORMATTING] - Cleanup formatting before starting to work on the file.

svn path=/trunk/; revision=22749
This commit is contained in:
Alex Ionescu 2006-07-01 22:47:52 +00:00
parent 3ea25ef417
commit e7423e0ba3
2 changed files with 422 additions and 498 deletions

View file

@ -556,7 +556,8 @@ IopStartDevice(
);
NTSTATUS
IoMountVolume(
NTAPI
IopMountVolume(
IN PDEVICE_OBJECT DeviceObject,
IN BOOLEAN AllowRawMount
);
@ -573,17 +574,19 @@ IoOpenFileOnDevice(
);
NTSTATUS
STDCALL
NTAPI
IopAttachVpb(
IN PDEVICE_OBJECT DeviceObject
);
VOID
NTAPI
IoInitFileSystemImplementation(
VOID
);
VOID
NTAPI
IoInitVpbImplementation(
VOID
);
@ -609,6 +612,7 @@ IoShutdownRegisteredDevices(
);
VOID
NTAPI
IoShutdownRegisteredFileSystems(
VOID
);

View file

@ -1,11 +1,11 @@
/* $Id$
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/io/fs.c
* PURPOSE: Filesystem functions
*
* PROGRAMMERS: David Welch (welch@mcmail.com)
/*
* PROJECT: ReactOS Kernel
* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/io/iomgr/volume.c
* PURPOSE: Volume and File System I/O Support
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
* Hervé Poussineau (hpoussin@reactos.org)
* Eric Kohl
*/
/* INCLUDES *****************************************************************/
@ -39,28 +39,37 @@ typedef struct _FS_CHANGE_NOTIFY_ENTRY
/* GLOBALS ******************************************************************/
static ERESOURCE FileSystemListLock;
static LIST_ENTRY FileSystemListHead;
ERESOURCE FileSystemListLock;
LIST_ENTRY FileSystemListHead;
KGUARDED_MUTEX FsChangeNotifyListLock;
LIST_ENTRY FsChangeNotifyListHead;
KSPIN_LOCK IoVpbLock;
static KGUARDED_MUTEX FsChangeNotifyListLock;
static LIST_ENTRY FsChangeNotifyListHead;
/* PRIVATE FUNCTIONS *********************************************************/
static VOID
IopNotifyFileSystemChange(PDEVICE_OBJECT DeviceObject,
BOOLEAN DriverActive);
static KSPIN_LOCK IoVpbLock;
/* FUNCTIONS *****************************************************************/
VOID INIT_FUNCTION
VOID
INIT_FUNCTION
NTAPI
IoInitVpbImplementation(VOID)
{
KeInitializeSpinLock(&IoVpbLock);
}
VOID
INIT_FUNCTION
NTAPI
IoInitFileSystemImplementation(VOID)
{
InitializeListHead(&FileSystemListHead);
ExInitializeResourceLite(&FileSystemListLock);
InitializeListHead(&FsChangeNotifyListHead);
KeInitializeGuardedMutex(&FsChangeNotifyListLock);
}
NTSTATUS
STDCALL
IopAttachVpb(PDEVICE_OBJECT DeviceObject)
IopAttachVpb(IN PDEVICE_OBJECT DeviceObject)
{
PVPB Vpb;
@ -68,7 +77,7 @@ IopAttachVpb(PDEVICE_OBJECT DeviceObject)
Vpb = ExAllocatePoolWithTag(NonPagedPool,
sizeof(VPB),
TAG_VPB);
if (Vpb == NULL) return(STATUS_UNSUCCESSFUL);
if (!Vpb) return(STATUS_UNSUCCESSFUL);
/* Clear it so we don't waste time manually */
RtlZeroMemory(Vpb, sizeof(VPB));
@ -83,18 +92,23 @@ IopAttachVpb(PDEVICE_OBJECT DeviceObject)
return(STATUS_SUCCESS);
}
VOID INIT_FUNCTION
IoInitFileSystemImplementation(VOID)
VOID
NTAPI
IopNotifyFileSystemChange(IN PDEVICE_OBJECT DeviceObject,
IN BOOLEAN DriverActive)
{
InitializeListHead(&FileSystemListHead);
ExInitializeResourceLite(&FileSystemListLock);
PFS_CHANGE_NOTIFY_ENTRY ChangeEntry;
InitializeListHead(&FsChangeNotifyListHead);
KeInitializeGuardedMutex(&FsChangeNotifyListLock);
KeAcquireGuardedMutex(&FsChangeNotifyListLock);
LIST_FOR_EACH(ChangeEntry, &FsChangeNotifyListHead,FS_CHANGE_NOTIFY_ENTRY, FsChangeNotifyList)
{
(ChangeEntry->FSDNotificationProc)(DeviceObject, DriverActive);
}
KeReleaseGuardedMutex(&FsChangeNotifyListLock);
}
VOID
NTAPI
IoShutdownRegisteredFileSystems(VOID)
{
FILE_SYSTEM_OBJECT* current;
@ -103,13 +117,9 @@ IoShutdownRegisteredFileSystems(VOID)
IO_STATUS_BLOCK IoStatusBlock;
NTSTATUS Status;
DPRINT("IoShutdownRegisteredFileSystems()\n");
KeEnterCriticalRegion();
ExAcquireResourceSharedLite(&FileSystemListLock,TRUE);
KeInitializeEvent(&Event,
NotificationEvent,
FALSE);
KeInitializeEvent(&Event, NotificationEvent, FALSE);
LIST_FOR_EACH(current, &FileSystemListHead, FILE_SYSTEM_OBJECT,Entry)
{
@ -137,20 +147,16 @@ IoShutdownRegisteredFileSystems(VOID)
KeLeaveCriticalRegion();
}
static NTSTATUS
IopMountFileSystem(PDEVICE_OBJECT DeviceObject,
PDEVICE_OBJECT DeviceToMount)
NTSTATUS
NTAPI
IopMountFileSystem(IN PDEVICE_OBJECT DeviceObject,
IN PDEVICE_OBJECT DeviceToMount)
{
IO_STATUS_BLOCK IoStatusBlock;
PIO_STACK_LOCATION StackPtr;
KEVENT Event;
PIRP Irp;
NTSTATUS Status;
DPRINT("IopMountFileSystem(DeviceObject 0x%p, DeviceToMount 0x%p)\n",
DeviceObject,DeviceToMount);
ASSERT_IRQL(PASSIVE_LEVEL);
KeInitializeEvent(&Event, NotificationEvent, FALSE);
@ -187,8 +193,8 @@ IopMountFileSystem(PDEVICE_OBJECT DeviceObject,
return(Status);
}
static NTSTATUS
NTSTATUS
NTAPI
IopLoadFileSystem(IN PDEVICE_OBJECT DeviceObject)
{
IO_STATUS_BLOCK IoStatusBlock;
@ -196,9 +202,6 @@ IopLoadFileSystem(IN PDEVICE_OBJECT DeviceObject)
KEVENT Event;
PIRP Irp;
NTSTATUS Status;
DPRINT("IopLoadFileSystem(DeviceObject 0x%p)\n", DeviceObject);
ASSERT_IRQL(PASSIVE_LEVEL);
KeInitializeEvent(&Event, NotificationEvent, FALSE);
@ -209,7 +212,6 @@ IopLoadFileSystem(IN PDEVICE_OBJECT DeviceObject)
}
Irp->UserIosb = &IoStatusBlock;
DPRINT("Irp->UserIosb 0x%p\n", Irp->UserIosb);
Irp->UserEvent = &Event;
Irp->Tail.Overlay.Thread = PsGetCurrentThread();
@ -232,27 +234,17 @@ IopLoadFileSystem(IN PDEVICE_OBJECT DeviceObject)
return(Status);
}
NTSTATUS
IoMountVolume(IN PDEVICE_OBJECT DeviceObject,
NTAPI
IopMountVolume(IN PDEVICE_OBJECT DeviceObject,
IN BOOLEAN AllowRawMount)
/*
* FUNCTION: Mounts a logical volume
* ARGUMENTS:
* DeviceObject = Device to mount
* RETURNS: Status
*/
{
PFILE_SYSTEM_OBJECT current;
NTSTATUS Status;
DEVICE_TYPE MatchingDeviceType;
PDEVICE_OBJECT DevObject;
ASSERT_IRQL(PASSIVE_LEVEL);
DPRINT("IoMountVolume(DeviceObject 0x%p AllowRawMount %x)\n",
DeviceObject, AllowRawMount);
switch (DeviceObject->DeviceType)
{
case FILE_DEVICE_DISK:
@ -288,6 +280,7 @@ restart:
{
continue;
}
/* If we are not allowed to mount this volume as a raw filesystem volume
then don't try this */
if (!AllowRawMount && RawFsIsRawFileSystemDeviceObject(current->DeviceObject))
@ -296,9 +289,9 @@ restart:
}
else
{
Status = IopMountFileSystem(current->DeviceObject,
DeviceObject);
Status = IopMountFileSystem(current->DeviceObject, DeviceObject);
}
switch (Status)
{
case STATUS_FS_DRIVER_REQUIRED:
@ -326,34 +319,19 @@ restart:
break;
}
}
ExReleaseResourceLite(&FileSystemListLock);
KeLeaveCriticalRegion();
return(STATUS_UNRECOGNIZED_VOLUME);
}
/* PUBLIC FUNCTIONS **********************************************************/
/**********************************************************************
* NAME EXPORTED
* IoVerifyVolume
*
* DESCRIPTION
* Verify the file system type and volume information or mount
* a file system.
*
* ARGUMENTS
* DeviceObject
* Device to verify or mount
*
* AllowRawMount
* ...
*
* RETURN VALUE
* Status
*
/*
* @implemented
*/
NTSTATUS STDCALL
NTSTATUS
NTAPI
IoVerifyVolume(IN PDEVICE_OBJECT DeviceObject,
IN BOOLEAN AllowRawMount)
{
@ -361,14 +339,9 @@ IoVerifyVolume(IN PDEVICE_OBJECT DeviceObject,
PIO_STACK_LOCATION StackPtr;
KEVENT Event;
PIRP Irp;
NTSTATUS Status;
NTSTATUS Status = STATUS_SUCCESS;
PDEVICE_OBJECT DevObject;
DPRINT("IoVerifyVolume(DeviceObject 0x%p AllowRawMount %x)\n",
DeviceObject, AllowRawMount);
Status = STATUS_SUCCESS;
KeWaitForSingleObject(&DeviceObject->DeviceLock,
Executive,
KernelMode,
@ -380,9 +353,7 @@ IoVerifyVolume(IN PDEVICE_OBJECT DeviceObject,
/* Issue verify request to the FSD */
DevObject = DeviceObject->Vpb->DeviceObject;
KeInitializeEvent(&Event,
NotificationEvent,
FALSE);
KeInitializeEvent(&Event, NotificationEvent, FALSE);
Irp = IoAllocateIrp(DevObject->StackSize, TRUE);
if (Irp==NULL)
@ -406,8 +377,7 @@ IoVerifyVolume(IN PDEVICE_OBJECT DeviceObject,
StackPtr->Parameters.VerifyVolume.Vpb = DeviceObject->Vpb;
StackPtr->Parameters.VerifyVolume.DeviceObject = DeviceObject;
Status = IoCallDriver(DevObject,
Irp);
Status = IoCallDriver(DevObject, Irp);
if (Status==STATUS_PENDING)
{
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
@ -416,9 +386,7 @@ IoVerifyVolume(IN PDEVICE_OBJECT DeviceObject,
if (NT_SUCCESS(Status))
{
KeSetEvent(&DeviceObject->DeviceLock,
IO_NO_INCREMENT,
FALSE);
KeSetEvent(&DeviceObject->DeviceLock, IO_NO_INCREMENT, FALSE);
return(STATUS_SUCCESS);
}
}
@ -433,29 +401,21 @@ IoVerifyVolume(IN PDEVICE_OBJECT DeviceObject,
}
/* Start mount sequence */
Status = IoMountVolume(DeviceObject,
AllowRawMount);
KeSetEvent(&DeviceObject->DeviceLock,
IO_NO_INCREMENT,
FALSE);
Status = IopMountVolume(DeviceObject, AllowRawMount);
KeSetEvent(&DeviceObject->DeviceLock, IO_NO_INCREMENT, FALSE);
return(Status);
}
/*
* @implemented
*/
VOID STDCALL
VOID
NTAPI
IoRegisterFileSystem(IN PDEVICE_OBJECT DeviceObject)
{
PFILE_SYSTEM_OBJECT Fs;
DPRINT("IoRegisterFileSystem(DeviceObject 0x%p)\n", DeviceObject);
Fs = ExAllocatePoolWithTag(NonPagedPool,
sizeof(FILE_SYSTEM_OBJECT),
TAG_FILE_SYSTEM);
@ -470,27 +430,23 @@ IoRegisterFileSystem(IN PDEVICE_OBJECT DeviceObject)
a volume. It is always the first filesystem driver registered so
we use InsertHeadList() here as opposed to the other alternative
InsertTailList(). */
InsertHeadList(&FileSystemListHead,
&Fs->Entry);
InsertHeadList(&FileSystemListHead, &Fs->Entry);
ExReleaseResourceLite(&FileSystemListLock);
KeLeaveCriticalRegion();
IopNotifyFileSystemChange(DeviceObject,
TRUE);
IopNotifyFileSystemChange(DeviceObject, TRUE);
}
/*
* @implemented
*/
VOID STDCALL
VOID
NTAPI
IoUnregisterFileSystem(IN PDEVICE_OBJECT DeviceObject)
{
PFILE_SYSTEM_OBJECT current;
DPRINT("IoUnregisterFileSystem(DeviceObject 0x%p)\n", DeviceObject);
KeEnterCriticalRegion();
ExAcquireResourceExclusiveLite(&FileSystemListLock, TRUE);
@ -511,26 +467,11 @@ IoUnregisterFileSystem(IN PDEVICE_OBJECT DeviceObject)
KeLeaveCriticalRegion();
}
/**********************************************************************
* NAME EXPORTED
* IoGetBaseFileSystemDeviceObject@4
*
* DESCRIPTION
* Get the DEVICE_OBJECT associated to
* a FILE_OBJECT.
*
* ARGUMENTS
* FileObject
*
* RETURN VALUE
*
* NOTE
* From Bo Branten's ntifs.h v13.
*
/*
* @implemented
*/
PDEVICE_OBJECT STDCALL
PDEVICE_OBJECT
NTAPI
IoGetBaseFileSystemDeviceObject(IN PFILE_OBJECT FileObject)
{
PDEVICE_OBJECT DeviceObject = NULL;
@ -548,6 +489,7 @@ IoGetBaseFileSystemDeviceObject(IN PFILE_OBJECT FileObject)
return DeviceObject;
}
}
/*
* If that failed, try the VPB
* in the FILE_OBJECT's DeviceObject.
@ -558,38 +500,20 @@ IoGetBaseFileSystemDeviceObject(IN PFILE_OBJECT FileObject)
/* DeviceObject->Vpb UNDEFINED! */
return DeviceObject;
}
/*
* If that pointer to the VPB is again
* undefined, return directly the
* device object from the FILE_OBJECT.
*/
return (
(NULL == Vpb->DeviceObject)
? DeviceObject
: Vpb->DeviceObject
);
return ((NULL == Vpb->DeviceObject) ? DeviceObject : Vpb->DeviceObject);
}
static VOID
IopNotifyFileSystemChange(PDEVICE_OBJECT DeviceObject,
BOOLEAN DriverActive)
{
PFS_CHANGE_NOTIFY_ENTRY ChangeEntry;
KeAcquireGuardedMutex(&FsChangeNotifyListLock);
LIST_FOR_EACH(ChangeEntry, &FsChangeNotifyListHead,FS_CHANGE_NOTIFY_ENTRY, FsChangeNotifyList)
{
(ChangeEntry->FSDNotificationProc)(DeviceObject, DriverActive);
}
KeReleaseGuardedMutex(&FsChangeNotifyListLock);
}
/*
* @implemented
*/
NTSTATUS STDCALL
NTSTATUS
NTAPI
IoRegisterFsRegistrationChange(IN PDRIVER_OBJECT DriverObject,
IN PDRIVER_FS_NOTIFICATION FSDNotificationProc)
{
@ -598,25 +522,23 @@ IoRegisterFsRegistrationChange(IN PDRIVER_OBJECT DriverObject,
Entry = ExAllocatePoolWithTag(NonPagedPool,
sizeof(FS_CHANGE_NOTIFY_ENTRY),
TAG_FS_CHANGE_NOTIFY);
if (Entry == NULL)
return(STATUS_INSUFFICIENT_RESOURCES);
if (Entry == NULL) return(STATUS_INSUFFICIENT_RESOURCES);
Entry->DriverObject = DriverObject;
Entry->FSDNotificationProc = FSDNotificationProc;
KeAcquireGuardedMutex(&FsChangeNotifyListLock);
InsertHeadList(&FsChangeNotifyListHead,
&Entry->FsChangeNotifyList);
InsertHeadList(&FsChangeNotifyListHead, &Entry->FsChangeNotifyList);
KeReleaseGuardedMutex(&FsChangeNotifyListLock);
return(STATUS_SUCCESS);
}
/*
* @implemented
*/
VOID STDCALL
VOID
NTAPI
IoUnregisterFsRegistrationChange(IN PDRIVER_OBJECT DriverObject,
IN PDRIVER_FS_NOTIFICATION FSDNotificationProc)
{
@ -634,29 +556,27 @@ IoUnregisterFsRegistrationChange(IN PDRIVER_OBJECT DriverObject,
ExFreePoolWithTag(ChangeEntry, TAG_FS_CHANGE_NOTIFY);
return;
}
}
}
/*
* @implemented
*/
VOID STDCALL
VOID
NTAPI
IoAcquireVpbSpinLock(OUT PKIRQL Irql)
{
KeAcquireSpinLock(&IoVpbLock,
Irql);
KeAcquireSpinLock(&IoVpbLock, Irql);
}
/*
* @implemented
*/
VOID STDCALL
VOID
NTAPI
IoReleaseVpbSpinLock(IN KIRQL Irql)
{
KeReleaseSpinLock(&IoVpbLock,
Irql);
KeReleaseSpinLock(&IoVpbLock, Irql);
}
/* EOF */