3 * Copyright (C) 2002, 2004 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 * FUNCTION: Retrieve the standard file information
46 CdfsGetStandardInformation(PFCB Fcb
,
47 PDEVICE_OBJECT DeviceObject
,
48 PFILE_STANDARD_INFORMATION StandardInfo
,
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 if (CdfsFCBIsDirectory(Fcb
))
65 StandardInfo
->AllocationSize
.QuadPart
= 0LL;
66 StandardInfo
->EndOfFile
.QuadPart
= 0LL;
67 StandardInfo
->Directory
= TRUE
;
71 StandardInfo
->AllocationSize
= Fcb
->RFCB
.AllocationSize
;
72 StandardInfo
->EndOfFile
= Fcb
->RFCB
.FileSize
;
73 StandardInfo
->Directory
= FALSE
;
75 StandardInfo
->NumberOfLinks
= 0;
76 StandardInfo
->DeletePending
= FALSE
;
78 *BufferLength
-= sizeof(FILE_STANDARD_INFORMATION
);
79 return(STATUS_SUCCESS
);
84 * FUNCTION: Retrieve the file position information
87 CdfsGetPositionInformation(PFILE_OBJECT FileObject
,
88 PFILE_POSITION_INFORMATION PositionInfo
,
91 DPRINT("CdfsGetPositionInformation() called\n");
93 if (*BufferLength
< sizeof(FILE_POSITION_INFORMATION
))
94 return STATUS_BUFFER_OVERFLOW
;
96 PositionInfo
->CurrentByteOffset
.QuadPart
=
97 FileObject
->CurrentByteOffset
.QuadPart
;
99 DPRINT("Getting position %I64x\n",
100 PositionInfo
->CurrentByteOffset
.QuadPart
);
102 *BufferLength
-= sizeof(FILE_POSITION_INFORMATION
);
103 return(STATUS_SUCCESS
);
108 * FUNCTION: Retrieve the basic file information
111 CdfsGetBasicInformation(PFILE_OBJECT FileObject
,
113 PDEVICE_OBJECT DeviceObject
,
114 PFILE_BASIC_INFORMATION BasicInfo
,
117 DPRINT("CdfsGetBasicInformation() called\n");
119 if (*BufferLength
< sizeof(FILE_BASIC_INFORMATION
))
120 return STATUS_BUFFER_OVERFLOW
;
122 CdfsDateTimeToSystemTime(Fcb
,
123 &BasicInfo
->CreationTime
);
124 CdfsDateTimeToSystemTime(Fcb
,
125 &BasicInfo
->LastAccessTime
);
126 CdfsDateTimeToSystemTime(Fcb
,
127 &BasicInfo
->LastWriteTime
);
128 CdfsDateTimeToSystemTime(Fcb
,
129 &BasicInfo
->ChangeTime
);
131 CdfsFileFlagsToAttributes(Fcb
,
132 &BasicInfo
->FileAttributes
);
134 *BufferLength
-= sizeof(FILE_BASIC_INFORMATION
);
136 return(STATUS_SUCCESS
);
141 * FUNCTION: Retrieve the file name information
144 CdfsGetNameInformation(PFILE_OBJECT FileObject
,
146 PDEVICE_OBJECT DeviceObject
,
147 PFILE_NAME_INFORMATION NameInfo
,
152 DPRINT("CdfsGetNameInformation() called\n");
154 ASSERT(NameInfo
!= NULL
);
157 NameLength
= wcslen(Fcb
->PathName
) * sizeof(WCHAR
);
158 if (*BufferLength
< sizeof(FILE_NAME_INFORMATION
) + NameLength
)
159 return STATUS_BUFFER_OVERFLOW
;
161 NameInfo
->FileNameLength
= NameLength
;
162 RtlCopyMemory(NameInfo
->FileName
,
164 NameLength
+ sizeof(WCHAR
));
167 (sizeof(FILE_NAME_INFORMATION
) + NameLength
+ sizeof(WCHAR
));
169 return STATUS_SUCCESS
;
174 * FUNCTION: Retrieve the internal file information
177 CdfsGetInternalInformation(PFCB Fcb
,
178 PFILE_INTERNAL_INFORMATION InternalInfo
,
181 DPRINT("CdfsGetInternalInformation() called\n");
183 ASSERT(InternalInfo
);
186 if (*BufferLength
< sizeof(FILE_INTERNAL_INFORMATION
))
187 return(STATUS_BUFFER_OVERFLOW
);
189 InternalInfo
->IndexNumber
.QuadPart
= Fcb
->IndexNumber
.QuadPart
;
191 *BufferLength
-= sizeof(FILE_INTERNAL_INFORMATION
);
193 return(STATUS_SUCCESS
);
198 * FUNCTION: Retrieve the file network open information
201 CdfsGetNetworkOpenInformation(PFCB Fcb
,
202 PFILE_NETWORK_OPEN_INFORMATION NetworkInfo
,
208 if (*BufferLength
< sizeof(FILE_NETWORK_OPEN_INFORMATION
))
209 return(STATUS_BUFFER_OVERFLOW
);
211 CdfsDateTimeToSystemTime(Fcb
,
212 &NetworkInfo
->CreationTime
);
213 CdfsDateTimeToSystemTime(Fcb
,
214 &NetworkInfo
->LastAccessTime
);
215 CdfsDateTimeToSystemTime(Fcb
,
216 &NetworkInfo
->LastWriteTime
);
217 CdfsDateTimeToSystemTime(Fcb
,
218 &NetworkInfo
->ChangeTime
);
219 if (CdfsFCBIsDirectory(Fcb
))
221 NetworkInfo
->AllocationSize
.QuadPart
= 0LL;
222 NetworkInfo
->EndOfFile
.QuadPart
= 0LL;
226 NetworkInfo
->AllocationSize
= Fcb
->RFCB
.AllocationSize
;
227 NetworkInfo
->EndOfFile
= Fcb
->RFCB
.FileSize
;
229 CdfsFileFlagsToAttributes(Fcb
,
230 &NetworkInfo
->FileAttributes
);
232 *BufferLength
-= sizeof(FILE_NETWORK_OPEN_INFORMATION
);
234 return(STATUS_SUCCESS
);
239 * FUNCTION: Retrieve all file information
242 CdfsGetAllInformation(PFILE_OBJECT FileObject
,
244 PFILE_ALL_INFORMATION Info
,
252 NameLength
= wcslen(Fcb
->PathName
) * sizeof(WCHAR
);
253 if (*BufferLength
< sizeof(FILE_ALL_INFORMATION
) + NameLength
)
254 return(STATUS_BUFFER_OVERFLOW
);
256 /* Basic Information */
257 CdfsDateTimeToSystemTime(Fcb
,
258 &Info
->BasicInformation
.CreationTime
);
259 CdfsDateTimeToSystemTime(Fcb
,
260 &Info
->BasicInformation
.LastAccessTime
);
261 CdfsDateTimeToSystemTime(Fcb
,
262 &Info
->BasicInformation
.LastWriteTime
);
263 CdfsDateTimeToSystemTime(Fcb
,
264 &Info
->BasicInformation
.ChangeTime
);
265 CdfsFileFlagsToAttributes(Fcb
,
266 &Info
->BasicInformation
.FileAttributes
);
268 /* Standard Information */
269 if (CdfsFCBIsDirectory(Fcb
))
271 Info
->StandardInformation
.AllocationSize
.QuadPart
= 0LL;
272 Info
->StandardInformation
.EndOfFile
.QuadPart
= 0LL;
273 Info
->StandardInformation
.Directory
= TRUE
;
277 Info
->StandardInformation
.AllocationSize
= Fcb
->RFCB
.AllocationSize
;
278 Info
->StandardInformation
.EndOfFile
= Fcb
->RFCB
.FileSize
;
279 Info
->StandardInformation
.Directory
= FALSE
;
281 Info
->StandardInformation
.NumberOfLinks
= 0;
282 Info
->StandardInformation
.DeletePending
= FALSE
;
284 /* Internal Information */
285 Info
->InternalInformation
.IndexNumber
.QuadPart
= Fcb
->IndexNumber
.QuadPart
;
288 Info
->EaInformation
.EaSize
= 0;
290 /* Access Information */
291 /* The IO-Manager adds this information */
293 /* Position Information */
294 Info
->PositionInformation
.CurrentByteOffset
.QuadPart
= FileObject
->CurrentByteOffset
.QuadPart
;
296 /* Mode Information */
297 /* The IO-Manager adds this information */
299 /* Alignment Information */
300 /* The IO-Manager adds this information */
302 /* Name Information */
303 Info
->NameInformation
.FileNameLength
= NameLength
;
304 RtlCopyMemory(Info
->NameInformation
.FileName
,
306 NameLength
+ sizeof(WCHAR
));
308 *BufferLength
-= (sizeof(FILE_ALL_INFORMATION
) + NameLength
+ sizeof(WCHAR
));
310 return STATUS_SUCCESS
;
315 * FUNCTION: Retrieve the specified file information
318 CdfsQueryInformation(PDEVICE_OBJECT DeviceObject
,
321 FILE_INFORMATION_CLASS FileInformationClass
;
322 PIO_STACK_LOCATION Stack
;
323 PFILE_OBJECT FileObject
;
328 NTSTATUS Status
= STATUS_SUCCESS
;
330 DPRINT("CdfsQueryInformation() called\n");
332 Stack
= IoGetCurrentIrpStackLocation(Irp
);
333 FileInformationClass
= Stack
->Parameters
.QueryFile
.FileInformationClass
;
334 FileObject
= Stack
->FileObject
;
335 Fcb
= FileObject
->FsContext
;
337 SystemBuffer
= Irp
->AssociatedIrp
.SystemBuffer
;
338 BufferLength
= Stack
->Parameters
.QueryFile
.Length
;
340 switch (FileInformationClass
)
342 case FileStandardInformation
:
343 Status
= CdfsGetStandardInformation(Fcb
,
349 case FilePositionInformation
:
350 Status
= CdfsGetPositionInformation(FileObject
,
355 case FileBasicInformation
:
356 Status
= CdfsGetBasicInformation(FileObject
,
363 case FileNameInformation
:
364 Status
= CdfsGetNameInformation(FileObject
,
371 case FileInternalInformation
:
372 Status
= CdfsGetInternalInformation(Fcb
,
377 case FileNetworkOpenInformation
:
378 Status
= CdfsGetNetworkOpenInformation(Fcb
,
383 case FileAllInformation
:
384 Status
= CdfsGetAllInformation(FileObject
,
390 case FileAlternateNameInformation
:
391 Status
= STATUS_NOT_IMPLEMENTED
;
395 DPRINT("Unimplemented information class %u\n", FileInformationClass
);
396 Status
= STATUS_NOT_SUPPORTED
;
400 Irp
->IoStatus
.Status
= Status
;
401 if (NT_SUCCESS(Status
))
402 Irp
->IoStatus
.Information
=
403 Stack
->Parameters
.QueryFile
.Length
- BufferLength
;
405 Irp
->IoStatus
.Information
= 0;
407 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
414 * FUNCTION: Set the file position information
417 CdfsSetPositionInformation(PFILE_OBJECT FileObject
,
418 PFILE_POSITION_INFORMATION PositionInfo
)
420 DPRINT ("CdfsSetPositionInformation()\n");
422 DPRINT ("PositionInfo %x\n", PositionInfo
);
423 DPRINT ("Setting position %I64u\n", PositionInfo
->CurrentByteOffset
.QuadPart
);
425 FileObject
->CurrentByteOffset
.QuadPart
=
426 PositionInfo
->CurrentByteOffset
.QuadPart
;
428 return STATUS_SUCCESS
;
433 * FUNCTION: Set the specified file information
436 CdfsSetInformation(PDEVICE_OBJECT DeviceObject
,
439 FILE_INFORMATION_CLASS FileInformationClass
;
440 PIO_STACK_LOCATION Stack
;
441 PFILE_OBJECT FileObject
;
445 NTSTATUS Status
= STATUS_SUCCESS
;
447 DPRINT("CdfsSetInformation() called\n");
449 Stack
= IoGetCurrentIrpStackLocation(Irp
);
450 FileInformationClass
= Stack
->Parameters
.SetFile
.FileInformationClass
;
451 FileObject
= Stack
->FileObject
;
452 Fcb
= FileObject
->FsContext
;
454 SystemBuffer
= Irp
->AssociatedIrp
.SystemBuffer
;
456 switch (FileInformationClass
)
458 case FilePositionInformation
:
459 Status
= CdfsSetPositionInformation(FileObject
,
463 case FileBasicInformation
:
464 case FileRenameInformation
:
465 Status
= STATUS_NOT_IMPLEMENTED
;
469 Status
= STATUS_NOT_SUPPORTED
;
473 Irp
->IoStatus
.Status
= Status
;
474 Irp
->IoStatus
.Information
= 0;
476 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);