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.
19 /* $Id: finfo.c,v 1.4 2002/07/20 11:44:24 ekohl Exp $
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
;
282 CdfsQueryInformation(PDEVICE_OBJECT DeviceObject
,
285 * FUNCTION: Retrieve the specified file information
288 FILE_INFORMATION_CLASS FileInformationClass
;
289 PIO_STACK_LOCATION Stack
;
290 PFILE_OBJECT FileObject
;
295 NTSTATUS Status
= STATUS_SUCCESS
;
297 DPRINT("CdfsQueryInformation() called\n");
299 Stack
= IoGetCurrentIrpStackLocation(Irp
);
300 FileInformationClass
= Stack
->Parameters
.QueryFile
.FileInformationClass
;
301 FileObject
= Stack
->FileObject
;
302 Fcb
= FileObject
->FsContext
;
304 SystemBuffer
= Irp
->AssociatedIrp
.SystemBuffer
;
305 BufferLength
= Stack
->Parameters
.QueryFile
.Length
;
307 switch (FileInformationClass
)
309 case FileStandardInformation
:
310 Status
= CdfsGetStandardInformation(Fcb
,
316 case FilePositionInformation
:
317 Status
= CdfsGetPositionInformation(FileObject
,
322 case FileBasicInformation
:
323 Status
= CdfsGetBasicInformation(FileObject
,
330 case FileNameInformation
:
331 Status
= CdfsGetNameInformation(FileObject
,
338 case FileInternalInformation
:
339 Status
= CdfsGetInternalInformation(Fcb
,
344 case FileNetworkOpenInformation
:
345 Status
= CdfsGetNetworkOpenInformation(Fcb
,
350 case FileAllInformation
:
351 Status
= CdfsGetAllInformation(FileObject
,
357 case FileAlternateNameInformation
:
358 Status
= STATUS_NOT_IMPLEMENTED
;
362 DPRINT("Unimplemented information class %u\n", FileInformationClass
);
363 Status
= STATUS_NOT_SUPPORTED
;
366 Irp
->IoStatus
.Status
= Status
;
367 if (NT_SUCCESS(Status
))
368 Irp
->IoStatus
.Information
=
369 Stack
->Parameters
.QueryFile
.Length
- BufferLength
;
371 Irp
->IoStatus
.Information
= 0;
373 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);