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 NtfsGetStandardInformation(PNTFS_FCB Fcb
,
40 PDEVICE_OBJECT DeviceObject
,
41 PFILE_STANDARD_INFORMATION StandardInfo
,
44 * FUNCTION: Retrieve the standard file information
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
);
66 return(STATUS_SUCCESS
);
71 NtfsGetPositionInformation(PFILE_OBJECT FileObject
,
72 PFILE_POSITION_INFORMATION PositionInfo
,
75 DPRINT("NtfsGetPositionInformation() called\n");
77 if (*BufferLength
< sizeof(FILE_POSITION_INFORMATION
))
78 return(STATUS_BUFFER_OVERFLOW
);
80 PositionInfo
->CurrentByteOffset
.QuadPart
=
82 // FileObject->CurrentByteOffset.QuadPart;
84 DPRINT("Getting position %I64x\n",
85 PositionInfo
->CurrentByteOffset
.QuadPart
);
87 *BufferLength
-= sizeof(FILE_POSITION_INFORMATION
);
88 return(STATUS_SUCCESS
);
93 NtfsGetBasicInformation(PFILE_OBJECT FileObject
,
95 PDEVICE_OBJECT DeviceObject
,
96 PFILE_BASIC_INFORMATION BasicInfo
,
99 DPRINT("NtfsGetBasicInformation() called\n");
101 if (*BufferLength
< sizeof(FILE_BASIC_INFORMATION
))
102 return(STATUS_BUFFER_OVERFLOW
);
105 CdfsDateTimeToFileTime(Fcb
,
106 &BasicInfo
->CreationTime
);
107 CdfsDateTimeToFileTime(Fcb
,
108 &BasicInfo
->LastAccessTime
);
109 CdfsDateTimeToFileTime(Fcb
,
110 &BasicInfo
->LastWriteTime
);
111 CdfsDateTimeToFileTime(Fcb
,
112 &BasicInfo
->ChangeTime
);
114 CdfsFileFlagsToAttributes(Fcb
,
115 &BasicInfo
->FileAttributes
);
118 *BufferLength
-= sizeof(FILE_BASIC_INFORMATION
);
120 return(STATUS_SUCCESS
);
125 NtfsGetNameInformation(PFILE_OBJECT FileObject
,
127 PDEVICE_OBJECT DeviceObject
,
128 PFILE_NAME_INFORMATION NameInfo
,
131 * FUNCTION: Retrieve the file name information
136 DPRINT("NtfsGetNameInformation() called\n");
138 ASSERT(NameInfo
!= NULL
);
141 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
));
150 // wcscpy(NameInfo->FileName, L"\\");
153 (sizeof(FILE_NAME_INFORMATION
) + NameLength
+ sizeof(WCHAR
));
155 return(STATUS_SUCCESS
);
160 NtfsGetInternalInformation(PNTFS_FCB Fcb
,
161 PFILE_INTERNAL_INFORMATION InternalInfo
,
164 DPRINT("NtfsGetInternalInformation() called\n");
166 ASSERT(InternalInfo
);
169 if (*BufferLength
< sizeof(FILE_INTERNAL_INFORMATION
))
170 return(STATUS_BUFFER_OVERFLOW
);
172 /* FIXME: get a real index, that can be used in a create operation */
173 InternalInfo
->IndexNumber
.QuadPart
= 0;
175 *BufferLength
-= sizeof(FILE_INTERNAL_INFORMATION
);
177 return(STATUS_SUCCESS
);
182 NtfsFsdQueryInformation(PDEVICE_OBJECT DeviceObject
,
185 * FUNCTION: Retrieve the specified file information
188 FILE_INFORMATION_CLASS FileInformationClass
;
189 PIO_STACK_LOCATION Stack
;
190 PFILE_OBJECT FileObject
;
195 NTSTATUS Status
= STATUS_SUCCESS
;
197 DPRINT("NtfsQueryInformation() called\n");
199 Stack
= IoGetCurrentIrpStackLocation(Irp
);
200 FileInformationClass
= Stack
->Parameters
.QueryFile
.FileInformationClass
;
201 FileObject
= Stack
->FileObject
;
202 Fcb
= FileObject
->FsContext
;
204 SystemBuffer
= Irp
->AssociatedIrp
.SystemBuffer
;
205 BufferLength
= Stack
->Parameters
.QueryFile
.Length
;
207 switch (FileInformationClass
)
209 case FileStandardInformation
:
210 Status
= NtfsGetStandardInformation(Fcb
,
216 case FilePositionInformation
:
217 Status
= NtfsGetPositionInformation(FileObject
,
222 case FileBasicInformation
:
223 Status
= NtfsGetBasicInformation(FileObject
,
230 case FileNameInformation
:
231 Status
= NtfsGetNameInformation(FileObject
,
238 case FileInternalInformation
:
239 Status
= NtfsGetInternalInformation(Fcb
,
244 case FileAlternateNameInformation
:
245 case FileAllInformation
:
246 Status
= STATUS_NOT_IMPLEMENTED
;
250 DPRINT("Unimplemented information class %u\n", FileInformationClass
);
251 Status
= STATUS_INVALID_PARAMETER
;
254 Irp
->IoStatus
.Status
= Status
;
255 if (NT_SUCCESS(Status
))
256 Irp
->IoStatus
.Information
=
257 Stack
->Parameters
.QueryFile
.Length
- BufferLength
;
259 Irp
->IoStatus
.Information
= 0;
261 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);