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.
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
23 * FILE: services/fs/ntfs/dirctl.c
24 * PURPOSE: NTFS filesystem driver
25 * PROGRAMMER: Eric Kohl
28 /* INCLUDES *****************************************************************/
30 #include <ddk/ntddk.h>
38 /* FUNCTIONS ****************************************************************/
41 NtfsGetStandardInformation(PFCB Fcb,
42 PDEVICE_OBJECT DeviceObject,
43 PFILE_STANDARD_INFORMATION StandardInfo,
46 * FUNCTION: Retrieve the standard file information
49 DPRINT("NtfsGetStandardInformation() called\n");
51 if (*BufferLength < sizeof(FILE_STANDARD_INFORMATION))
52 return(STATUS_BUFFER_OVERFLOW);
55 assert(StandardInfo != NULL);
58 RtlZeroMemory(StandardInfo,
59 sizeof(FILE_STANDARD_INFORMATION));
61 StandardInfo->AllocationSize = Fcb->RFCB.AllocationSize;
62 StandardInfo->EndOfFile = Fcb->RFCB.FileSize;
63 StandardInfo->NumberOfLinks = 0;
64 StandardInfo->DeletePending = FALSE;
65 StandardInfo->Directory = NtfsFCBIsDirectory(Fcb);
67 *BufferLength -= sizeof(FILE_STANDARD_INFORMATION);
68 return(STATUS_SUCCESS);
73 NtfsGetPositionInformation(PFILE_OBJECT FileObject,
74 PFILE_POSITION_INFORMATION PositionInfo,
77 DPRINT("NtfsGetPositionInformation() called\n");
79 if (*BufferLength < sizeof(FILE_POSITION_INFORMATION))
80 return(STATUS_BUFFER_OVERFLOW);
82 PositionInfo->CurrentByteOffset.QuadPart =
84 // FileObject->CurrentByteOffset.QuadPart;
86 DPRINT("Getting position %I64x\n",
87 PositionInfo->CurrentByteOffset.QuadPart);
89 *BufferLength -= sizeof(FILE_POSITION_INFORMATION);
90 return(STATUS_SUCCESS);
95 NtfsGetBasicInformation(PFILE_OBJECT FileObject,
97 PDEVICE_OBJECT DeviceObject,
98 PFILE_BASIC_INFORMATION BasicInfo,
101 DPRINT("NtfsGetBasicInformation() called\n");
103 if (*BufferLength < sizeof(FILE_BASIC_INFORMATION))
104 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);
120 *BufferLength -= sizeof(FILE_BASIC_INFORMATION);
122 return(STATUS_SUCCESS);
127 NtfsGetNameInformation(PFILE_OBJECT FileObject,
129 PDEVICE_OBJECT DeviceObject,
130 PFILE_NAME_INFORMATION NameInfo,
133 * FUNCTION: Retrieve the file name information
138 DPRINT("NtfsGetNameInformation() called\n");
140 assert(NameInfo != NULL);
143 // NameLength = wcslen(Fcb->PathName) * sizeof(WCHAR);
145 if (*BufferLength < sizeof(FILE_NAME_INFORMATION) + NameLength)
146 return(STATUS_BUFFER_OVERFLOW);
148 NameInfo->FileNameLength = NameLength;
149 // memcpy(NameInfo->FileName,
151 // NameLength + sizeof(WCHAR));
152 wcscpy(NameInfo->FileName, L"\\");
155 (sizeof(FILE_NAME_INFORMATION) + NameLength + sizeof(WCHAR));
157 return(STATUS_SUCCESS);
162 NtfsGetInternalInformation(PFCB Fcb,
163 PFILE_INTERNAL_INFORMATION InternalInfo,
166 DPRINT("NtfsGetInternalInformation() called\n");
168 assert(InternalInfo);
171 if (*BufferLength < sizeof(FILE_INTERNAL_INFORMATION))
172 return(STATUS_BUFFER_OVERFLOW);
174 /* FIXME: get a real index, that can be used in a create operation */
175 InternalInfo->IndexNumber.QuadPart = 0;
177 *BufferLength -= sizeof(FILE_INTERNAL_INFORMATION);
179 return(STATUS_SUCCESS);
184 NtfsQueryInformation(PDEVICE_OBJECT DeviceObject,
187 * FUNCTION: Retrieve the specified file information
190 FILE_INFORMATION_CLASS FileInformationClass;
191 PIO_STACK_LOCATION Stack;
192 PFILE_OBJECT FileObject;
197 NTSTATUS Status = STATUS_SUCCESS;
199 DPRINT("NtfsQueryInformation() called\n");
201 Stack = IoGetCurrentIrpStackLocation(Irp);
202 FileInformationClass = Stack->Parameters.QueryFile.FileInformationClass;
203 FileObject = Stack->FileObject;
204 Fcb = FileObject->FsContext;
206 SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
207 BufferLength = Stack->Parameters.QueryFile.Length;
209 switch (FileInformationClass)
211 case FileStandardInformation:
212 Status = NtfsGetStandardInformation(Fcb,
218 case FilePositionInformation:
219 Status = NtfsGetPositionInformation(FileObject,
224 case FileBasicInformation:
225 Status = NtfsGetBasicInformation(FileObject,
232 case FileNameInformation:
233 Status = NtfsGetNameInformation(FileObject,
240 case FileInternalInformation:
241 Status = NtfsGetInternalInformation(Fcb,
246 case FileAlternateNameInformation:
247 case FileAllInformation:
248 Status = STATUS_NOT_IMPLEMENTED;
252 DPRINT("Unimplemented information class %u\n", FileInformationClass);
253 Status = STATUS_NOT_SUPPORTED;
256 Irp->IoStatus.Status = Status;
257 if (NT_SUCCESS(Status))
258 Irp->IoStatus.Information =
259 Stack->Parameters.QueryFile.Length - BufferLength;
261 Irp->IoStatus.Information = 0;
263 IoCompleteRequest(Irp, IO_NO_INCREMENT);