ReactOS  0.4.13-dev-482-ge57f103
finfo.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS kernel
4  * FILE: drivers/filesystems/msfs/finfo.c
5  * PURPOSE: Mailslot filesystem
6  * PROGRAMMER: Eric Kohl
7  */
8 
9 /* INCLUDES ******************************************************************/
10 
11 #include "msfs.h"
12 
13 #define NDEBUG
14 #include <debug.h>
15 
16 #undef MAILSLOT_NO_MESSAGE
17 #undef MAILSLOT_WAIT_FOREVER
18 #define MAILSLOT_NO_MESSAGE MAXULONG
19 #define MAILSLOT_WAIT_FOREVER MAXULONG
20 
21 /* FUNCTIONS *****************************************************************/
22 
23 static NTSTATUS
27 {
28  KIRQL oldIrql;
29 
32 
33  Buffer->MaximumMessageSize = Fcb->MaxMessageSize;
34  Buffer->ReadTimeout = Fcb->TimeOut;
35 
36  KeAcquireSpinLock(&Fcb->MessageListLock, &oldIrql);
37  Buffer->MessagesAvailable = Fcb->MessageCount;
38  if (Fcb->MessageCount == 0)
39  {
40  Buffer->NextMessageSize = MAILSLOT_NO_MESSAGE;
41  }
42  else
43  {
44  PMSFS_MESSAGE Message = CONTAINING_RECORD(Fcb->MessageListHead.Flink,
46  MessageListEntry);
47  Buffer->NextMessageSize = Message->Size;
48  }
49  KeReleaseSpinLock(&Fcb->MessageListLock, oldIrql);
50 
52 
53  return STATUS_SUCCESS;
54 }
55 
56 
57 static NTSTATUS
61 {
64 
65  Fcb->TimeOut = *Buffer->ReadTimeout;
66 
67  return STATUS_SUCCESS;
68 }
69 
70 
73  PIRP Irp)
74 {
75  PIO_STACK_LOCATION IoStack;
78  PMSFS_FCB Fcb;
79  PMSFS_CCB Ccb;
80  PVOID SystemBuffer;
83 
84  DPRINT("MsfsQueryInformation(DeviceObject %p Irp %p)\n",
85  DeviceObject, Irp);
86 
88  FileInformationClass = IoStack->Parameters.QueryFile.FileInformationClass;
89  FileObject = IoStack->FileObject;
90  Fcb = (PMSFS_FCB)FileObject->FsContext;
91  Ccb = (PMSFS_CCB)FileObject->FsContext2;
92 
93  DPRINT("Mailslot name: %wZ\n", &Fcb->Name);
94 
95  /* querying information is not permitted on client side */
96  if (Fcb->ServerCcb != Ccb)
97  {
99 
100  Irp->IoStatus.Status = Status;
101  Irp->IoStatus.Information = 0;
102 
104 
105  return Status;
106  }
107 
108  SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
109  BufferLength = IoStack->Parameters.QueryFile.Length;
110 
111  switch (FileInformationClass)
112  {
115  SystemBuffer,
116  &BufferLength);
117  break;
118 
119  default:
121  }
122 
123  Irp->IoStatus.Status = Status;
124  if (NT_SUCCESS(Status))
125  Irp->IoStatus.Information =
126  IoStack->Parameters.QueryFile.Length - BufferLength;
127  else
128  Irp->IoStatus.Information = 0;
130 
131  return Status;
132 }
133 
134 
137  PIRP Irp)
138 {
139  PIO_STACK_LOCATION IoStack;
142  PMSFS_FCB Fcb;
143  PMSFS_CCB Ccb;
144  PVOID SystemBuffer;
147 
148  DPRINT("MsfsSetInformation(DeviceObject %p Irp %p)\n", DeviceObject, Irp);
149 
150  IoStack = IoGetCurrentIrpStackLocation (Irp);
151  FileInformationClass = IoStack->Parameters.QueryFile.FileInformationClass;
152  FileObject = IoStack->FileObject;
153  Fcb = (PMSFS_FCB)FileObject->FsContext;
154  Ccb = (PMSFS_CCB)FileObject->FsContext2;
155 
156  DPRINT("Mailslot name: %wZ\n", &Fcb->Name);
157 
158  /* setting information is not permitted on client side */
159  if (Fcb->ServerCcb != Ccb)
160  {
162 
163  Irp->IoStatus.Status = Status;
164  Irp->IoStatus.Information = 0;
165 
167 
168  return Status;
169  }
170 
171  SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
172  BufferLength = IoStack->Parameters.QueryFile.Length;
173 
174  DPRINT("FileInformationClass %d\n", FileInformationClass);
175  DPRINT("SystemBuffer %p\n", SystemBuffer);
176 
177  switch (FileInformationClass)
178  {
181  SystemBuffer,
182  &BufferLength);
183  break;
184 
185  default:
187  }
188 
189  Irp->IoStatus.Status = Status;
190  Irp->IoStatus.Information = 0;
192 
193  return Status;
194 }
195 
196 /* EOF */
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
_In_ PIRP Irp
Definition: csq.h:116
struct _FILE_MAILSLOT_QUERY_INFORMATION FILE_MAILSLOT_QUERY_INFORMATION
LONG NTSTATUS
Definition: precomp.h:26
static OUT PIO_STATUS_BLOCK OUT PVOID IN ULONG IN FILE_INFORMATION_CLASS FileInformationClass
Definition: pipe.c:75
NTSTATUS DEFAULTAPI MsfsQueryInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: finfo.c:72
UCHAR KIRQL
Definition: env_spec_w32.h:591
_In_ ULONG BufferLength
Definition: usbdlib.h:225
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
struct _MSFS_FCB * PMSFS_FCB
static NTSTATUS MsfsQueryMailslotInformation(PMSFS_FCB Fcb, PFILE_MAILSLOT_QUERY_INFORMATION Buffer, PULONG BufferLength)
Definition: finfo.c:24
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
enum _FILE_INFORMATION_CLASS FILE_INFORMATION_CLASS
Definition: directory.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
static NTSTATUS MsfsSetMailslotInformation(PMSFS_FCB Fcb, PFILE_MAILSLOT_SET_INFORMATION Buffer, PULONG BufferLength)
Definition: finfo.c:58
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
* PFILE_OBJECT
Definition: iotypes.h:1954
#define MAILSLOT_NO_MESSAGE
Definition: finfo.c:18
CHAR Message[80]
Definition: alive.c:5
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:593
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2812
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
unsigned int * PULONG
Definition: retypes.h:1
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define DEFAULTAPI
Definition: msfs.h:15
NTSTATUS DEFAULTAPI MsfsSetInformation(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Definition: finfo.c:136
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:565
Definition: msfs.h:24
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
_In_ PFCB Fcb
Definition: cdprocs.h:151
return STATUS_SUCCESS
Definition: btrfs.c:2777
Definition: msfs.h:54