diff --git a/reactos/drivers/fs/vfat/fsctl.c b/reactos/drivers/fs/vfat/fsctl.c index 860402e80fd..8fceee18743 100644 --- a/reactos/drivers/fs/vfat/fsctl.c +++ b/reactos/drivers/fs/vfat/fsctl.c @@ -1,4 +1,4 @@ -/* $Id: fsctl.c,v 1.1 2002/03/18 22:37:13 hbirr Exp $ +/* $Id: fsctl.c,v 1.2 2002/04/10 09:58:45 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -202,7 +202,7 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext) goto ByeBye; } - Status = VfatHasFileSystem (IrpContext->Stack->Parameters.Mount.DeviceObject, &RecognizedFS, NULL); + Status = VfatHasFileSystem (IrpContext->Stack->Parameters.MountVolume.DeviceObject, &RecognizedFS, NULL); if (!NT_SUCCESS(Status)) { goto ByeBye; @@ -233,8 +233,8 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext) RtlZeroMemory(DeviceExt, sizeof(DEVICE_EXTENSION)); /* use same vpb as device disk */ - DeviceObject->Vpb = IrpContext->Stack->Parameters.Mount.DeviceObject->Vpb; - Status = VfatMountDevice(DeviceExt, IrpContext->Stack->Parameters.Mount.DeviceObject); + DeviceObject->Vpb = IrpContext->Stack->Parameters.MountVolume.DeviceObject->Vpb; + Status = VfatMountDevice(DeviceExt, IrpContext->Stack->Parameters.MountVolume.DeviceObject); if (!NT_SUCCESS(Status)) { /* FIXME: delete device object */ @@ -254,7 +254,7 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext) } #endif DeviceObject->Vpb->Flags |= VPB_MOUNTED; - DeviceExt->StorageDevice = IoAttachDeviceToDeviceStack(DeviceObject, IrpContext->Stack->Parameters.Mount.DeviceObject); + DeviceExt->StorageDevice = IoAttachDeviceToDeviceStack(DeviceObject, IrpContext->Stack->Parameters.MountVolume.DeviceObject); DeviceExt->FATFileObject = IoCreateStreamFileObject(NULL, DeviceExt->StorageDevice); Fcb = vfatNewFCB(NULL); @@ -334,6 +334,21 @@ ByeBye: return Status; } + +static NTSTATUS +VfatVerify (PVFAT_IRP_CONTEXT IrpContext) +/* + * FUNCTION: Mount the filesystem + */ +{ + DPRINT("VfatVerify(IrpContext %x)\n", IrpContext); + + assert(IrpContext); + + return(STATUS_INVALID_DEVICE_REQUEST); +} + + NTSTATUS VfatFileSystemControl(PVFAT_IRP_CONTEXT IrpContext) /* * FUNCTION: File system control @@ -358,8 +373,7 @@ NTSTATUS VfatFileSystemControl(PVFAT_IRP_CONTEXT IrpContext) break; case IRP_MN_VERIFY_VOLUME: - DPRINT("VFAT FSC: IRP_MN_VERIFY_VOLUME\n"); - Status = STATUS_INVALID_DEVICE_REQUEST; + Status = VfatVerify(IrpContext); break; default: diff --git a/reactos/include/ddk/iofuncs.h b/reactos/include/ddk/iofuncs.h index de382f22a80..97826383418 100644 --- a/reactos/include/ddk/iofuncs.h +++ b/reactos/include/ddk/iofuncs.h @@ -1,6 +1,6 @@ #ifndef _INCLUDE_DDK_IOFUNCS_H #define _INCLUDE_DDK_IOFUNCS_H -/* $Id: iofuncs.h,v 1.29 2002/01/21 22:27:36 hbirr Exp $ */ +/* $Id: iofuncs.h,v 1.30 2002/04/10 09:55:10 ekohl Exp $ */ /* --- EXPORTED BY NTOSKRNL --- */ @@ -822,7 +822,7 @@ IoQueryVolumeInformation ( VOID STDCALL IoQueueThreadIrp ( - PVOID Unknown0 + IN PIRP Irp ); VOID STDCALL diff --git a/reactos/include/ddk/iotypes.h b/reactos/include/ddk/iotypes.h index 8b314819db5..d1a359a46f2 100644 --- a/reactos/include/ddk/iotypes.h +++ b/reactos/include/ddk/iotypes.h @@ -1,4 +1,4 @@ -/* $Id: iotypes.h,v 1.35 2002/03/25 21:53:27 ekohl Exp $ +/* $Id: iotypes.h,v 1.36 2002/04/10 09:55:10 ekohl Exp $ * */ @@ -304,7 +304,7 @@ typedef struct __attribute__((packed)) _IO_STACK_LOCATION { struct _VPB* Vpb; struct _DEVICE_OBJECT* DeviceObject; - } Mount; + } MountVolume; struct { struct _VPB* Vpb; diff --git a/reactos/ntoskrnl/include/internal/io.h b/reactos/ntoskrnl/include/internal/io.h index 0ca7d0c16e6..9ac1cc45016 100644 --- a/reactos/ntoskrnl/include/internal/io.h +++ b/reactos/ntoskrnl/include/internal/io.h @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: io.h,v 1.17 2002/03/15 23:59:05 ekohl Exp $ +/* $Id: io.h,v 1.18 2002/04/10 09:58:02 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -254,17 +254,19 @@ NTSTATUS IopInitializeDeviceNodeService(PDEVICE_NODE DeviceNode); NTSTATUS IopInitializeDriver(PDRIVER_INITIALIZE DriverEntry, - PDEVICE_NODE DeviceNode); -VOID + PDEVICE_NODE DeviceNode); +VOID IoInitCancelHandling(VOID); -VOID +VOID IoInitSymbolicLinkImplementation(VOID); -VOID +VOID IoInitFileSystemImplementation(VOID); -VOID +VOID IoInitVpbImplementation (VOID); -NTSTATUS IoTryToMountStorageDevice(PDEVICE_OBJECT DeviceObject); +NTSTATUS +IoTryToMountStorageDevice(IN PDEVICE_OBJECT DeviceObject, + IN BOOLEAN AllowRawMount); POBJECT IoOpenSymlink(POBJECT SymbolicLink); POBJECT IoOpenFileOnDevice(POBJECT SymbolicLink, PWCHAR Name); @@ -299,17 +301,18 @@ VOID IoInitShutdownNotification(VOID); VOID IoShutdownRegisteredDevices(VOID); VOID IoShutdownRegisteredFileSystems(VOID); -NTSTATUS STDCALL -IoPageRead (PFILE_OBJECT FileObject, +NTSTATUS STDCALL +IoPageRead(PFILE_OBJECT FileObject, + PMDL Mdl, + PLARGE_INTEGER Offset, + PIO_STATUS_BLOCK StatusBlock, + BOOLEAN PagingIo); +NTSTATUS STDCALL +IoPageWrite(PFILE_OBJECT FileObject, PMDL Mdl, PLARGE_INTEGER Offset, PIO_STATUS_BLOCK StatusBlock, BOOLEAN PagingIo); -NTSTATUS STDCALL IoPageWrite (PFILE_OBJECT FileObject, - PMDL Mdl, - PLARGE_INTEGER Offset, - PIO_STATUS_BLOCK StatusBlock, - BOOLEAN PagingIo); NTSTATUS IoCreateArcNames(VOID); diff --git a/reactos/ntoskrnl/io/buildirp.c b/reactos/ntoskrnl/io/buildirp.c index 3f434795fa3..6f02cafc8fa 100644 --- a/reactos/ntoskrnl/io/buildirp.c +++ b/reactos/ntoskrnl/io/buildirp.c @@ -1,4 +1,4 @@ -/* $Id: buildirp.c,v 1.26 2002/03/17 17:21:44 hbirr Exp $ +/* $Id: buildirp.c,v 1.27 2002/04/10 09:57:31 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -81,8 +81,8 @@ PIRP IoBuildFilesystemControlRequest(ULONG MinorFunction, * DeviceObject = Device object to send the request to * UserEvent = Event used to notify the caller of completion * IoStatusBlock (OUT) = Used to return the status of the operation - * DeviceToMount = Device to mount (for the IRP_MN_MOUNT_DEVICE - * request) + * DeviceToMount = Device to mount (for the IRP_MN_MOUNT_VOLUME + * or IRP_MN_VERIFY_VOLUME request) */ { PIRP Irp; @@ -114,11 +114,13 @@ PIRP IoBuildFilesystemControlRequest(ULONG MinorFunction, break; case IRP_MN_MOUNT_VOLUME: - StackPtr->Parameters.Mount.Vpb = DeviceToMount->Vpb; - StackPtr->Parameters.Mount.DeviceObject = DeviceToMount; + StackPtr->Parameters.MountVolume.Vpb = DeviceToMount->Vpb; + StackPtr->Parameters.MountVolume.DeviceObject = DeviceToMount; break; case IRP_MN_VERIFY_VOLUME: + StackPtr->Parameters.VerifyVolume.Vpb = DeviceToMount->Vpb; + StackPtr->Parameters.VerifyVolume.DeviceObject = DeviceToMount; break; case IRP_MN_LOAD_FILE_SYSTEM: diff --git a/reactos/ntoskrnl/io/create.c b/reactos/ntoskrnl/io/create.c index 6d6fcf678dd..0ed9fcda8ec 100644 --- a/reactos/ntoskrnl/io/create.c +++ b/reactos/ntoskrnl/io/create.c @@ -1,4 +1,4 @@ -/* $Id: create.c,v 1.55 2002/04/07 18:36:13 phreak Exp $ +/* $Id: create.c,v 1.56 2002/04/10 09:57:31 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -44,7 +44,7 @@ NTSTATUS STDCALL NtDeleteFile(IN POBJECT_ATTRIBUTES ObjectAttributes) { - UNIMPLEMENTED; + UNIMPLEMENTED; } @@ -67,91 +67,95 @@ IopCreateFile(PVOID ObjectBody, PWSTR RemainingPath, POBJECT_ATTRIBUTES ObjectAttributes) { - PDEVICE_OBJECT DeviceObject = (PDEVICE_OBJECT) Parent; - PFILE_OBJECT FileObject = (PFILE_OBJECT) ObjectBody; - NTSTATUS Status; - - DPRINT("IopCreateFile(ObjectBody %x, Parent %x, RemainingPath %S)\n", - ObjectBody, - Parent, - RemainingPath); - - if (NULL == DeviceObject) - { - /* This is probably an attempt to create a meta fileobject (eg. for FAT) - for the cache manager, so return STATUS_SUCCESS */ - DPRINT("DeviceObject was NULL\n"); - return (STATUS_SUCCESS); - } - if (IoDeviceObjectType != BODY_TO_HEADER(Parent)->ObjectType) - { - CPRINT("Parent is a %S which is not a device type\n", - BODY_TO_HEADER(Parent)->ObjectType->TypeName.Buffer); - return (STATUS_UNSUCCESSFUL); - } - Status = ObReferenceObjectByPointer (DeviceObject, - STANDARD_RIGHTS_REQUIRED, - IoDeviceObjectType, - UserMode); - if (STATUS_SUCCESS != Status) - { - CHECKPOINT1; - return (Status); - } - - DeviceObject = IoGetAttachedDevice (DeviceObject); - - DPRINT("DeviceObject %x\n", DeviceObject); - - if (NULL == RemainingPath) - { - FileObject->Flags = FileObject->Flags | FO_DIRECT_DEVICE_OPEN; - FileObject->FileName.Buffer = 0; - FileObject->FileName.Length = FileObject->FileName.MaximumLength = 0; - } - else - { - if ((DeviceObject->DeviceType != FILE_DEVICE_FILE_SYSTEM) - && (DeviceObject->DeviceType != FILE_DEVICE_DISK) - && (DeviceObject->DeviceType != FILE_DEVICE_NETWORK) - && (DeviceObject->DeviceType != FILE_DEVICE_NAMED_PIPE) - && (DeviceObject->DeviceType != FILE_DEVICE_MAILSLOT)) - { - CPRINT ("Device was wrong type\n"); - return (STATUS_UNSUCCESSFUL); - } + PDEVICE_OBJECT DeviceObject = (PDEVICE_OBJECT) Parent; + PFILE_OBJECT FileObject = (PFILE_OBJECT) ObjectBody; + NTSTATUS Status; - if (DeviceObject->DeviceType != FILE_DEVICE_NETWORK - && (DeviceObject->DeviceType != FILE_DEVICE_NAMED_PIPE) - && (DeviceObject->DeviceType != FILE_DEVICE_MAILSLOT)) - { - if (!(DeviceObject->Vpb->Flags & VPB_MOUNTED)) - { - DPRINT("Trying to mount storage device\n"); - Status = IoTryToMountStorageDevice (DeviceObject); - DPRINT("Status %x\n", Status); - if (!NT_SUCCESS(Status)) - { - CPRINT("Failed to mount storage device (status %x)\n", - Status); - return (Status); - } - DeviceObject = IoGetAttachedDevice(DeviceObject); - } - } - RtlCreateUnicodeString(&(FileObject->FileName), - RemainingPath); - } - DPRINT("FileObject->FileName.Buffer %S\n", - FileObject->FileName.Buffer); - FileObject->DeviceObject = DeviceObject; - DPRINT("FileObject %x DeviceObject %x\n", - FileObject, - DeviceObject); - FileObject->Vpb = DeviceObject->Vpb; - FileObject->Type = InternalFileType; - - return (STATUS_SUCCESS); + DPRINT("IopCreateFile(ObjectBody %x, Parent %x, RemainingPath %S)\n", + ObjectBody, + Parent, + RemainingPath); + + if (NULL == DeviceObject) + { + /* This is probably an attempt to create a meta fileobject (eg. for FAT) + for the cache manager, so return STATUS_SUCCESS */ + DPRINT("DeviceObject was NULL\n"); + return(STATUS_SUCCESS); + } + + if (IoDeviceObjectType != BODY_TO_HEADER(Parent)->ObjectType) + { + CPRINT("Parent is a %S which is not a device type\n", + BODY_TO_HEADER(Parent)->ObjectType->TypeName.Buffer); + return(STATUS_UNSUCCESSFUL); + } + + Status = ObReferenceObjectByPointer(DeviceObject, + STANDARD_RIGHTS_REQUIRED, + IoDeviceObjectType, + UserMode); + if (!NT_SUCCESS(Status)) + { + CPRINT("Failed to reference device object %x\n", DeviceObject); + return(Status); + } + + DeviceObject = IoGetAttachedDevice(DeviceObject); + DPRINT("DeviceObject %x\n", DeviceObject); + + if (NULL == RemainingPath) + { + FileObject->Flags = FileObject->Flags | FO_DIRECT_DEVICE_OPEN; + FileObject->FileName.Buffer = 0; + FileObject->FileName.Length = FileObject->FileName.MaximumLength = 0; + } + else + { + if ((DeviceObject->DeviceType != FILE_DEVICE_FILE_SYSTEM) + && (DeviceObject->DeviceType != FILE_DEVICE_DISK) + && (DeviceObject->DeviceType != FILE_DEVICE_CD_ROM) + && (DeviceObject->DeviceType != FILE_DEVICE_TAPE) + && (DeviceObject->DeviceType != FILE_DEVICE_NETWORK) + && (DeviceObject->DeviceType != FILE_DEVICE_NAMED_PIPE) + && (DeviceObject->DeviceType != FILE_DEVICE_MAILSLOT)) + { + CPRINT("Device was wrong type\n"); + return(STATUS_UNSUCCESSFUL); + } + + if (DeviceObject->DeviceType != FILE_DEVICE_NETWORK + && (DeviceObject->DeviceType != FILE_DEVICE_NAMED_PIPE) + && (DeviceObject->DeviceType != FILE_DEVICE_MAILSLOT)) + { + if (!(DeviceObject->Vpb->Flags & VPB_MOUNTED)) + { + DPRINT("Trying to mount storage device\n"); + Status = IoTryToMountStorageDevice(DeviceObject, FALSE); + DPRINT("Status %x\n", Status); + if (!NT_SUCCESS(Status)) + { + CPRINT("Failed to mount storage device (status %x)\n", + Status); + return(Status); + } + DeviceObject = IoGetAttachedDevice(DeviceObject); + } + } + RtlCreateUnicodeString(&(FileObject->FileName), + RemainingPath); + } + + DPRINT("FileObject->FileName %wZ\n", + &FileObject->FileName); + FileObject->DeviceObject = DeviceObject; + DPRINT("FileObject %x DeviceObject %x\n", + FileObject, + DeviceObject); + FileObject->Vpb = DeviceObject->Vpb; + FileObject->Type = InternalFileType; + + return(STATUS_SUCCESS); } @@ -184,15 +188,15 @@ IoCreateStreamFileObject(PFILE_OBJECT FileObject, NTSTATUS Status; DPRINT("IoCreateStreamFileObject(FileObject %x, DeviceObject %x)\n", - FileObject, DeviceObject); - - assert_irql (PASSIVE_LEVEL); + FileObject, DeviceObject); + + assert_irql(PASSIVE_LEVEL); - Status = ObCreateObject (&FileHandle, - STANDARD_RIGHTS_REQUIRED, - NULL, - IoFileObjectType, - (PVOID*)&CreatedFileObject); + Status = ObCreateObject(&FileHandle, + STANDARD_RIGHTS_REQUIRED, + NULL, + IoFileObjectType, + (PVOID*)&CreatedFileObject); if (!NT_SUCCESS(Status)) { DPRINT("Could not create FileObject\n"); @@ -213,11 +217,11 @@ IoCreateStreamFileObject(PFILE_OBJECT FileObject, CreatedFileObject->Flags |= FO_DIRECT_DEVICE_OPEN; // shouldn't we initialize the lock event, and several other things here too? - KeInitializeEvent( &CreatedFileObject->Event, NotificationEvent, FALSE ); + KeInitializeEvent(&CreatedFileObject->Event, NotificationEvent, FALSE); - ZwClose (FileHandle); + ZwClose(FileHandle); - return (CreatedFileObject); + return(CreatedFileObject); } diff --git a/reactos/ntoskrnl/io/device.c b/reactos/ntoskrnl/io/device.c index 3cde331d6ba..033a04f645b 100644 --- a/reactos/ntoskrnl/io/device.c +++ b/reactos/ntoskrnl/io/device.c @@ -1,4 +1,4 @@ -/* $Id: device.c,v 1.36 2002/03/24 15:30:44 ekohl Exp $ +/* $Id: device.c,v 1.37 2002/04/10 09:57:31 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -274,18 +274,20 @@ IoRegisterDriverReinitialization(PDRIVER_OBJECT DriverObject, UNIMPLEMENTED; } -NTSTATUS STDCALL + +NTSTATUS STDCALL IopDefaultDispatchFunction(PDEVICE_OBJECT DeviceObject, PIRP Irp) { - Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED; - Irp->IoStatus.Information = 0; - - IoCompleteRequest(Irp, IO_NO_INCREMENT); - return(STATUS_NOT_IMPLEMENTED); + Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED; + Irp->IoStatus.Information = 0; + + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return(STATUS_NOT_IMPLEMENTED); } -NTSTATUS + +NTSTATUS IopCreateDriverObject(PDRIVER_OBJECT *DriverObject) { PDRIVER_OBJECT Object; @@ -458,13 +460,12 @@ IopInitializeService( } NTSTATUS -IopInitializeDeviceNodeService( - PDEVICE_NODE DeviceNode) +IopInitializeDeviceNodeService(PDEVICE_NODE DeviceNode) { RTL_QUERY_REGISTRY_TABLE QueryTable[2]; UNICODE_STRING ImagePath; HANDLE KeyHandle; - NTSTATUS Status; + NTSTATUS Status; Status = RtlpGetRegistryHandle( RTL_REGISTRY_SERVICES, @@ -473,8 +474,8 @@ IopInitializeDeviceNodeService( &KeyHandle); if (!NT_SUCCESS(Status)) { - DPRINT("RtlpGetRegistryHandle() failed (Status %x)\n", Status); - return Status; + DPRINT("RtlpGetRegistryHandle() failed (Status %x)\n", Status); + return(Status); } RtlZeroMemory(QueryTable, sizeof(QueryTable)); @@ -496,20 +497,20 @@ IopInitializeDeviceNodeService( DPRINT("RtlQueryRegistryValues() returned status %x\n", Status); if (NT_SUCCESS(Status)) - { - DPRINT("Got ImagePath %S\n", ImagePath.Buffer); + { + DPRINT("Got ImagePath %S\n", ImagePath.Buffer); - Status = IopInitializeService(DeviceNode, &ImagePath); + Status = IopInitializeService(DeviceNode, &ImagePath); - RtlFreeUnicodeString(&ImagePath); - } + RtlFreeUnicodeString(&ImagePath); + } - return Status; + return(Status); } -NTSTATUS +NTSTATUS IopInitializeDriver(PDRIVER_INITIALIZE DriverEntry, - PDEVICE_NODE DeviceNode) + PDEVICE_NODE DeviceNode) /* * FUNCTION: Called to initalize a loaded driver * ARGUMENTS: @@ -528,21 +529,21 @@ IopInitializeDriver(PDRIVER_INITIALIZE DriverEntry, Status = IopCreateDriverObject(&DriverObject); if (!NT_SUCCESS(Status)) { - return(Status); + return(Status); } DeviceNode->DriverObject = DriverObject; if (DeviceNode->ServiceName.Buffer) - { - wcscpy(RegistryKeyBuffer, DRIVER_REGISTRY_KEY_BASENAME); - wcscat(RegistryKeyBuffer, DeviceNode->ServiceName.Buffer); - RtlInitUnicodeString(&RegistryKey, RegistryKeyBuffer); - } + { + wcscpy(RegistryKeyBuffer, DRIVER_REGISTRY_KEY_BASENAME); + wcscat(RegistryKeyBuffer, DeviceNode->ServiceName.Buffer); + RtlInitUnicodeString(&RegistryKey, RegistryKeyBuffer); + } else - { - RtlInitUnicodeString(&RegistryKey, NULL); - } + { + RtlInitUnicodeString(&RegistryKey, NULL); + } DPRINT("RegistryKey: %wZ\n", &RegistryKey); DPRINT("Calling driver entrypoint at %08lx\n", DriverEntry); @@ -550,10 +551,10 @@ IopInitializeDriver(PDRIVER_INITIALIZE DriverEntry, Status = DriverEntry(DriverObject, &RegistryKey); if (!NT_SUCCESS(Status)) { - DeviceNode->DriverObject = NULL; - ExFreePool(DriverObject->DriverExtension); - ExFreePool(DriverObject); - return(Status); + DeviceNode->DriverObject = NULL; + ExFreePool(DriverObject->DriverExtension); + ExFreePool(DriverObject); + return(Status); } Status = IopInitializeDevice(DeviceNode, TRUE); @@ -561,6 +562,7 @@ IopInitializeDriver(PDRIVER_INITIALIZE DriverEntry, return(Status); } + NTSTATUS STDCALL IoAttachDevice(PDEVICE_OBJECT SourceDevice, PUNICODE_STRING TargetDevice, @@ -573,9 +575,10 @@ IoAttachDevice(PDEVICE_OBJECT SourceDevice, * AttachedDevice (OUT) = Caller storage for the device attached to */ { - UNIMPLEMENTED; + UNIMPLEMENTED; } + NTSTATUS STDCALL IopCreateDevice(PVOID ObjectBody, PVOID Parent, @@ -674,45 +677,48 @@ IoCreateDevice(PDRIVER_OBJECT DriverObject, CreatedDeviceObject->NextDevice = DriverObject->DeviceObject; DriverObject->DeviceObject = CreatedDeviceObject; } - - CreatedDeviceObject->Type = DeviceType; - CreatedDeviceObject->DriverObject = DriverObject; - CreatedDeviceObject->CurrentIrp = NULL; - CreatedDeviceObject->Flags = 0; + + CreatedDeviceObject->Type = DeviceType; + CreatedDeviceObject->DriverObject = DriverObject; + CreatedDeviceObject->CurrentIrp = NULL; + CreatedDeviceObject->Flags = 0; - CreatedDeviceObject->DeviceExtension = - ExAllocatePoolWithTag(NonPagedPool, DeviceExtensionSize, - TAG_DEVICE_EXTENSION); - if (DeviceExtensionSize > 0 && CreatedDeviceObject->DeviceExtension == NULL) - { - ExFreePool(CreatedDeviceObject); - return(STATUS_INSUFFICIENT_RESOURCES); - } + CreatedDeviceObject->DeviceExtension = + ExAllocatePoolWithTag(NonPagedPool, DeviceExtensionSize, + TAG_DEVICE_EXTENSION); + if (DeviceExtensionSize > 0 && CreatedDeviceObject->DeviceExtension == NULL) + { + ExFreePool(CreatedDeviceObject); + return(STATUS_INSUFFICIENT_RESOURCES); + } if (DeviceExtensionSize > 0) - { - RtlZeroMemory(CreatedDeviceObject->DeviceExtension, - DeviceExtensionSize); - } + { + RtlZeroMemory(CreatedDeviceObject->DeviceExtension, + DeviceExtensionSize); + } - CreatedDeviceObject->AttachedDevice = NULL; - CreatedDeviceObject->DeviceType = DeviceType; - CreatedDeviceObject->StackSize = 1; - CreatedDeviceObject->AlignmentRequirement = 1; - KeInitializeDeviceQueue(&CreatedDeviceObject->DeviceQueue); - - KeInitializeEvent(&CreatedDeviceObject->DeviceLock, - SynchronizationEvent, - TRUE); - - if (CreatedDeviceObject->DeviceType == FILE_DEVICE_DISK) - { - IoAttachVpb(CreatedDeviceObject); - } - - *DeviceObject = CreatedDeviceObject; - - return(STATUS_SUCCESS); + CreatedDeviceObject->AttachedDevice = NULL; + CreatedDeviceObject->DeviceType = DeviceType; + CreatedDeviceObject->StackSize = 1; + CreatedDeviceObject->AlignmentRequirement = 1; + KeInitializeDeviceQueue(&CreatedDeviceObject->DeviceQueue); + + KeInitializeEvent(&CreatedDeviceObject->DeviceLock, + SynchronizationEvent, + TRUE); + + /* FIXME: Do we need to add network drives too?! */ + if (CreatedDeviceObject->DeviceType == FILE_DEVICE_DISK || + CreatedDeviceObject->DeviceType == FILE_DEVICE_CD_ROM || + CreatedDeviceObject->DeviceType == FILE_DEVICE_TAPE) + { + IoAttachVpb(CreatedDeviceObject); + } + + *DeviceObject = CreatedDeviceObject; + + return(STATUS_SUCCESS); } @@ -726,8 +732,8 @@ IoOpenDeviceInstanceKey ( DWORD Unknown4 ) { - UNIMPLEMENTED; - return (STATUS_NOT_IMPLEMENTED); + UNIMPLEMENTED; + return(STATUS_NOT_IMPLEMENTED); } @@ -738,8 +744,8 @@ IoQueryDeviceEnumInfo ( DWORD Unknown1 ) { - UNIMPLEMENTED; - return 0; + UNIMPLEMENTED; + return 0; } @@ -750,15 +756,15 @@ IoGetDeviceToVerify (PETHREAD Thread) * device, that is the target of the given thread's I/O request */ { - return Thread->DeviceToVerify; + return(Thread->DeviceToVerify); } VOID STDCALL -IoSetDeviceToVerify (IN PETHREAD Thread, - IN PDEVICE_OBJECT DeviceObject) +IoSetDeviceToVerify(IN PETHREAD Thread, + IN PDEVICE_OBJECT DeviceObject) { - Thread->DeviceToVerify = DeviceObject; + Thread->DeviceToVerify = DeviceObject; } @@ -766,7 +772,7 @@ VOID STDCALL IoSetHardErrorOrVerifyDevice(PIRP Irp, PDEVICE_OBJECT DeviceObject) { - Irp->Tail.Overlay.Thread->DeviceToVerify = DeviceObject; + Irp->Tail.Overlay.Thread->DeviceToVerify = DeviceObject; } diff --git a/reactos/ntoskrnl/io/fs.c b/reactos/ntoskrnl/io/fs.c index c2c284a5d05..30ee2bc3216 100644 --- a/reactos/ntoskrnl/io/fs.c +++ b/reactos/ntoskrnl/io/fs.c @@ -1,4 +1,4 @@ -/* $Id: fs.c,v 1.21 2002/04/07 18:36:13 phreak Exp $ +/* $Id: fs.c,v 1.22 2002/04/10 09:57:31 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -130,7 +130,9 @@ NtFsControlFile ( return(Status); } -VOID IoInitFileSystemImplementation(VOID) + +VOID +IoInitFileSystemImplementation(VOID) { InitializeListHead(&FileSystemListHead); KeInitializeSpinLock(&FileSystemListLock); @@ -139,7 +141,9 @@ VOID IoInitFileSystemImplementation(VOID) KeInitializeSpinLock(&FsChangeNotifyListLock); } -VOID IoShutdownRegisteredFileSystems(VOID) + +VOID +IoShutdownRegisteredFileSystems(VOID) { KIRQL oldlvl; PLIST_ENTRY current_entry; @@ -180,8 +184,10 @@ VOID IoShutdownRegisteredFileSystems(VOID) KeReleaseSpinLock(&FileSystemListLock,oldlvl); } -NTSTATUS IoAskFileSystemToMountDevice(PDEVICE_OBJECT DeviceObject, - PDEVICE_OBJECT DeviceToMount) + +NTSTATUS +IoAskFileSystemToMountDevice(PDEVICE_OBJECT DeviceObject, + PDEVICE_OBJECT DeviceToMount) { PIRP Irp; IO_STATUS_BLOCK IoStatusBlock; @@ -211,12 +217,17 @@ NTSTATUS IoAskFileSystemToMountDevice(PDEVICE_OBJECT DeviceObject, return(Status); } -NTSTATUS IoAskFileSystemToLoad(PDEVICE_OBJECT DeviceObject) + +NTSTATUS +IoAskFileSystemToLoad(PDEVICE_OBJECT DeviceObject) { UNIMPLEMENTED; } -NTSTATUS IoTryToMountStorageDevice(PDEVICE_OBJECT DeviceObject) + +NTSTATUS +IoTryToMountStorageDevice(IN PDEVICE_OBJECT DeviceObject, + IN BOOLEAN AllowRawMount) /* * FUNCTION: Trys to mount a storage device * ARGUMENTS: @@ -231,7 +242,7 @@ NTSTATUS IoTryToMountStorageDevice(PDEVICE_OBJECT DeviceObject) assert_irql(PASSIVE_LEVEL); - DPRINT("IoTryToMountStorageDevice(DeviceObject %x)\n",DeviceObject); + DPRINT1("IoTryToMountStorageDevice(DeviceObject %x)\n",DeviceObject); KeAcquireSpinLock(&FileSystemListLock,&oldlvl); current_entry = FileSystemListHead.Flink; @@ -266,6 +277,90 @@ NTSTATUS IoTryToMountStorageDevice(PDEVICE_OBJECT DeviceObject) return(STATUS_UNRECOGNIZED_VOLUME); } + +/********************************************************************** + * NAME EXPORTED + * IoVerifyVolume + * + * DESCRIPTION + * Veriyfy the file system type and volume information or mount + * a file system. + * + * ARGUMENTS + * DeviceObject + * Device to verify or mount + * + * AllowRawMount + * ... + * + * RETURN VALUE + * Status + */ +NTSTATUS STDCALL +IoVerifyVolume(IN PDEVICE_OBJECT DeviceObject, + IN BOOLEAN AllowRawMount) +{ +#if 0 + IO_STATUS_BLOCK IoStatusBlock, + KEVENT Event; + PIRP Irp; +#endif + NTSTATUS Status; + + DPRINT1("IoVerifyVolume(DeviceObject %x AllowRawMount %x)\n", + DeviceObject, + AllowRawMount); + + Status = STATUS_SUCCESS; + + KeWaitForSingleObject(&DeviceObject->DeviceLock, + Executive, + KernelMode, + FALSE, + NULL); + + if (DeviceObject->Vpb->Flags & VPB_MOUNTED) + { + /* FIXME: Issue verify request to the FSD */ +#if 0 + KeInitializeEvent(&Event,...); + + Irp = IoBuildFilesystemControlRequest(IRP_MN_VERIFY_VOLUME, + DeviceObject, + &Event, + &IoStatusBlock, + &DeviceToMount) + + +#endif + + if (NT_SUCCESS(Status)) + { + KeSetEvent(&DeviceObject->DeviceLock, + IO_NO_INCREMENT, + FALSE); + return(STATUS_SUCCESS); + } + } + + if (Status == STATUS_WRONG_VOLUME) + { + /* FIXME: Replace existing VPB by a new one */ + + } + + /* Start mount sequence */ + Status = IoTryToMountStorageDevice(DeviceObject, + AllowRawMount); + + KeSetEvent(&DeviceObject->DeviceLock, + IO_NO_INCREMENT, + FALSE); + + return(Status); +} + + VOID STDCALL IoRegisterFileSystem(PDEVICE_OBJECT DeviceObject) { @@ -283,6 +378,7 @@ IoRegisterFileSystem(PDEVICE_OBJECT DeviceObject) IopNotifyFileSystemChange(DeviceObject, TRUE); } + VOID STDCALL IoUnregisterFileSystem(PDEVICE_OBJECT DeviceObject) { diff --git a/reactos/ntoskrnl/io/irp.c b/reactos/ntoskrnl/io/irp.c index 7230ffce44c..3d7c53d5b9e 100644 --- a/reactos/ntoskrnl/io/irp.c +++ b/reactos/ntoskrnl/io/irp.c @@ -1,4 +1,4 @@ -/* $Id: irp.c,v 1.39 2002/01/21 22:30:26 hbirr Exp $ +/* $Id: irp.c,v 1.40 2002/04/10 09:57:31 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -46,19 +46,20 @@ VOID STDCALL -IoFreeIrp (PIRP Irp) +IoFreeIrp(PIRP Irp) /* * FUNCTION: Releases a caller allocated irp * ARGUMENTS: * Irp = Irp to free */ { - ExFreePool(Irp); + ExFreePool(Irp); } PIRP STDCALL -IoMakeAssociatedIrp (PIRP Irp, CCHAR StackSize) +IoMakeAssociatedIrp(PIRP Irp, + CCHAR StackSize) /* * FUNCTION: Allocates and initializes an irp to associated with a master irp * ARGUMENTS: @@ -67,15 +68,17 @@ IoMakeAssociatedIrp (PIRP Irp, CCHAR StackSize) * RETURNS: The irp allocated */ { - PIRP AssocIrp; - - AssocIrp = IoAllocateIrp(StackSize,FALSE); - UNIMPLEMENTED; + PIRP AssocIrp; + + AssocIrp = IoAllocateIrp(StackSize,FALSE); + UNIMPLEMENTED; } VOID STDCALL -IoInitializeIrp (PIRP Irp, USHORT PacketSize, CCHAR StackSize) +IoInitializeIrp(PIRP Irp, + USHORT PacketSize, + CCHAR StackSize) /* * FUNCTION: Initalizes an irp allocated by the caller * ARGUMENTS: @@ -84,48 +87,50 @@ IoInitializeIrp (PIRP Irp, USHORT PacketSize, CCHAR StackSize) * StackSize = Number of stack locations in the IRP */ { - assert(Irp != NULL); + assert(Irp != NULL); - memset(Irp, 0, PacketSize); - Irp->Size = PacketSize; - Irp->StackCount = StackSize; - Irp->CurrentLocation = StackSize; - Irp->Tail.Overlay.CurrentStackLocation = &Irp->Stack[(ULONG)StackSize]; + memset(Irp, 0, PacketSize); + Irp->Size = PacketSize; + Irp->StackCount = StackSize; + Irp->CurrentLocation = StackSize; + Irp->Tail.Overlay.CurrentStackLocation = &Irp->Stack[(ULONG)StackSize]; } NTSTATUS FASTCALL -IofCallDriver (PDEVICE_OBJECT DeviceObject, PIRP Irp) +IofCallDriver(PDEVICE_OBJECT DeviceObject, + PIRP Irp) /* * FUNCTION: Sends an IRP to the next lower driver */ { - NTSTATUS Status; - PDRIVER_OBJECT DriverObject; - PIO_STACK_LOCATION Param; - - DPRINT("IofCallDriver(DeviceObject %x, Irp %x)\n",DeviceObject,Irp); - - assert(Irp); - assert(DeviceObject); + NTSTATUS Status; + PDRIVER_OBJECT DriverObject; + PIO_STACK_LOCATION Param; + + DPRINT("IofCallDriver(DeviceObject %x, Irp %x)\n",DeviceObject,Irp); + + assert(Irp); + assert(DeviceObject); - DriverObject = DeviceObject->DriverObject; + DriverObject = DeviceObject->DriverObject; - assert(DriverObject); + assert(DriverObject); - Param = IoGetNextIrpStackLocation(Irp); + Param = IoGetNextIrpStackLocation(Irp); - DPRINT("IrpSp 0x%X\n", Param); - - Irp->Tail.Overlay.CurrentStackLocation--; - Irp->CurrentLocation--; - - DPRINT("MajorFunction %d\n", Param->MajorFunction); - DPRINT("DriverObject->MajorFunction[Param->MajorFunction] %x\n", - DriverObject->MajorFunction[Param->MajorFunction]); - Status = DriverObject->MajorFunction[Param->MajorFunction](DeviceObject, - Irp); - return Status; + DPRINT("IrpSp 0x%X\n", Param); + + Irp->Tail.Overlay.CurrentStackLocation--; + Irp->CurrentLocation--; + + DPRINT("MajorFunction %d\n", Param->MajorFunction); + DPRINT("DriverObject->MajorFunction[Param->MajorFunction] %x\n", + DriverObject->MajorFunction[Param->MajorFunction]); + Status = DriverObject->MajorFunction[Param->MajorFunction](DeviceObject, + Irp); + + return(Status); } @@ -133,16 +138,14 @@ NTSTATUS STDCALL IoCallDriver (PDEVICE_OBJECT DeviceObject, PIRP Irp) { - return IofCallDriver ( - DeviceObject, - Irp - ); + return(IofCallDriver(DeviceObject, + Irp)); } -PIRP -STDCALL -IoAllocateIrp (CCHAR StackSize, BOOLEAN ChargeQuota) +PIRP STDCALL +IoAllocateIrp(CCHAR StackSize, + BOOLEAN ChargeQuota) /* * FUNCTION: Allocates an IRP * ARGUMENTS: @@ -151,37 +154,41 @@ IoAllocateIrp (CCHAR StackSize, BOOLEAN ChargeQuota) * RETURNS: Irp allocated */ { - PIRP Irp; + PIRP Irp; #if 0 - DbgPrint("IoAllocateIrp(StackSize %d ChargeQuota %d)\n", - StackSize, - ChargeQuota); - KeDumpStackFrames(0,8); + DbgPrint("IoAllocateIrp(StackSize %d ChargeQuota %d)\n", + StackSize, + ChargeQuota); + KeDumpStackFrames(0,8); #endif - - if (ChargeQuota) - { -// Irp = ExAllocatePoolWithQuota(NonPagedPool,IoSizeOfIrp(StackSize)); - Irp = ExAllocatePoolWithTag(NonPagedPool, IoSizeOfIrp(StackSize), - TAG_IRP); - } - else - { - Irp = ExAllocatePoolWithTag(NonPagedPool,IoSizeOfIrp(StackSize), - TAG_IRP); - } - - if (Irp==NULL) - { - return(NULL); - } - - IoInitializeIrp(Irp, IoSizeOfIrp(StackSize), StackSize); + + if (ChargeQuota) + { +// Irp = ExAllocatePoolWithQuota(NonPagedPool,IoSizeOfIrp(StackSize)); + Irp = ExAllocatePoolWithTag(NonPagedPool, + IoSizeOfIrp(StackSize), + TAG_IRP); + } + else + { + Irp = ExAllocatePoolWithTag(NonPagedPool, + IoSizeOfIrp(StackSize), + TAG_IRP); + } -// DPRINT("Irp %x Irp->StackPtr %d\n", Irp, Irp->CurrentLocation); + if (Irp==NULL) + { + return(NULL); + } - return Irp; + IoInitializeIrp(Irp, + IoSizeOfIrp(StackSize), + StackSize); + +// DPRINT("Irp %x Irp->StackPtr %d\n", Irp, Irp->CurrentLocation); + + return(Irp); } @@ -192,11 +199,12 @@ IopCompleteRequest(struct _KAPC* Apc, PVOID* SystemArgument1, PVOID* SystemArgument2) { - DPRINT("IopCompleteRequest(Apc %x, SystemArgument1 %x, " - "(*SystemArgument1) %x\n", Apc, SystemArgument1, - *SystemArgument1); - IoSecondStageCompletion((PIRP)(*SystemArgument1), - (KPRIORITY)(*SystemArgument2)); + DPRINT("IopCompleteRequest(Apc %x, SystemArgument1 %x, (*SystemArgument1) %x\n", + Apc, + SystemArgument1, + *SystemArgument1); + IoSecondStageCompletion((PIRP)(*SystemArgument1), + (KPRIORITY)(*SystemArgument2)); } @@ -263,14 +271,12 @@ IofCompleteRequest(PIRP Irp, } -VOID -STDCALL -IoCompleteRequest (PIRP Irp, CCHAR PriorityBoost) +VOID STDCALL +IoCompleteRequest(PIRP Irp, + CCHAR PriorityBoost) { - IofCompleteRequest ( - Irp, - PriorityBoost - ); + IofCompleteRequest(Irp, + PriorityBoost); } @@ -288,89 +294,65 @@ IoCompleteRequest (PIRP Irp, CCHAR PriorityBoost) * RETURN VALUE * TRUE if Irp's operation is synchronous; otherwise FALSE. */ -BOOLEAN -STDCALL -IoIsOperationSynchronous ( - IN PIRP Irp - ) +BOOLEAN STDCALL +IoIsOperationSynchronous(IN PIRP Irp) { - ULONG Flags = 0; - PFILE_OBJECT FileObject = NULL; - - /* - * Check the associated FILE_OBJECT's - * flags first. - */ - FileObject = Irp->Tail.Overlay.OriginalFileObject; - if (!(FO_SYNCHRONOUS_IO & FileObject->Flags)) + PFILE_OBJECT FileObject = NULL; + ULONG Flags = 0; + + /* Check the associated FILE_OBJECT's flags first. */ + FileObject = Irp->Tail.Overlay.OriginalFileObject; + if (!(FO_SYNCHRONOUS_IO & FileObject->Flags)) + { + /* Check IRP's flags. */ + Flags = Irp->Flags; + if (!((IRP_SYNCHRONOUS_API | IRP_SYNCHRONOUS_PAGING_IO) & Flags)) { - /* Check IRP's flags. */ - Flags = Irp->Flags; - if (!( (IRP_SYNCHRONOUS_API | IRP_SYNCHRONOUS_PAGING_IO) - & Flags - )) - { - return FALSE; - } + return(FALSE); } - /* - * Check more IRP's flags. - */ - Flags = Irp->Flags; - if ( !(IRP_MOUNT_COMPLETION & Flags) - || (IRP_SYNCHRONOUS_PAGING_IO & Flags) - ) - { - return TRUE; - } - /* - * Otherwise, it is an - * asynchronous operation. - */ - return FALSE; + } + + /* Check more IRP's flags. */ + Flags = Irp->Flags; + if (!(IRP_MOUNT_COMPLETION & Flags) + || (IRP_SYNCHRONOUS_PAGING_IO & Flags)) + { + return(TRUE); + } + + /* Otherwise, it is an asynchronous operation. */ + return(FALSE); } -VOID -STDCALL -IoEnqueueIrp ( - PIRP Irp - ) +VOID STDCALL +IoEnqueueIrp(IN PIRP Irp) { - UNIMPLEMENTED; + UNIMPLEMENTED; } -VOID -STDCALL -IoSetTopLevelIrp ( - IN PIRP Irp - ) +VOID STDCALL +IoSetTopLevelIrp(IN PIRP Irp) { - PETHREAD Thread; + PETHREAD Thread; - Thread = PsGetCurrentThread (); - Thread->TopLevelIrp->TopLevelIrp = Irp; + Thread = PsGetCurrentThread(); + Thread->TopLevelIrp->TopLevelIrp = Irp; } -PIRP -STDCALL -IoGetTopLevelIrp ( - VOID - ) +PIRP STDCALL +IoGetTopLevelIrp(VOID) { - return (PsGetCurrentThread ()->TopLevelIrp->TopLevelIrp); + return(PsGetCurrentThread()->TopLevelIrp->TopLevelIrp); } -VOID -STDCALL -IoQueueThreadIrp ( - PVOID Unknown0 - ) +VOID STDCALL +IoQueueThreadIrp(IN PIRP Irp) { - UNIMPLEMENTED; + UNIMPLEMENTED; } /* EOF */ diff --git a/reactos/ntoskrnl/io/vpb.c b/reactos/ntoskrnl/io/vpb.c index c7a6eb88ba4..a1c9ae20179 100644 --- a/reactos/ntoskrnl/io/vpb.c +++ b/reactos/ntoskrnl/io/vpb.c @@ -1,4 +1,4 @@ -/* $Id: vpb.c,v 1.14 2001/11/02 22:22:33 hbirr Exp $ +/* $Id: vpb.c,v 1.15 2002/04/10 09:57:31 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -376,14 +376,4 @@ IoReleaseVpbSpinLock(IN KIRQL Irql) Irql); } - -NTSTATUS STDCALL -IoVerifyVolume(IN PDEVICE_OBJECT DeviceObject, - IN BOOLEAN AllowRawMount) -{ - UNIMPLEMENTED; - return(STATUS_NOT_IMPLEMENTED); -} - - /* EOF */