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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19 * COPYRIGHT: See COPYING in the top level directory
20 * PROJECT: ReactOS kernel
21 * FILE: drivers/filesystem/ntfs/dirctl.c
22 * PURPOSE: NTFS filesystem driver
23 * PROGRAMMERS: Eric Kohl
24 * Hervé Poussineau (hpoussin@reactos.org)
27 /* INCLUDES *****************************************************************/
34 /* FUNCTIONS ****************************************************************/
37 * FUNCTION: Retrieve the standard file information
41 NtfsGetStandardInformation(PNTFS_FCB Fcb
,
42 PDEVICE_OBJECT DeviceObject
,
43 PFILE_STANDARD_INFORMATION StandardInfo
,
46 UNREFERENCED_PARAMETER(DeviceObject
);
48 DPRINT("NtfsGetStandardInformation() called\n");
50 if (*BufferLength
< sizeof(FILE_STANDARD_INFORMATION
))
51 return STATUS_BUFFER_OVERFLOW
;
54 ASSERT(StandardInfo
!= NULL
);
57 RtlZeroMemory(StandardInfo
,
58 sizeof(FILE_STANDARD_INFORMATION
));
60 StandardInfo
->AllocationSize
= Fcb
->RFCB
.AllocationSize
;
61 StandardInfo
->EndOfFile
= Fcb
->RFCB
.FileSize
;
62 StandardInfo
->NumberOfLinks
= 0;
63 StandardInfo
->DeletePending
= FALSE
;
64 StandardInfo
->Directory
= NtfsFCBIsDirectory(Fcb
);
66 *BufferLength
-= sizeof(FILE_STANDARD_INFORMATION
);
68 return STATUS_SUCCESS
;
74 NtfsGetPositionInformation(PFILE_OBJECT FileObject
,
75 PFILE_POSITION_INFORMATION PositionInfo
,
78 UNREFERENCED_PARAMETER(FileObject
);
80 DPRINT("NtfsGetPositionInformation() called\n");
82 if (*BufferLength
< sizeof(FILE_POSITION_INFORMATION
))
83 return STATUS_BUFFER_OVERFLOW
;
85 PositionInfo
->CurrentByteOffset
.QuadPart
= 0;
86 // FileObject->CurrentByteOffset.QuadPart;
88 DPRINT("Getting position %I64x\n",
89 PositionInfo
->CurrentByteOffset
.QuadPart
);
91 *BufferLength
-= sizeof(FILE_POSITION_INFORMATION
);
93 return STATUS_SUCCESS
;
99 NtfsGetBasicInformation(PFILE_OBJECT FileObject
,
101 PDEVICE_OBJECT DeviceObject
,
102 PFILE_BASIC_INFORMATION BasicInfo
,
105 DPRINT("NtfsGetBasicInformation() called\n");
107 if (*BufferLength
< sizeof(FILE_BASIC_INFORMATION
))
108 return STATUS_BUFFER_OVERFLOW
;
111 CdfsDateTimeToFileTime(Fcb
,
112 &BasicInfo
->CreationTime
);
113 CdfsDateTimeToFileTime(Fcb
,
114 &BasicInfo
->LastAccessTime
);
115 CdfsDateTimeToFileTime(Fcb
,
116 &BasicInfo
->LastWriteTime
);
117 CdfsDateTimeToFileTime(Fcb
,
118 &BasicInfo
->ChangeTime
);
120 CdfsFileFlagsToAttributes(Fcb
,
121 &BasicInfo
->FileAttributes
);
123 UNREFERENCED_PARAMETER(FileObject
);
124 UNREFERENCED_PARAMETER(Fcb
);
125 UNREFERENCED_PARAMETER(DeviceObject
);
126 UNREFERENCED_PARAMETER(BasicInfo
);
129 *BufferLength
-= sizeof(FILE_BASIC_INFORMATION
);
131 return STATUS_SUCCESS
;
136 * FUNCTION: Retrieve the file name information
140 NtfsGetNameInformation(PFILE_OBJECT FileObject
,
142 PDEVICE_OBJECT DeviceObject
,
143 PFILE_NAME_INFORMATION NameInfo
,
148 UNREFERENCED_PARAMETER(FileObject
);
149 UNREFERENCED_PARAMETER(DeviceObject
);
151 DPRINT("NtfsGetNameInformation() called\n");
153 ASSERT(NameInfo
!= NULL
);
156 NameLength
= wcslen(Fcb
->PathName
) * sizeof(WCHAR
);
158 if (*BufferLength
< sizeof(FILE_NAME_INFORMATION
) + NameLength
)
159 return STATUS_BUFFER_OVERFLOW
;
161 NameInfo
->FileNameLength
= NameLength
;
162 memcpy(NameInfo
->FileName
,
164 NameLength
+ sizeof(WCHAR
));
165 // wcscpy(NameInfo->FileName, L"\\");
167 *BufferLength
-= (sizeof(FILE_NAME_INFORMATION
) + NameLength
+ sizeof(WCHAR
));
169 return STATUS_SUCCESS
;
175 NtfsGetInternalInformation(PNTFS_FCB Fcb
,
176 PFILE_INTERNAL_INFORMATION InternalInfo
,
179 DPRINT("NtfsGetInternalInformation() called\n");
181 ASSERT(InternalInfo
);
184 if (*BufferLength
< sizeof(FILE_INTERNAL_INFORMATION
))
185 return STATUS_BUFFER_OVERFLOW
;
187 /* FIXME: get a real index, that can be used in a create operation */
188 InternalInfo
->IndexNumber
.QuadPart
= 0;
190 *BufferLength
-= sizeof(FILE_INTERNAL_INFORMATION
);
192 return STATUS_SUCCESS
;
197 * FUNCTION: Retrieve the specified file information
201 NtfsFsdQueryInformation(PDEVICE_OBJECT DeviceObject
,
204 FILE_INFORMATION_CLASS FileInformationClass
;
205 PIO_STACK_LOCATION Stack
;
206 PFILE_OBJECT FileObject
;
210 NTSTATUS Status
= STATUS_SUCCESS
;
212 DPRINT("NtfsQueryInformation() called\n");
214 Stack
= IoGetCurrentIrpStackLocation(Irp
);
215 FileInformationClass
= Stack
->Parameters
.QueryFile
.FileInformationClass
;
216 FileObject
= Stack
->FileObject
;
217 Fcb
= FileObject
->FsContext
;
219 SystemBuffer
= Irp
->AssociatedIrp
.SystemBuffer
;
220 BufferLength
= Stack
->Parameters
.QueryFile
.Length
;
222 switch (FileInformationClass
)
224 case FileStandardInformation
:
225 Status
= NtfsGetStandardInformation(Fcb
,
231 case FilePositionInformation
:
232 Status
= NtfsGetPositionInformation(FileObject
,
237 case FileBasicInformation
:
238 Status
= NtfsGetBasicInformation(FileObject
,
245 case FileNameInformation
:
246 Status
= NtfsGetNameInformation(FileObject
,
253 case FileInternalInformation
:
254 Status
= NtfsGetInternalInformation(Fcb
,
259 case FileAlternateNameInformation
:
260 case FileAllInformation
:
261 Status
= STATUS_NOT_IMPLEMENTED
;
265 DPRINT("Unimplemented information class %u\n", FileInformationClass
);
266 Status
= STATUS_INVALID_PARAMETER
;
269 Irp
->IoStatus
.Status
= Status
;
271 if (NT_SUCCESS(Status
))
272 Irp
->IoStatus
.Information
=
273 Stack
->Parameters
.QueryFile
.Length
- BufferLength
;
275 Irp
->IoStatus
.Information
= 0;
277 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);