3 * Copyright (C) 2002 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
23 * FILE: services/fs/cdfs/finfo.c
24 * PURPOSE: CDROM (ISO 9660) filesystem driver
25 * PROGRAMMER: Art Yerkes
30 /* INCLUDES *****************************************************************/
32 #include <ddk/ntddk.h>
40 /* FUNCTIONS ****************************************************************/
43 CdfsGetStandardInformation(PFCB Fcb,
44 PDEVICE_OBJECT DeviceObject,
45 PFILE_STANDARD_INFORMATION StandardInfo,
48 * FUNCTION: Retrieve the standard file information
51 DPRINT("CdfsGetStandardInformation() called\n");
53 if (*BufferLength < sizeof(FILE_STANDARD_INFORMATION))
54 return STATUS_BUFFER_OVERFLOW;
57 assert(StandardInfo != NULL);
60 RtlZeroMemory(StandardInfo,
61 sizeof(FILE_STANDARD_INFORMATION));
63 StandardInfo->AllocationSize = Fcb->RFCB.AllocationSize;
64 StandardInfo->EndOfFile = Fcb->RFCB.FileSize;
65 StandardInfo->NumberOfLinks = 0;
66 StandardInfo->DeletePending = FALSE;
67 StandardInfo->Directory = Fcb->Entry.FileFlags & 0x02 ? TRUE : FALSE;
69 *BufferLength -= sizeof(FILE_STANDARD_INFORMATION);
70 return(STATUS_SUCCESS);
75 CdfsGetPositionInformation(PFILE_OBJECT FileObject,
76 PFILE_POSITION_INFORMATION PositionInfo,
79 DPRINT("CdfsGetPositionInformation() called\n");
81 if (*BufferLength < sizeof(FILE_POSITION_INFORMATION))
82 return STATUS_BUFFER_OVERFLOW;
84 PositionInfo->CurrentByteOffset.QuadPart =
85 FileObject->CurrentByteOffset.QuadPart;
87 DPRINT("Getting position %I64x\n",
88 PositionInfo->CurrentByteOffset.QuadPart);
90 *BufferLength -= sizeof(FILE_POSITION_INFORMATION);
91 return(STATUS_SUCCESS);
96 CdfsGetBasicInformation(PFILE_OBJECT FileObject,
98 PDEVICE_OBJECT DeviceObject,
99 PFILE_BASIC_INFORMATION BasicInfo,
102 DPRINT("CdfsGetBasicInformation() called\n");
104 if (*BufferLength < sizeof(FILE_BASIC_INFORMATION))
105 return STATUS_BUFFER_OVERFLOW;
107 CdfsDateTimeToFileTime(Fcb,
108 &BasicInfo->CreationTime);
109 CdfsDateTimeToFileTime(Fcb,
110 &BasicInfo->LastAccessTime);
111 CdfsDateTimeToFileTime(Fcb,
112 &BasicInfo->LastWriteTime);
113 CdfsDateTimeToFileTime(Fcb,
114 &BasicInfo->ChangeTime);
116 CdfsFileFlagsToAttributes(Fcb,
117 &BasicInfo->FileAttributes);
119 *BufferLength -= sizeof(FILE_BASIC_INFORMATION);
121 return(STATUS_SUCCESS);
126 CdfsGetNameInformation(PFILE_OBJECT FileObject,
128 PDEVICE_OBJECT DeviceObject,
129 PFILE_NAME_INFORMATION NameInfo,
132 * FUNCTION: Retrieve the file name information
137 DPRINT("CdfsGetNameInformation() called\n");
139 assert(NameInfo != NULL);
142 NameLength = wcslen(Fcb->PathName) * sizeof(WCHAR);
143 if (*BufferLength < sizeof(FILE_NAME_INFORMATION) + NameLength)
144 return STATUS_BUFFER_OVERFLOW;
146 NameInfo->FileNameLength = NameLength;
147 RtlCopyMemory(NameInfo->FileName,
149 NameLength + sizeof(WCHAR));
152 (sizeof(FILE_NAME_INFORMATION) + NameLength + sizeof(WCHAR));
154 return STATUS_SUCCESS;
159 CdfsGetInternalInformation(PFCB Fcb,
160 PFILE_INTERNAL_INFORMATION InternalInfo,
163 DPRINT("CdfsGetInternalInformation() called\n");
165 assert(InternalInfo);
168 if (*BufferLength < sizeof(FILE_INTERNAL_INFORMATION))
169 return(STATUS_BUFFER_OVERFLOW);
171 /* FIXME: get a real index, that can be used in a create operation */
172 InternalInfo->IndexNumber.QuadPart = 0;
174 *BufferLength -= sizeof(FILE_INTERNAL_INFORMATION);
176 return(STATUS_SUCCESS);
181 CdfsGetNetworkOpenInformation(PFCB Fcb,
182 PFILE_NETWORK_OPEN_INFORMATION NetworkInfo,
185 * FUNCTION: Retrieve the file network open information
191 if (*BufferLength < sizeof(FILE_NETWORK_OPEN_INFORMATION))
192 return(STATUS_BUFFER_OVERFLOW);
194 CdfsDateTimeToFileTime(Fcb,
195 &NetworkInfo->CreationTime);
196 CdfsDateTimeToFileTime(Fcb,
197 &NetworkInfo->LastAccessTime);
198 CdfsDateTimeToFileTime(Fcb,
199 &NetworkInfo->LastWriteTime);
200 CdfsDateTimeToFileTime(Fcb,
201 &NetworkInfo->ChangeTime);
202 NetworkInfo->AllocationSize = Fcb->RFCB.AllocationSize;
203 NetworkInfo->EndOfFile = Fcb->RFCB.FileSize;
204 CdfsFileFlagsToAttributes(Fcb,
205 &NetworkInfo->FileAttributes);
207 *BufferLength -= sizeof(FILE_NETWORK_OPEN_INFORMATION);
209 return(STATUS_SUCCESS);
214 CdfsGetAllInformation(PFILE_OBJECT FileObject,
216 PFILE_ALL_INFORMATION Info,
219 * FUNCTION: Retrieve the all file information
227 NameLength = wcslen(Fcb->PathName) * sizeof(WCHAR);
228 if (*BufferLength < sizeof(FILE_ALL_INFORMATION) + NameLength)
229 return(STATUS_BUFFER_OVERFLOW);
231 /* Basic Information */
232 CdfsDateTimeToFileTime(Fcb,
233 &Info->BasicInformation.CreationTime);
234 CdfsDateTimeToFileTime(Fcb,
235 &Info->BasicInformation.LastAccessTime);
236 CdfsDateTimeToFileTime(Fcb,
237 &Info->BasicInformation.LastWriteTime);
238 CdfsDateTimeToFileTime(Fcb,
239 &Info->BasicInformation.ChangeTime);
240 CdfsFileFlagsToAttributes(Fcb,
241 &Info->BasicInformation.FileAttributes);
243 /* Standard Information */
244 Info->StandardInformation.AllocationSize = Fcb->RFCB.AllocationSize;
245 Info->StandardInformation.EndOfFile = Fcb->RFCB.FileSize;
246 Info->StandardInformation.NumberOfLinks = 0;
247 Info->StandardInformation.DeletePending = FALSE;
248 Info->StandardInformation.Directory = Fcb->Entry.FileFlags & 0x02 ? TRUE : FALSE;
250 /* Internal Information */
251 /* FIXME: get a real index, that can be used in a create operation */
252 Info->InternalInformation.IndexNumber.QuadPart = 0;
255 Info->EaInformation.EaSize = 0;
257 /* Access Information */
258 /* The IO-Manager adds this information */
260 /* Position Information */
261 Info->PositionInformation.CurrentByteOffset.QuadPart = FileObject->CurrentByteOffset.QuadPart;
263 /* Mode Information */
264 /* The IO-Manager adds this information */
266 /* Alignment Information */
267 /* The IO-Manager adds this information */
269 /* Name Information */
270 Info->NameInformation.FileNameLength = NameLength;
271 RtlCopyMemory(Info->NameInformation.FileName,
273 NameLength + sizeof(WCHAR));
275 *BufferLength -= (sizeof(FILE_ALL_INFORMATION) + NameLength + sizeof(WCHAR));
277 return STATUS_SUCCESS;
281 CdfsSetPositionInformation(PFILE_OBJECT FileObject,
282 PFILE_POSITION_INFORMATION PositionInfo)
284 DPRINT ("CdfsSetPositionInformation()\n");
286 DPRINT ("PositionInfo %x\n", PositionInfo);
287 DPRINT ("Setting position %d\n", PositionInfo->CurrentByteOffset.u.LowPart);
288 memcpy (&FileObject->CurrentByteOffset, &PositionInfo->CurrentByteOffset,
289 sizeof (LARGE_INTEGER));
291 return (STATUS_SUCCESS);
295 CdfsQueryInformation(PDEVICE_OBJECT DeviceObject,
298 * FUNCTION: Retrieve the specified file information
301 FILE_INFORMATION_CLASS FileInformationClass;
302 PIO_STACK_LOCATION Stack;
303 PFILE_OBJECT FileObject;
308 NTSTATUS Status = STATUS_SUCCESS;
310 DPRINT("CdfsQueryInformation() called\n");
312 Stack = IoGetCurrentIrpStackLocation(Irp);
313 FileInformationClass = Stack->Parameters.QueryFile.FileInformationClass;
314 FileObject = Stack->FileObject;
315 Fcb = FileObject->FsContext;
317 SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
318 BufferLength = Stack->Parameters.QueryFile.Length;
320 switch (FileInformationClass)
322 case FileStandardInformation:
323 Status = CdfsGetStandardInformation(Fcb,
329 case FilePositionInformation:
330 Status = CdfsGetPositionInformation(FileObject,
335 case FileBasicInformation:
336 Status = CdfsGetBasicInformation(FileObject,
343 case FileNameInformation:
344 Status = CdfsGetNameInformation(FileObject,
351 case FileInternalInformation:
352 Status = CdfsGetInternalInformation(Fcb,
357 case FileNetworkOpenInformation:
358 Status = CdfsGetNetworkOpenInformation(Fcb,
363 case FileAllInformation:
364 Status = CdfsGetAllInformation(FileObject,
370 case FileAlternateNameInformation:
371 Status = STATUS_NOT_IMPLEMENTED;
375 DPRINT("Unimplemented information class %u\n", FileInformationClass);
376 Status = STATUS_NOT_SUPPORTED;
379 Irp->IoStatus.Status = Status;
380 if (NT_SUCCESS(Status))
381 Irp->IoStatus.Information =
382 Stack->Parameters.QueryFile.Length - BufferLength;
384 Irp->IoStatus.Information = 0;
386 IoCompleteRequest(Irp, IO_NO_INCREMENT);
392 CdfsSetInformation(PDEVICE_OBJECT DeviceObject,
395 * FUNCTION: Retrieve the specified file information
398 FILE_INFORMATION_CLASS FileInformationClass;
399 PIO_STACK_LOCATION Stack;
400 PFILE_OBJECT FileObject;
404 NTSTATUS Status = STATUS_SUCCESS;
406 DPRINT1("CdfsSetInformation() called\n");
408 Stack = IoGetCurrentIrpStackLocation(Irp);
409 FileInformationClass = Stack->Parameters.SetFile.FileInformationClass;
410 FileObject = Stack->FileObject;
411 Fcb = FileObject->FsContext;
413 SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
415 switch (FileInformationClass)
417 case FilePositionInformation:
418 Status = CdfsSetPositionInformation(FileObject,
421 case FileBasicInformation:
422 case FileRenameInformation:
423 Status = STATUS_NOT_IMPLEMENTED;
426 Status = STATUS_NOT_SUPPORTED;
429 Irp->IoStatus.Status = Status;
430 Irp->IoStatus.Information = 0;
432 IoCompleteRequest(Irp, IO_NO_INCREMENT);