3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: services/fs/ms/finfo.c
6 * PURPOSE: Mailslot filesystem
7 * PROGRAMMER: Eric Kohl <ekohl@rz-online.de>
10 /* INCLUDES ******************************************************************/
18 /* FUNCTIONS *****************************************************************/
21 MsfsQueryMailslotInformation(PMSFS_FCB Fcb
,
22 PFILE_MAILSLOT_QUERY_INFORMATION Buffer
,
25 PMSFS_MAILSLOT Mailslot
;
28 if (*BufferLength
< sizeof(FILE_MAILSLOT_QUERY_INFORMATION
))
29 return(STATUS_BUFFER_OVERFLOW
);
31 Mailslot
= Fcb
->Mailslot
;
33 Buffer
->MaximumMessageSize
= Mailslot
->MaxMessageSize
;
34 Buffer
->ReadTimeout
= Mailslot
->TimeOut
;
36 KeAcquireSpinLock(&Mailslot
->MessageListLock
, &oldIrql
);
37 Buffer
->MessagesAvailable
= Mailslot
->MessageCount
;
38 if (Mailslot
->MessageCount
== 0)
40 Buffer
->NextMessageSize
= 0;
44 /* FIXME: read size of first message (head) */
45 Buffer
->NextMessageSize
= 0;
47 KeReleaseSpinLock(&Mailslot
->MessageListLock
, oldIrql
);
49 *BufferLength
-= sizeof(FILE_MAILSLOT_QUERY_INFORMATION
);
51 return(STATUS_SUCCESS
);
56 MsfsSetMailslotInformation(PMSFS_FCB Fcb
,
57 PFILE_MAILSLOT_SET_INFORMATION Buffer
,
60 if (*BufferLength
< sizeof(FILE_MAILSLOT_SET_INFORMATION
))
61 return(STATUS_BUFFER_OVERFLOW
);
63 Fcb
->Mailslot
->TimeOut
= *Buffer
->ReadTimeout
;
65 return(STATUS_SUCCESS
);
70 MsfsQueryInformation(PDEVICE_OBJECT DeviceObject
,
73 PIO_STACK_LOCATION IoStack
;
74 FILE_INFORMATION_CLASS FileInformationClass
;
75 PFILE_OBJECT FileObject
;
76 PMSFS_DEVICE_EXTENSION DeviceExtension
;
78 PMSFS_MAILSLOT Mailslot
;
83 DPRINT("MsfsQueryInformation(DeviceObject %p Irp %p)\n", DeviceObject
, Irp
);
85 IoStack
= IoGetCurrentIrpStackLocation (Irp
);
86 FileInformationClass
= IoStack
->Parameters
.QueryFile
.FileInformationClass
;
87 DeviceExtension
= DeviceObject
->DeviceExtension
;
88 FileObject
= IoStack
->FileObject
;
89 Fcb
= (PMSFS_FCB
)FileObject
->FsContext
;
90 Mailslot
= Fcb
->Mailslot
;
92 DPRINT("Mailslot name: %wZ\n", &Mailslot
->Name
);
94 /* querying information is not permitted on client side */
95 if (Fcb
->Mailslot
->ServerFcb
!= Fcb
)
97 Status
= STATUS_ACCESS_DENIED
;
99 Irp
->IoStatus
.Status
= Status
;
100 Irp
->IoStatus
.Information
= 0;
102 IoCompleteRequest(Irp
,
108 SystemBuffer
= Irp
->AssociatedIrp
.SystemBuffer
;
109 BufferLength
= IoStack
->Parameters
.QueryFile
.Length
;
111 switch (FileInformationClass
)
113 case FileMailslotQueryInformation
:
114 Status
= MsfsQueryMailslotInformation(Fcb
,
119 Status
= STATUS_NOT_IMPLEMENTED
;
122 Irp
->IoStatus
.Status
= Status
;
123 if (NT_SUCCESS(Status
))
124 Irp
->IoStatus
.Information
=
125 IoStack
->Parameters
.QueryFile
.Length
- BufferLength
;
127 Irp
->IoStatus
.Information
= 0;
128 IoCompleteRequest(Irp
,
136 MsfsSetInformation(PDEVICE_OBJECT DeviceObject
,
139 PIO_STACK_LOCATION IoStack
;
140 FILE_INFORMATION_CLASS FileInformationClass
;
141 PFILE_OBJECT FileObject
;
143 PMSFS_MAILSLOT Mailslot
;
148 DPRINT("MsfsSetInformation(DeviceObject %p Irp %p)\n", DeviceObject
, Irp
);
150 IoStack
= IoGetCurrentIrpStackLocation (Irp
);
151 FileInformationClass
= IoStack
->Parameters
.QueryFile
.FileInformationClass
;
152 FileObject
= IoStack
->FileObject
;
153 Fcb
= (PMSFS_FCB
)FileObject
->FsContext
;
154 Mailslot
= Fcb
->Mailslot
;
156 DPRINT("Mailslot name: %wZ\n", &Mailslot
->Name
);
158 /* setting information is not permitted on client side */
159 if (Fcb
->Mailslot
->ServerFcb
!= Fcb
)
161 Status
= STATUS_ACCESS_DENIED
;
163 Irp
->IoStatus
.Status
= Status
;
164 Irp
->IoStatus
.Information
= 0;
166 IoCompleteRequest(Irp
,
172 SystemBuffer
= Irp
->AssociatedIrp
.SystemBuffer
;
173 BufferLength
= IoStack
->Parameters
.QueryFile
.Length
;
175 DPRINT("FileInformationClass %d\n", FileInformationClass
);
176 DPRINT("SystemBuffer %x\n", SystemBuffer
);
178 switch (FileInformationClass
)
180 case FileMailslotSetInformation
:
181 Status
= MsfsSetMailslotInformation(Fcb
,
186 Status
= STATUS_NOT_IMPLEMENTED
;
189 Irp
->IoStatus
.Status
= Status
;
190 Irp
->IoStatus
.Information
= 0;
191 IoCompleteRequest(Irp
,