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 /* FUNCTIONS ****************************************************************/
36 * FUNCTION: Retrieve the standard file information
40 NtfsGetStandardInformation(PNTFS_FCB Fcb
,
41 PDEVICE_OBJECT DeviceObject
,
42 PFILE_STANDARD_INFORMATION StandardInfo
,
45 UNREFERENCED_PARAMETER(DeviceObject
);
47 DPRINT("NtfsGetStandardInformation() called\n");
49 if (*BufferLength
< sizeof(FILE_STANDARD_INFORMATION
))
50 return STATUS_BUFFER_OVERFLOW
;
53 ASSERT(StandardInfo
!= NULL
);
56 RtlZeroMemory(StandardInfo
,
57 sizeof(FILE_STANDARD_INFORMATION
));
59 StandardInfo
->AllocationSize
= Fcb
->RFCB
.AllocationSize
;
60 StandardInfo
->EndOfFile
= Fcb
->RFCB
.FileSize
;
61 StandardInfo
->NumberOfLinks
= 0;
62 StandardInfo
->DeletePending
= FALSE
;
63 StandardInfo
->Directory
= NtfsFCBIsDirectory(Fcb
);
65 *BufferLength
-= sizeof(FILE_STANDARD_INFORMATION
);
67 return STATUS_SUCCESS
;
73 NtfsGetPositionInformation(PFILE_OBJECT FileObject
,
74 PFILE_POSITION_INFORMATION PositionInfo
,
77 UNREFERENCED_PARAMETER(FileObject
);
79 DPRINT("NtfsGetPositionInformation() called\n");
81 if (*BufferLength
< sizeof(FILE_POSITION_INFORMATION
))
82 return STATUS_BUFFER_OVERFLOW
;
84 PositionInfo
->CurrentByteOffset
.QuadPart
= 0;
85 // FileObject->CurrentByteOffset.QuadPart;
87 DPRINT("Getting position %I64x\n",
88 PositionInfo
->CurrentByteOffset
.QuadPart
);
90 *BufferLength
-= sizeof(FILE_POSITION_INFORMATION
);
92 return STATUS_SUCCESS
;
98 NtfsGetBasicInformation(PFILE_OBJECT FileObject
,
100 PDEVICE_OBJECT DeviceObject
,
101 PFILE_BASIC_INFORMATION BasicInfo
,
104 DPRINT("NtfsGetBasicInformation() called\n");
106 if (*BufferLength
< sizeof(FILE_BASIC_INFORMATION
))
107 return STATUS_BUFFER_OVERFLOW
;
110 CdfsDateTimeToFileTime(Fcb
,
111 &BasicInfo
->CreationTime
);
112 CdfsDateTimeToFileTime(Fcb
,
113 &BasicInfo
->LastAccessTime
);
114 CdfsDateTimeToFileTime(Fcb
,
115 &BasicInfo
->LastWriteTime
);
116 CdfsDateTimeToFileTime(Fcb
,
117 &BasicInfo
->ChangeTime
);
119 CdfsFileFlagsToAttributes(Fcb
,
120 &BasicInfo
->FileAttributes
);
122 UNREFERENCED_PARAMETER(FileObject
);
123 UNREFERENCED_PARAMETER(Fcb
);
124 UNREFERENCED_PARAMETER(DeviceObject
);
125 UNREFERENCED_PARAMETER(BasicInfo
);
128 *BufferLength
-= sizeof(FILE_BASIC_INFORMATION
);
130 return STATUS_SUCCESS
;
135 * FUNCTION: Retrieve the file name information
139 NtfsGetNameInformation(PFILE_OBJECT FileObject
,
141 PDEVICE_OBJECT DeviceObject
,
142 PFILE_NAME_INFORMATION NameInfo
,
147 UNREFERENCED_PARAMETER(FileObject
);
148 UNREFERENCED_PARAMETER(DeviceObject
);
150 DPRINT("NtfsGetNameInformation() called\n");
152 ASSERT(NameInfo
!= NULL
);
155 NameLength
= wcslen(Fcb
->PathName
) * sizeof(WCHAR
);
157 if (*BufferLength
< sizeof(FILE_NAME_INFORMATION
) + NameLength
)
158 return STATUS_BUFFER_OVERFLOW
;
160 NameInfo
->FileNameLength
= NameLength
;
161 memcpy(NameInfo
->FileName
,
163 NameLength
+ sizeof(WCHAR
));
164 // wcscpy(NameInfo->FileName, L"\\");
166 *BufferLength
-= (sizeof(FILE_NAME_INFORMATION
) + NameLength
+ sizeof(WCHAR
));
168 return STATUS_SUCCESS
;
174 NtfsGetInternalInformation(PNTFS_FCB Fcb
,
175 PFILE_INTERNAL_INFORMATION InternalInfo
,
178 DPRINT("NtfsGetInternalInformation() called\n");
180 ASSERT(InternalInfo
);
183 if (*BufferLength
< sizeof(FILE_INTERNAL_INFORMATION
))
184 return STATUS_BUFFER_OVERFLOW
;
186 /* FIXME: get a real index, that can be used in a create operation */
187 InternalInfo
->IndexNumber
.QuadPart
= 0;
189 *BufferLength
-= sizeof(FILE_INTERNAL_INFORMATION
);
191 return STATUS_SUCCESS
;
196 * FUNCTION: Retrieve the specified file information
200 NtfsFsdQueryInformation(PDEVICE_OBJECT DeviceObject
,
203 FILE_INFORMATION_CLASS FileInformationClass
;
204 PIO_STACK_LOCATION Stack
;
205 PFILE_OBJECT FileObject
;
209 NTSTATUS Status
= STATUS_SUCCESS
;
211 DPRINT("NtfsQueryInformation() called\n");
213 Stack
= IoGetCurrentIrpStackLocation(Irp
);
214 FileInformationClass
= Stack
->Parameters
.QueryFile
.FileInformationClass
;
215 FileObject
= Stack
->FileObject
;
216 Fcb
= FileObject
->FsContext
;
218 SystemBuffer
= Irp
->AssociatedIrp
.SystemBuffer
;
219 BufferLength
= Stack
->Parameters
.QueryFile
.Length
;
221 switch (FileInformationClass
)
223 case FileStandardInformation
:
224 Status
= NtfsGetStandardInformation(Fcb
,
230 case FilePositionInformation
:
231 Status
= NtfsGetPositionInformation(FileObject
,
236 case FileBasicInformation
:
237 Status
= NtfsGetBasicInformation(FileObject
,
244 case FileNameInformation
:
245 Status
= NtfsGetNameInformation(FileObject
,
252 case FileInternalInformation
:
253 Status
= NtfsGetInternalInformation(Fcb
,
258 case FileAlternateNameInformation
:
259 case FileAllInformation
:
260 Status
= STATUS_NOT_IMPLEMENTED
;
264 DPRINT("Unimplemented information class %u\n", FileInformationClass
);
265 Status
= STATUS_INVALID_PARAMETER
;
268 Irp
->IoStatus
.Status
= Status
;
270 if (NT_SUCCESS(Status
))
271 Irp
->IoStatus
.Information
=
272 Stack
->Parameters
.QueryFile
.Length
- BufferLength
;
274 Irp
->IoStatus
.Information
= 0;
276 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);