2001-07-29 16:41:25 +00:00
|
|
|
/* $Id: rw.c,v 1.3 2001/07/29 16:40:20 ekohl Exp $
|
2000-03-26 22:00:10 +00:00
|
|
|
*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
|
|
|
* FILE: services/fs/np/rw.c
|
|
|
|
* PURPOSE: Named pipe filesystem
|
|
|
|
* PROGRAMMER: David Welch <welch@cwcom.net>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
|
|
|
|
#include <ddk/ntddk.h>
|
2001-05-01 11:09:01 +00:00
|
|
|
#include "npfs.h"
|
2000-03-26 22:00:10 +00:00
|
|
|
|
|
|
|
//#define NDEBUG
|
2001-05-01 11:09:01 +00:00
|
|
|
#include <debug.h>
|
2000-03-26 22:00:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
|
2001-05-01 11:09:01 +00:00
|
|
|
NTSTATUS STDCALL
|
|
|
|
NpfsRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
2000-03-26 22:00:10 +00:00
|
|
|
{
|
|
|
|
PIO_STACK_LOCATION IoStack;
|
|
|
|
PFILE_OBJECT FileObject;
|
|
|
|
NTSTATUS Status;
|
|
|
|
PNPFS_DEVICE_EXTENSION DeviceExt;
|
|
|
|
PWSTR PipeName;
|
2001-05-01 11:09:01 +00:00
|
|
|
// PNPFS_FSCONTEXT PipeDescr;
|
2000-03-26 22:00:10 +00:00
|
|
|
KIRQL oldIrql;
|
|
|
|
PLIST_ENTRY current_entry;
|
2001-05-01 11:09:01 +00:00
|
|
|
// PNPFS_CONTEXT current;
|
2000-03-26 22:00:10 +00:00
|
|
|
ULONG Information;
|
|
|
|
|
2001-07-29 16:41:25 +00:00
|
|
|
DPRINT1("NpfsRead()\n");
|
|
|
|
|
2000-03-26 22:00:10 +00:00
|
|
|
DeviceExt = (PNPFS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
|
|
|
IoStack = IoGetCurrentIrpStackLocation(Irp);
|
|
|
|
FileObject = IoStack->FileObject;
|
2001-05-01 11:09:01 +00:00
|
|
|
|
|
|
|
Status = STATUS_SUCCESS;
|
|
|
|
Information = 0;
|
|
|
|
|
|
|
|
#if 0
|
2000-03-26 22:00:10 +00:00
|
|
|
PipeDescr = FileObject->FsContext;
|
|
|
|
|
|
|
|
if (PipeType & NPFS_READMODE_BYTE)
|
|
|
|
{
|
|
|
|
PLIST_ENTRY current_entry;
|
|
|
|
PNPFS_MSG current;
|
|
|
|
KIRQL oldIrql;
|
|
|
|
ULONG Length;
|
|
|
|
PVOID Buffer;
|
|
|
|
|
|
|
|
KeAcquireSpinLock(&PipeDescr->MsgListLock, &oldIrql);
|
|
|
|
current_entry = PipeDescr->MsgListHead.Flink;
|
|
|
|
Information = 0;
|
|
|
|
Length = IoStack->Parameters.Read.Length;
|
|
|
|
Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
|
|
|
|
while (Length > 0 &&
|
|
|
|
current_entry != &PipeDescr->MsgListHead)
|
|
|
|
{
|
|
|
|
current = CONTAINING_RECORD(current_entry,
|
|
|
|
NPFS_MSG,
|
|
|
|
ListEntry);
|
|
|
|
|
|
|
|
memcpy(Buffer, current->Buffer, current->Length);
|
|
|
|
Buffer = Buffer + current->Length;
|
|
|
|
Length = Length - current->Length;
|
|
|
|
Information = Information + current->Length;
|
|
|
|
|
|
|
|
current_entry = current_entry->Flink;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
}
|
2001-05-01 11:09:01 +00:00
|
|
|
#endif
|
2000-03-26 22:00:10 +00:00
|
|
|
|
|
|
|
Irp->IoStatus.Status = Status;
|
|
|
|
Irp->IoStatus.Information = Information;
|
|
|
|
|
|
|
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
|
|
|
|
|
|
|
return(Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-01 11:09:01 +00:00
|
|
|
NTSTATUS STDCALL
|
|
|
|
NpfsWrite(PDEVICE_OBJECT DeviceObject,
|
|
|
|
PIRP Irp)
|
|
|
|
{
|
2001-07-29 16:41:25 +00:00
|
|
|
PIO_STACK_LOCATION IoStack;
|
|
|
|
PFILE_OBJECT FileObject;
|
|
|
|
PNPFS_FCB Fcb = NULL;
|
|
|
|
PNPFS_PIPE Pipe = NULL;
|
|
|
|
PUCHAR Buffer;
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
ULONG Length;
|
|
|
|
ULONG Offset;
|
2001-05-01 11:09:01 +00:00
|
|
|
|
2001-07-29 16:41:25 +00:00
|
|
|
DPRINT("NpfsWrite()\n");
|
2001-05-01 11:09:01 +00:00
|
|
|
|
2001-07-29 16:41:25 +00:00
|
|
|
IoStack = IoGetCurrentIrpStackLocation(Irp);
|
|
|
|
FileObject = IoStack->FileObject;
|
|
|
|
DPRINT("FileObject %p\n", FileObject);
|
|
|
|
DPRINT("Pipe name %wZ\n", &FileObject->FileName);
|
2001-05-01 11:09:01 +00:00
|
|
|
|
2001-07-29 16:41:25 +00:00
|
|
|
Fcb = FileObject->FsContext;
|
|
|
|
Pipe = Fcb->Pipe;
|
|
|
|
|
|
|
|
Length = IoStack->Parameters.Write.Length;
|
|
|
|
Buffer = MmGetSystemAddressForMdl (Irp->MdlAddress);
|
|
|
|
Offset = IoStack->Parameters.Write.ByteOffset.u.LowPart;
|
|
|
|
|
|
|
|
|
|
|
|
Irp->IoStatus.Status = Status;
|
|
|
|
Irp->IoStatus.Information = Length;
|
|
|
|
|
|
|
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
|
|
|
|
|
|
|
return(Status);
|
2001-05-01 11:09:01 +00:00
|
|
|
}
|
|
|
|
|
2000-03-26 22:00:10 +00:00
|
|
|
/* EOF */
|