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/volume.c
24 * PURPOSE: NTFS filesystem driver
25 * PROGRAMMER: Eric Kohl
28 /* INCLUDES *****************************************************************/
35 /* FUNCTIONS ****************************************************************/
38 NtfsGetFsVolumeInformation(PDEVICE_OBJECT DeviceObject
,
39 PFILE_FS_VOLUME_INFORMATION FsVolumeInfo
,
42 DPRINT("NtfsGetFsVolumeInformation() called\n");
43 DPRINT("FsVolumeInfo = %p\n", FsVolumeInfo
);
44 DPRINT("BufferLength %lu\n", *BufferLength
);
46 DPRINT("Vpb %p\n", DeviceObject
->Vpb
);
48 DPRINT("Required length %lu\n",
49 sizeof(FILE_FS_VOLUME_INFORMATION
) + DeviceObject
->Vpb
->VolumeLabelLength
);
50 DPRINT("LabelLength %hu\n",
51 DeviceObject
->Vpb
->VolumeLabelLength
);
52 DPRINT("Label %*.S\n",
53 DeviceObject
->Vpb
->VolumeLabelLength
/ sizeof(WCHAR
),
54 DeviceObject
->Vpb
->VolumeLabel
);
56 if (*BufferLength
< sizeof(FILE_FS_VOLUME_INFORMATION
))
57 return STATUS_INFO_LENGTH_MISMATCH
;
59 if (*BufferLength
< (sizeof(FILE_FS_VOLUME_INFORMATION
) + DeviceObject
->Vpb
->VolumeLabelLength
))
60 return STATUS_BUFFER_OVERFLOW
;
63 FsVolumeInfo
->VolumeSerialNumber
= DeviceObject
->Vpb
->SerialNumber
;
64 FsVolumeInfo
->VolumeLabelLength
= DeviceObject
->Vpb
->VolumeLabelLength
;
65 memcpy(FsVolumeInfo
->VolumeLabel
,
66 DeviceObject
->Vpb
->VolumeLabel
,
67 DeviceObject
->Vpb
->VolumeLabelLength
);
70 FsVolumeInfo
->VolumeCreationTime
.QuadPart
= 0;
71 FsVolumeInfo
->SupportsObjects
= FALSE
;
73 *BufferLength
-= (sizeof(FILE_FS_VOLUME_INFORMATION
) + DeviceObject
->Vpb
->VolumeLabelLength
);
75 DPRINT("BufferLength %lu\n", *BufferLength
);
76 DPRINT("NtfsGetFsVolumeInformation() done\n");
78 return STATUS_SUCCESS
;
83 NtfsGetFsAttributeInformation(PDEVICE_EXTENSION DeviceExt
,
84 PFILE_FS_ATTRIBUTE_INFORMATION FsAttributeInfo
,
87 DPRINT("NtfsGetFsAttributeInformation()\n");
88 DPRINT("FsAttributeInfo = %p\n", FsAttributeInfo
);
89 DPRINT("BufferLength %lu\n", *BufferLength
);
90 DPRINT("Required length %lu\n", (sizeof(FILE_FS_ATTRIBUTE_INFORMATION
) + 8));
92 if (*BufferLength
< sizeof (FILE_FS_ATTRIBUTE_INFORMATION
))
93 return(STATUS_INFO_LENGTH_MISMATCH
);
95 if (*BufferLength
< (sizeof(FILE_FS_ATTRIBUTE_INFORMATION
) + 8))
96 return(STATUS_BUFFER_OVERFLOW
);
98 FsAttributeInfo
->FileSystemAttributes
=
99 FILE_CASE_PRESERVED_NAMES
| FILE_UNICODE_ON_DISK
;
100 FsAttributeInfo
->MaximumComponentNameLength
= 255;
101 FsAttributeInfo
->FileSystemNameLength
= 8;
103 memcpy(FsAttributeInfo
->FileSystemName
, L
"NTFS", 8);
105 DPRINT("Finished NtfsGetFsAttributeInformation()\n");
107 *BufferLength
-= (sizeof(FILE_FS_ATTRIBUTE_INFORMATION
) + 8);
108 DPRINT("BufferLength %lu\n", *BufferLength
);
110 return(STATUS_SUCCESS
);
115 NtfsGetFsSizeInformation(PDEVICE_OBJECT DeviceObject
,
116 PFILE_FS_SIZE_INFORMATION FsSizeInfo
,
119 PDEVICE_EXTENSION DeviceExt
;
120 NTSTATUS Status
= STATUS_SUCCESS
;
122 DPRINT("NtfsGetFsSizeInformation()\n");
123 DPRINT("FsSizeInfo = %p\n", FsSizeInfo
);
125 if (*BufferLength
< sizeof(FILE_FS_SIZE_INFORMATION
))
126 return(STATUS_BUFFER_OVERFLOW
);
128 DeviceExt
= DeviceObject
->DeviceExtension
;
130 FsSizeInfo
->AvailableAllocationUnits
.QuadPart
= 0;
131 FsSizeInfo
->TotalAllocationUnits
.QuadPart
= DeviceExt
->NtfsInfo
.SectorCount
; /* ?? */
132 FsSizeInfo
->SectorsPerAllocationUnit
= DeviceExt
->NtfsInfo
.SectorsPerCluster
;
133 FsSizeInfo
->BytesPerSector
= DeviceExt
->NtfsInfo
.BytesPerSector
;
135 DPRINT("Finished NtfsGetFsSizeInformation()\n");
136 if (NT_SUCCESS(Status
))
137 *BufferLength
-= sizeof(FILE_FS_SIZE_INFORMATION
);
144 NtfsGetFsDeviceInformation(PFILE_FS_DEVICE_INFORMATION FsDeviceInfo
,
147 DPRINT("NtfsGetFsDeviceInformation()\n");
148 DPRINT("FsDeviceInfo = %p\n", FsDeviceInfo
);
149 DPRINT("BufferLength %lu\n", *BufferLength
);
150 DPRINT("Required length %lu\n", sizeof(FILE_FS_DEVICE_INFORMATION
));
152 if (*BufferLength
< sizeof(FILE_FS_DEVICE_INFORMATION
))
153 return(STATUS_BUFFER_OVERFLOW
);
155 FsDeviceInfo
->DeviceType
= FILE_DEVICE_DISK
;
156 FsDeviceInfo
->Characteristics
= 0; /* FIXME: fix this !! */
158 DPRINT("NtfsGetFsDeviceInformation() finished.\n");
160 *BufferLength
-= sizeof(FILE_FS_DEVICE_INFORMATION
);
161 DPRINT("BufferLength %lu\n", *BufferLength
);
163 return(STATUS_SUCCESS
);
169 NtfsQueryVolumeInformation(PDEVICE_OBJECT DeviceObject
,
172 FS_INFORMATION_CLASS FsInformationClass
;
173 PIO_STACK_LOCATION Stack
;
174 NTSTATUS Status
= STATUS_SUCCESS
;
178 DPRINT("NtfsQueryVolumeInformation() called\n");
180 Stack
= IoGetCurrentIrpStackLocation(Irp
);
181 FsInformationClass
= Stack
->Parameters
.QueryVolume
.FsInformationClass
;
182 BufferLength
= Stack
->Parameters
.QueryVolume
.Length
;
183 SystemBuffer
= Irp
->AssociatedIrp
.SystemBuffer
;
185 DPRINT("FsInformationClass %d\n", FsInformationClass
);
186 DPRINT("SystemBuffer %x\n", SystemBuffer
);
188 switch (FsInformationClass
)
190 case FileFsVolumeInformation
:
191 Status
= NtfsGetFsVolumeInformation(DeviceObject
,
196 case FileFsAttributeInformation
:
197 Status
= NtfsGetFsAttributeInformation(DeviceObject
->DeviceExtension
,
202 case FileFsSizeInformation
:
203 Status
= NtfsGetFsSizeInformation(DeviceObject
,
208 case FileFsDeviceInformation
:
209 Status
= NtfsGetFsDeviceInformation(SystemBuffer
,
214 Status
= STATUS_NOT_SUPPORTED
;
217 Irp
->IoStatus
.Status
= Status
;
218 if (NT_SUCCESS(Status
))
219 Irp
->IoStatus
.Information
=
220 Stack
->Parameters
.QueryVolume
.Length
- BufferLength
;
222 Irp
->IoStatus
.Information
= 0;
223 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
230 NtfsSetVolumeInformation(PDEVICE_OBJECT DeviceObject
,
233 DPRINT("NtfsSetVolumeInformation() called\n");
235 Irp
->IoStatus
.Status
= STATUS_NOT_SUPPORTED
;
236 Irp
->IoStatus
.Information
= 0;
237 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
239 return(STATUS_NOT_SUPPORTED
);