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.2 2002/05/01 13:15:42 ekohl Exp $
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
23 * FILE: services/fs/cdfs/dirctl.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 memcpy(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 CdfsQueryInformation(PDEVICE_OBJECT DeviceObject
,
184 * FUNCTION: Retrieve the specified file information
187 FILE_INFORMATION_CLASS FileInformationClass
;
188 PIO_STACK_LOCATION Stack
;
189 PFILE_OBJECT FileObject
;
194 NTSTATUS Status
= STATUS_SUCCESS
;
196 DPRINT("CdfsQueryInformation() called\n");
198 Stack
= IoGetCurrentIrpStackLocation(Irp
);
199 FileInformationClass
= Stack
->Parameters
.QueryFile
.FileInformationClass
;
200 FileObject
= Stack
->FileObject
;
201 Fcb
= FileObject
->FsContext
;
203 SystemBuffer
= Irp
->AssociatedIrp
.SystemBuffer
;
204 BufferLength
= Stack
->Parameters
.QueryFile
.Length
;
206 switch (FileInformationClass
)
208 case FileStandardInformation
:
209 Status
= CdfsGetStandardInformation(Fcb
,
215 case FilePositionInformation
:
216 Status
= CdfsGetPositionInformation(FileObject
,
221 case FileBasicInformation
:
222 Status
= CdfsGetBasicInformation(FileObject
,
229 case FileNameInformation
:
230 Status
= CdfsGetNameInformation(FileObject
,
237 case FileInternalInformation
:
238 Status
= CdfsGetInternalInformation(Fcb
,
243 case FileAlternateNameInformation
:
244 case FileAllInformation
:
245 Status
= STATUS_NOT_IMPLEMENTED
;
249 DPRINT("Unimplemented information class %u\n", FileInformationClass
);
250 Status
= STATUS_NOT_SUPPORTED
;
253 Irp
->IoStatus
.Status
= Status
;
254 if (NT_SUCCESS(Status
))
255 Irp
->IoStatus
.Information
=
256 Stack
->Parameters
.QueryFile
.Length
- BufferLength
;
258 Irp
->IoStatus
.Information
= 0;
260 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);