2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: ntoskrnl/io/vpb.c
5 * PURPOSE: Volume Parameter Block managment
6 * PROGRAMMER: David Welch (welch@mcmail.com)
11 /* INCLUDES *****************************************************************/
13 #include <ddk/ntddk.h>
15 #include <internal/string.h>
16 #include <internal/ob.h>
18 #include <internal/debug.h>
20 /* FUNCTIONS *****************************************************************/
22 NTSTATUS
IoAttachVpb(PDEVICE_OBJECT DeviceObject
)
26 Vpb
= ExAllocatePool(NonPagedPool
,sizeof(VPB
));
29 return(STATUS_UNSUCCESSFUL
);
33 Vpb
->Size
= sizeof(VPB
) / sizeof(DWORD
);
35 Vpb
->VolumeLabelLength
= 0;
36 Vpb
->DeviceObject
= NULL
;
37 Vpb
->RealDevice
= DeviceObject
;
38 Vpb
->SerialNumber
= 0;
39 Vpb
->ReferenceCount
= 0;
40 RtlZeroMemory(Vpb
->VolumeLabel
,sizeof(WCHAR
)*MAXIMUM_VOLUME_LABEL_LENGTH
);
42 DeviceObject
->Vpb
= Vpb
;
45 PIRP
IoBuildVolumeInformationIrp(ULONG MajorFunction
,
46 PFILE_OBJECT FileObject
,
49 CINT FSInformationClass
,
50 PIO_STATUS_BLOCK IoStatusBlock
,
54 PIO_STACK_LOCATION StackPtr
;
55 PDEVICE_OBJECT DeviceObject
;
57 DeviceObject
= FileObject
->DeviceObject
;
59 Irp
= IoAllocateIrp(DeviceObject
->StackSize
,TRUE
);
65 Irp
->AssociatedIrp
.SystemBuffer
= FSInformation
;
67 StackPtr
= IoGetNextIrpStackLocation(Irp
);
68 StackPtr
->MajorFunction
= MajorFunction
;
69 StackPtr
->MinorFunction
= 0;
71 StackPtr
->Control
= 0;
72 StackPtr
->DeviceObject
= DeviceObject
;
73 StackPtr
->FileObject
= FileObject
;
74 Irp
->UserEvent
= Event
;
75 Irp
->UserIosb
= IoStatusBlock
;
77 if (MajorFunction
== IRP_MJ_QUERY_VOLUME_INFORMATION
)
79 StackPtr
->Parameters
.SetVolume
.Length
= Length
;
80 StackPtr
->Parameters
.SetVolume
.FileInformationClass
=
85 StackPtr
->Parameters
.QueryVolume
.Length
= Length
;
86 StackPtr
->Parameters
.QueryVolume
.FileInformationClass
=
92 NTSTATUS STDCALL
NtQueryVolumeInformationFile(
94 OUT PIO_STATUS_BLOCK IoStatusBlock
,
95 OUT PVOID FSInformation
,
97 IN FS_INFORMATION_CLASS FSInformationClass
)
100 * FUNCTION: Queries the volume information
102 * FileHandle = Handle to a file object on the target volume
103 * ReturnLength = DataWritten
104 * FSInformation = Caller should supply storage for the information
106 * Length = Size of the information structure
107 * FSInformationClass = Index to a information structure
109 * FileFsVolumeInformation FILE_FS_VOLUME_INFORMATION
110 * FileFsLabelInformation FILE_FS_LABEL_INFORMATION
111 * FileFsSizeInformation FILE_FS_SIZE_INFORMATION
112 * FileFsDeviceInformation FILE_FS_DEVICE_INFORMATION
113 * FileFsAttributeInformation FILE_FS_ATTRIBUTE_INFORMATION
114 * FileFsControlInformation
115 * FileFsQuotaQueryInformation --
116 * FileFsQuotaSetInformation --
117 * FileFsMaximumInformation
122 return(ZwQueryVolumeInformationFile(FileHandle
,IoStatusBlock
,FSInformation
,
123 Length
,FSInformationClass
));
128 ZwQueryVolumeInformationFile(
129 IN HANDLE FileHandle
,
130 OUT PIO_STATUS_BLOCK IoStatusBlock
,
131 OUT PVOID FSInformation
,
133 IN FS_INFORMATION_CLASS FSInformationClass
)
135 PFILE_OBJECT FileObject
;
136 PDEVICE_OBJECT DeviceObject
;
141 Status
= ObReferenceObjectByHandle(FileHandle
,
142 FILE_READ_ATTRIBUTES
,
147 if (Status
!= STATUS_SUCCESS
)
152 DeviceObject
= FileObject
->DeviceObject
;
154 KeInitializeEvent(&Event
,NotificationEvent
,FALSE
);
156 Irp
= IoBuildVolumeInformationIrp(IRP_MJ_QUERY_VOLUME_INFORMATION
,
163 Status
= IoCallDriver(DeviceObject
,Irp
);
164 if (Status
== STATUS_PENDING
)
166 KeWaitForSingleObject(&Event
,UserRequest
,KernelMode
,FALSE
,NULL
);
167 Status
= IoStatusBlock
->Status
;
174 NtSetVolumeInformationFile(
175 IN HANDLE FileHandle
,
176 IN CINT VolumeInformationClass
,
177 PVOID VolumeInformation
,
181 return(ZwSetVolumeInformationFile(FileHandle
,VolumeInformationClass
,
182 VolumeInformation
,Length
));
187 ZwSetVolumeInformationFile(
188 IN HANDLE FileHandle
,
189 IN CINT VolumeInformationClass
,
190 PVOID VolumeInformation
,
195 PFILE_OBJECT FileObject
;
196 PDEVICE_OBJECT DeviceObject
;
201 Status
= ObReferenceObjectByHandle(FileHandle
,
202 FILE_WRITE_ATTRIBUTES
,
207 if (Status
!= STATUS_SUCCESS
)
212 DeviceObject
= FileObject
->DeviceObject
;
214 KeInitializeEvent(&Event
,NotificationEvent
,FALSE
);
216 Irp
= IoBuildVolumeInformationIrp(IRP_MJ_SET_VOLUME_INFORMATION
,
220 VolumeInformationClass
,
223 Status
= IoCallDriver(DeviceObject
,Irp
);
224 if (Status
== STATUS_PENDING
)
226 KeWaitForSingleObject(&Event
,UserRequest
,KernelMode
,FALSE
,NULL
);