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 ******************************************************************/
19 /* FUNCTIONS *****************************************************************/
22 MsfsQueryMailslotInformation(PMSFS_FCB Fcb
,
23 PFILE_MAILSLOT_QUERY_INFORMATION Buffer
,
26 PMSFS_MAILSLOT Mailslot
;
29 if (*BufferLength
< sizeof(FILE_MAILSLOT_QUERY_INFORMATION
))
30 return(STATUS_BUFFER_OVERFLOW
);
32 Mailslot
= Fcb
->Mailslot
;
34 Buffer
->MaximumMessageSize
= Mailslot
->MaxMessageSize
;
35 Buffer
->ReadTimeout
= Mailslot
->TimeOut
;
37 KeAcquireSpinLock(&Mailslot
->MessageListLock
, &oldIrql
);
38 Buffer
->MessagesAvailable
= Mailslot
->MessageCount
;
39 if (Mailslot
->MessageCount
== 0)
41 Buffer
->NextMessageSize
= 0;
45 /* FIXME: read size of first message (head) */
46 Buffer
->NextMessageSize
= 0;
48 KeReleaseSpinLock(&Mailslot
->MessageListLock
, oldIrql
);
50 *BufferLength
-= sizeof(FILE_MAILSLOT_QUERY_INFORMATION
);
52 return(STATUS_SUCCESS
);
57 MsfsSetMailslotInformation(PMSFS_FCB Fcb
,
58 PFILE_MAILSLOT_SET_INFORMATION Buffer
,
61 if (*BufferLength
< sizeof(FILE_MAILSLOT_SET_INFORMATION
))
62 return(STATUS_BUFFER_OVERFLOW
);
64 Fcb
->Mailslot
->TimeOut
= Buffer
->ReadTimeout
;
66 return(STATUS_SUCCESS
);
71 MsfsQueryInformation(PDEVICE_OBJECT DeviceObject
,
74 PIO_STACK_LOCATION IoStack
;
75 FILE_INFORMATION_CLASS FileInformationClass
;
76 PFILE_OBJECT FileObject
;
77 PMSFS_DEVICE_EXTENSION DeviceExtension
;
79 PMSFS_MAILSLOT Mailslot
;
84 DPRINT("MsfsQueryInformation(DeviceObject %p Irp %p)\n", DeviceObject
, Irp
);
86 IoStack
= IoGetCurrentIrpStackLocation (Irp
);
87 FileInformationClass
= IoStack
->Parameters
.QueryFile
.FileInformationClass
;
88 DeviceExtension
= DeviceObject
->DeviceExtension
;
89 FileObject
= IoStack
->FileObject
;
90 Fcb
= (PMSFS_FCB
)FileObject
->FsContext
;
91 Mailslot
= Fcb
->Mailslot
;
93 DPRINT("Mailslot name: %wZ\n", &Mailslot
->Name
);
95 /* querying information is not permitted on client side */
96 if (Fcb
->Mailslot
->ServerFcb
!= Fcb
)
98 Status
= STATUS_ACCESS_DENIED
;
100 Irp
->IoStatus
.Status
= Status
;
101 Irp
->IoStatus
.Information
= 0;
103 IoCompleteRequest(Irp
,
109 SystemBuffer
= Irp
->AssociatedIrp
.SystemBuffer
;
110 BufferLength
= IoStack
->Parameters
.QueryFile
.Length
;
112 switch (FileInformationClass
)
114 case FileMailslotQueryInformation
:
115 Status
= MsfsQueryMailslotInformation(Fcb
,
120 Status
= STATUS_NOT_IMPLEMENTED
;
123 Irp
->IoStatus
.Status
= Status
;
124 if (NT_SUCCESS(Status
))
125 Irp
->IoStatus
.Information
=
126 IoStack
->Parameters
.QueryFile
.Length
- BufferLength
;
128 Irp
->IoStatus
.Information
= 0;
129 IoCompleteRequest(Irp
,
137 MsfsSetInformation(PDEVICE_OBJECT DeviceObject
,
140 PIO_STACK_LOCATION IoStack
;
141 FILE_INFORMATION_CLASS FileInformationClass
;
142 PFILE_OBJECT FileObject
;
144 PMSFS_MAILSLOT Mailslot
;
149 DPRINT("MsfsSetInformation(DeviceObject %p Irp %p)\n", DeviceObject
, Irp
);
151 IoStack
= IoGetCurrentIrpStackLocation (Irp
);
152 FileInformationClass
= IoStack
->Parameters
.QueryFile
.FileInformationClass
;
153 FileObject
= IoStack
->FileObject
;
154 Fcb
= (PMSFS_FCB
)FileObject
->FsContext
;
155 Mailslot
= Fcb
->Mailslot
;
157 DPRINT("Mailslot name: %wZ\n", &Mailslot
->Name
);
159 /* setting information is not permitted on client side */
160 if (Fcb
->Mailslot
->ServerFcb
!= Fcb
)
162 Status
= STATUS_ACCESS_DENIED
;
164 Irp
->IoStatus
.Status
= Status
;
165 Irp
->IoStatus
.Information
= 0;
167 IoCompleteRequest(Irp
,
173 SystemBuffer
= Irp
->AssociatedIrp
.SystemBuffer
;
174 BufferLength
= IoStack
->Parameters
.QueryFile
.Length
;
176 DPRINT("FileInformationClass %d\n", FileInformationClass
);
177 DPRINT("SystemBuffer %x\n", SystemBuffer
);
179 switch (FileInformationClass
)
181 case FileMailslotSetInformation
:
182 Status
= MsfsSetMailslotInformation(Fcb
,
187 Status
= STATUS_NOT_IMPLEMENTED
;
190 Irp
->IoStatus
.Status
= Status
;
191 Irp
->IoStatus
.Information
= 0;
192 IoCompleteRequest(Irp
,