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 * PROGRAMMER: Eric Kohl
26 /* INCLUDES *****************************************************************/
33 /* GLOBALS *****************************************************************/
36 /* FUNCTIONS ****************************************************************/
39 * FUNCTION: Retrieve the standard file information
43 NtfsGetStandardInformation(PNTFS_FCB Fcb
,
44 PDEVICE_OBJECT DeviceObject
,
45 PFILE_STANDARD_INFORMATION StandardInfo
,
48 UNREFERENCED_PARAMETER(DeviceObject
);
50 DPRINT("NtfsGetStandardInformation() called\n");
52 if (*BufferLength
< sizeof(FILE_STANDARD_INFORMATION
))
53 return STATUS_BUFFER_OVERFLOW
;
56 ASSERT(StandardInfo
!= NULL
);
59 RtlZeroMemory(StandardInfo
,
60 sizeof(FILE_STANDARD_INFORMATION
));
62 StandardInfo
->AllocationSize
= Fcb
->RFCB
.AllocationSize
;
63 StandardInfo
->EndOfFile
= Fcb
->RFCB
.FileSize
;
64 StandardInfo
->NumberOfLinks
= 0;
65 StandardInfo
->DeletePending
= FALSE
;
66 StandardInfo
->Directory
= NtfsFCBIsDirectory(Fcb
);
68 *BufferLength
-= sizeof(FILE_STANDARD_INFORMATION
);
70 return STATUS_SUCCESS
;
76 NtfsGetPositionInformation(PFILE_OBJECT FileObject
,
77 PFILE_POSITION_INFORMATION PositionInfo
,
80 UNREFERENCED_PARAMETER(FileObject
);
82 DPRINT("NtfsGetPositionInformation() called\n");
84 if (*BufferLength
< sizeof(FILE_POSITION_INFORMATION
))
85 return STATUS_BUFFER_OVERFLOW
;
87 PositionInfo
->CurrentByteOffset
.QuadPart
= 0;
88 // FileObject->CurrentByteOffset.QuadPart;
90 DPRINT("Getting position %I64x\n",
91 PositionInfo
->CurrentByteOffset
.QuadPart
);
93 *BufferLength
-= sizeof(FILE_POSITION_INFORMATION
);
95 return STATUS_SUCCESS
;
101 NtfsGetBasicInformation(PFILE_OBJECT FileObject
,
103 PDEVICE_OBJECT DeviceObject
,
104 PFILE_BASIC_INFORMATION BasicInfo
,
107 DPRINT("NtfsGetBasicInformation() called\n");
109 if (*BufferLength
< sizeof(FILE_BASIC_INFORMATION
))
110 return STATUS_BUFFER_OVERFLOW
;
113 CdfsDateTimeToFileTime(Fcb
,
114 &BasicInfo
->CreationTime
);
115 CdfsDateTimeToFileTime(Fcb
,
116 &BasicInfo
->LastAccessTime
);
117 CdfsDateTimeToFileTime(Fcb
,
118 &BasicInfo
->LastWriteTime
);
119 CdfsDateTimeToFileTime(Fcb
,
120 &BasicInfo
->ChangeTime
);
122 CdfsFileFlagsToAttributes(Fcb
,
123 &BasicInfo
->FileAttributes
);
125 UNREFERENCED_PARAMETER(FileObject
);
126 UNREFERENCED_PARAMETER(Fcb
);
127 UNREFERENCED_PARAMETER(DeviceObject
);
128 UNREFERENCED_PARAMETER(BasicInfo
);
131 *BufferLength
-= sizeof(FILE_BASIC_INFORMATION
);
133 return STATUS_SUCCESS
;
138 * FUNCTION: Retrieve the file name information
142 NtfsGetNameInformation(PFILE_OBJECT FileObject
,
144 PDEVICE_OBJECT DeviceObject
,
145 PFILE_NAME_INFORMATION NameInfo
,
150 UNREFERENCED_PARAMETER(FileObject
);
151 UNREFERENCED_PARAMETER(DeviceObject
);
153 DPRINT("NtfsGetNameInformation() called\n");
155 ASSERT(NameInfo
!= NULL
);
158 NameLength
= wcslen(Fcb
->PathName
) * sizeof(WCHAR
);
160 if (*BufferLength
< sizeof(FILE_NAME_INFORMATION
) + NameLength
)
161 return STATUS_BUFFER_OVERFLOW
;
163 NameInfo
->FileNameLength
= NameLength
;
164 memcpy(NameInfo
->FileName
,
166 NameLength
+ sizeof(WCHAR
));
167 // wcscpy(NameInfo->FileName, L"\\");
169 *BufferLength
-= (sizeof(FILE_NAME_INFORMATION
) + NameLength
+ sizeof(WCHAR
));
171 return STATUS_SUCCESS
;
177 NtfsGetInternalInformation(PNTFS_FCB Fcb
,
178 PFILE_INTERNAL_INFORMATION InternalInfo
,
181 DPRINT("NtfsGetInternalInformation() called\n");
183 ASSERT(InternalInfo
);
186 if (*BufferLength
< sizeof(FILE_INTERNAL_INFORMATION
))
187 return STATUS_BUFFER_OVERFLOW
;
189 /* FIXME: get a real index, that can be used in a create operation */
190 InternalInfo
->IndexNumber
.QuadPart
= 0;
192 *BufferLength
-= sizeof(FILE_INTERNAL_INFORMATION
);
194 return STATUS_SUCCESS
;
199 * FUNCTION: Retrieve the specified file information
203 NtfsFsdQueryInformation(PDEVICE_OBJECT DeviceObject
,
206 FILE_INFORMATION_CLASS FileInformationClass
;
207 PIO_STACK_LOCATION Stack
;
208 PFILE_OBJECT FileObject
;
212 NTSTATUS Status
= STATUS_SUCCESS
;
214 DPRINT("NtfsQueryInformation() called\n");
216 Stack
= IoGetCurrentIrpStackLocation(Irp
);
217 FileInformationClass
= Stack
->Parameters
.QueryFile
.FileInformationClass
;
218 FileObject
= Stack
->FileObject
;
219 Fcb
= FileObject
->FsContext
;
221 SystemBuffer
= Irp
->AssociatedIrp
.SystemBuffer
;
222 BufferLength
= Stack
->Parameters
.QueryFile
.Length
;
224 switch (FileInformationClass
)
226 case FileStandardInformation
:
227 Status
= NtfsGetStandardInformation(Fcb
,
233 case FilePositionInformation
:
234 Status
= NtfsGetPositionInformation(FileObject
,
239 case FileBasicInformation
:
240 Status
= NtfsGetBasicInformation(FileObject
,
247 case FileNameInformation
:
248 Status
= NtfsGetNameInformation(FileObject
,
255 case FileInternalInformation
:
256 Status
= NtfsGetInternalInformation(Fcb
,
261 case FileAlternateNameInformation
:
262 case FileAllInformation
:
263 Status
= STATUS_NOT_IMPLEMENTED
;
267 DPRINT("Unimplemented information class %u\n", FileInformationClass
);
268 Status
= STATUS_INVALID_PARAMETER
;
271 Irp
->IoStatus
.Status
= Status
;
273 if (NT_SUCCESS(Status
))
274 Irp
->IoStatus
.Information
=
275 Stack
->Parameters
.QueryFile
.Length
- BufferLength
;
277 Irp
->IoStatus
.Information
= 0;
279 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);