2005-09-04 21:44:02 +00:00
|
|
|
/*
|
2007-04-18 01:25:28 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
|
|
|
* FILE: drivers/fs/np/mount.c
|
|
|
|
* PURPOSE: Named pipe filesystem
|
|
|
|
* PROGRAMMER: David Welch <welch@cwcom.net>
|
|
|
|
*/
|
1999-11-24 11:51:55 +00:00
|
|
|
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
|
2007-04-18 01:51:27 +00:00
|
|
|
#include "npfs.h"
|
|
|
|
|
2001-10-21 18:58:32 +00:00
|
|
|
#define NDEBUG
|
2001-05-01 11:09:01 +00:00
|
|
|
#include <debug.h>
|
1999-11-24 11:51:55 +00:00
|
|
|
|
2000-03-26 22:00:10 +00:00
|
|
|
/* FUNCTIONS *****************************************************************/
|
1999-11-24 11:51:55 +00:00
|
|
|
|
2008-11-29 20:14:45 +00:00
|
|
|
NTSTATUS NTAPI
|
2001-05-10 23:38:31 +00:00
|
|
|
DriverEntry(PDRIVER_OBJECT DriverObject,
|
2009-02-08 09:04:42 +00:00
|
|
|
PUNICODE_STRING RegistryPath)
|
1999-11-24 11:51:55 +00:00
|
|
|
{
|
2009-02-08 09:04:42 +00:00
|
|
|
PDEVICE_OBJECT DeviceObject;
|
|
|
|
UNICODE_STRING DeviceName;
|
2010-11-19 22:42:53 +00:00
|
|
|
PNPFS_VCB Vcb;
|
|
|
|
PNPFS_FCB Fcb;
|
2009-02-08 09:04:42 +00:00
|
|
|
NTSTATUS Status;
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2009-02-08 09:04:42 +00:00
|
|
|
DPRINT("Named Pipe FSD 0.0.2\n");
|
2005-03-28 18:42:53 +00:00
|
|
|
|
2009-02-08 09:04:42 +00:00
|
|
|
ASSERT (sizeof(NPFS_CONTEXT) <= FIELD_OFFSET(IRP, Tail.Overlay.DriverContext));
|
|
|
|
ASSERT (sizeof(NPFS_WAITER_ENTRY) <= FIELD_OFFSET(IRP, Tail.Overlay.DriverContext));
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2009-02-08 09:04:42 +00:00
|
|
|
DriverObject->MajorFunction[IRP_MJ_CREATE] = NpfsCreate;
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_CREATE_NAMED_PIPE] =
|
|
|
|
NpfsCreateNamedPipe;
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_CLOSE] = NpfsClose;
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_READ] = NpfsRead;
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_WRITE] = NpfsWrite;
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] =
|
|
|
|
NpfsQueryInformation;
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_SET_INFORMATION] =
|
|
|
|
NpfsSetInformation;
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] =
|
|
|
|
NpfsQueryVolumeInformation;
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_CLEANUP] = NpfsCleanup;
|
|
|
|
DriverObject->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = NpfsFlushBuffers;
|
2011-01-01 12:40:24 +00:00
|
|
|
DriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] =
|
|
|
|
NpfsDirectoryControl;
|
2009-02-08 09:04:42 +00:00
|
|
|
DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] =
|
|
|
|
NpfsFileSystemControl;
|
|
|
|
// DriverObject->MajorFunction[IRP_MJ_QUERY_SECURITY] =
|
|
|
|
// NpfsQuerySecurity;
|
|
|
|
// DriverObject->MajorFunction[IRP_MJ_SET_SECURITY] =
|
|
|
|
// NpfsSetSecurity;
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2009-02-08 09:04:42 +00:00
|
|
|
DriverObject->DriverUnload = NULL;
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2009-02-08 09:04:42 +00:00
|
|
|
RtlInitUnicodeString(&DeviceName, L"\\Device\\NamedPipe");
|
|
|
|
Status = IoCreateDevice(DriverObject,
|
2010-11-19 22:42:53 +00:00
|
|
|
sizeof(NPFS_VCB),
|
2009-02-08 09:04:42 +00:00
|
|
|
&DeviceName,
|
|
|
|
FILE_DEVICE_NAMED_PIPE,
|
|
|
|
0,
|
|
|
|
FALSE,
|
|
|
|
&DeviceObject);
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
DPRINT("Failed to create named pipe device! (Status %x)\n", Status);
|
|
|
|
return Status;
|
|
|
|
}
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2010-11-19 22:42:53 +00:00
|
|
|
/* Initialize the device object */
|
2009-02-08 09:04:42 +00:00
|
|
|
DeviceObject->Flags |= DO_DIRECT_IO;
|
2010-06-01 09:12:32 +00:00
|
|
|
DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;
|
2005-05-08 02:16:32 +00:00
|
|
|
|
2010-11-19 22:42:53 +00:00
|
|
|
/* Initialize the Volume Control Block (VCB) */
|
|
|
|
Vcb = (PNPFS_VCB)DeviceObject->DeviceExtension;
|
|
|
|
InitializeListHead(&Vcb->PipeListHead);
|
|
|
|
InitializeListHead(&Vcb->ThreadListHead);
|
|
|
|
KeInitializeMutex(&Vcb->PipeListLock, 0);
|
|
|
|
Vcb->EmptyWaiterCount = 0;
|
2001-10-21 18:58:32 +00:00
|
|
|
|
2009-02-08 09:04:42 +00:00
|
|
|
/* set the size quotas */
|
2010-11-19 22:42:53 +00:00
|
|
|
Vcb->MinQuota = PAGE_SIZE;
|
|
|
|
Vcb->DefaultQuota = 8 * PAGE_SIZE;
|
|
|
|
Vcb->MaxQuota = 64 * PAGE_SIZE;
|
|
|
|
|
2010-11-22 23:08:11 +00:00
|
|
|
/* Create the device FCB */
|
2011-07-06 18:14:42 +00:00
|
|
|
Fcb = ExAllocatePoolWithTag(NonPagedPool, sizeof(NPFS_FCB), TAG_NPFS_FCB);
|
2010-11-22 23:08:11 +00:00
|
|
|
Fcb->Type = FCB_DEVICE;
|
2010-11-19 22:42:53 +00:00
|
|
|
Fcb->Vcb = Vcb;
|
2010-11-22 23:08:11 +00:00
|
|
|
Vcb->DeviceFcb = Fcb;
|
2010-11-19 22:42:53 +00:00
|
|
|
|
2010-11-22 23:08:11 +00:00
|
|
|
/* Create the root directory FCB */
|
2011-07-06 18:14:42 +00:00
|
|
|
Fcb = ExAllocatePoolWithTag(NonPagedPool, sizeof(NPFS_FCB), TAG_NPFS_FCB);
|
2010-11-22 23:08:11 +00:00
|
|
|
Fcb->Type = FCB_DIRECTORY;
|
|
|
|
Fcb->Vcb = Vcb;
|
2010-11-19 22:42:53 +00:00
|
|
|
Vcb->RootFcb = Fcb;
|
2001-10-21 18:58:32 +00:00
|
|
|
|
2009-02-08 09:04:42 +00:00
|
|
|
return STATUS_SUCCESS;
|
1999-11-24 11:51:55 +00:00
|
|
|
}
|
1999-12-04 20:58:45 +00:00
|
|
|
|
2011-01-01 12:40:24 +00:00
|
|
|
|
|
|
|
FCB_TYPE
|
|
|
|
NpfsGetFcb(PFILE_OBJECT FileObject,
|
|
|
|
PNPFS_FCB *Fcb)
|
|
|
|
{
|
|
|
|
PNPFS_FCB LocalFcb = NULL;
|
|
|
|
FCB_TYPE FcbType = FCB_INVALID;
|
|
|
|
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
LocalFcb = (PNPFS_FCB)FileObject->FsContext;
|
|
|
|
FcbType = LocalFcb->Type;
|
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
LocalFcb = NULL;
|
|
|
|
FcbType = FCB_INVALID;
|
|
|
|
}
|
|
|
|
_SEH2_END;
|
|
|
|
|
|
|
|
*Fcb = LocalFcb;
|
|
|
|
|
|
|
|
return FcbType;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CCB_TYPE
|
|
|
|
NpfsGetCcb(PFILE_OBJECT FileObject,
|
|
|
|
PNPFS_CCB *Ccb)
|
|
|
|
{
|
|
|
|
PNPFS_CCB LocalCcb = NULL;
|
|
|
|
CCB_TYPE CcbType = CCB_INVALID;
|
|
|
|
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
LocalCcb = (PNPFS_CCB)FileObject->FsContext2;
|
|
|
|
CcbType = LocalCcb->Type;
|
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
LocalCcb = NULL;
|
|
|
|
CcbType = CCB_INVALID;
|
|
|
|
}
|
|
|
|
_SEH2_END;
|
|
|
|
|
|
|
|
*Ccb = LocalCcb;
|
|
|
|
|
|
|
|
return CcbType;
|
|
|
|
}
|
|
|
|
|
1999-12-04 20:58:45 +00:00
|
|
|
/* EOF */
|