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>
19 #include <internal/debug.h>
21 /* FUNCTIONS *****************************************************************/
23 NTSTATUS
IoAttachVpb(PDEVICE_OBJECT DeviceObject
)
27 Vpb
= ExAllocatePool(NonPagedPool
,sizeof(VPB
));
30 return(STATUS_UNSUCCESSFUL
);
34 Vpb
->Size
= sizeof(VPB
) / sizeof(DWORD
);
36 Vpb
->VolumeLabelLength
= 0;
37 Vpb
->DeviceObject
= NULL
;
38 Vpb
->RealDevice
= DeviceObject
;
39 Vpb
->SerialNumber
= 0;
40 Vpb
->ReferenceCount
= 0;
41 RtlZeroMemory(Vpb
->VolumeLabel
,sizeof(WCHAR
)*MAXIMUM_VOLUME_LABEL_LENGTH
);
43 DeviceObject
->Vpb
= Vpb
;
45 return(STATUS_SUCCESS
);
48 PIRP
IoBuildVolumeInformationIrp(ULONG MajorFunction
,
49 PFILE_OBJECT FileObject
,
52 CINT FSInformationClass
,
53 PIO_STATUS_BLOCK IoStatusBlock
,
57 PIO_STACK_LOCATION StackPtr
;
58 PDEVICE_OBJECT DeviceObject
;
60 DeviceObject
= FileObject
->DeviceObject
;
62 Irp
= IoAllocateIrp(DeviceObject
->StackSize
,TRUE
);
68 // Irp->AssociatedIrp.SystemBuffer = FSInformation;
69 Irp
->UserBuffer
= FSInformation
;
71 StackPtr
= IoGetNextIrpStackLocation(Irp
);
72 StackPtr
->MajorFunction
= MajorFunction
;
73 StackPtr
->MinorFunction
= 0;
75 StackPtr
->Control
= 0;
76 StackPtr
->DeviceObject
= DeviceObject
;
77 StackPtr
->FileObject
= FileObject
;
78 Irp
->UserEvent
= Event
;
79 Irp
->UserIosb
= IoStatusBlock
;
81 switch (MajorFunction
)
83 case IRP_MJ_SET_VOLUME_INFORMATION
:
84 StackPtr
->Parameters
.SetVolume
.Length
= Length
;
85 StackPtr
->Parameters
.SetVolume
.FileInformationClass
=
89 case IRP_MJ_QUERY_VOLUME_INFORMATION
:
90 StackPtr
->Parameters
.QueryVolume
.Length
= Length
;
91 StackPtr
->Parameters
.QueryVolume
.FileInformationClass
=
100 NtQueryVolumeInformationFile (
101 IN HANDLE FileHandle
,
102 OUT PIO_STATUS_BLOCK IoStatusBlock
,
103 OUT PVOID FSInformation
,
105 IN FS_INFORMATION_CLASS FSInformationClass
109 * FUNCTION: Queries the volume information
111 * FileHandle = Handle to a file object on the target volume
112 * ReturnLength = DataWritten
113 * FSInformation = Caller should supply storage for the information
115 * Length = Size of the information structure
116 * FSInformationClass = Index to a information structure
118 * FileFsVolumeInformation FILE_FS_VOLUME_INFORMATION
119 * FileFsLabelInformation FILE_FS_LABEL_INFORMATION
120 * FileFsSizeInformation FILE_FS_SIZE_INFORMATION
121 * FileFsDeviceInformation FILE_FS_DEVICE_INFORMATION
122 * FileFsAttributeInformation FILE_FS_ATTRIBUTE_INFORMATION
123 * FileFsControlInformation
124 * FileFsQuotaQueryInformation --
125 * FileFsQuotaSetInformation --
126 * FileFsMaximumInformation
131 PFILE_OBJECT FileObject
;
132 PDEVICE_OBJECT DeviceObject
;
137 DPRINT("FSInformation %p\n", FSInformation
);
139 Status
= ObReferenceObjectByHandle(FileHandle
,
140 FILE_READ_ATTRIBUTES
,
145 if (Status
!= STATUS_SUCCESS
)
150 DeviceObject
= FileObject
->DeviceObject
;
152 KeInitializeEvent(&Event
,NotificationEvent
,FALSE
);
154 Irp
= IoBuildVolumeInformationIrp(IRP_MJ_QUERY_VOLUME_INFORMATION
,
161 Status
= IoCallDriver(DeviceObject
,Irp
);
162 if (Status
== STATUS_PENDING
)
164 KeWaitForSingleObject(&Event
,UserRequest
,KernelMode
,FALSE
,NULL
);
165 Status
= IoStatusBlock
->Status
;
172 NtSetVolumeInformationFile (
173 IN HANDLE FileHandle
,
174 IN CINT VolumeInformationClass
,
175 PVOID VolumeInformation
,
179 PFILE_OBJECT FileObject
;
180 PDEVICE_OBJECT DeviceObject
;
185 Status
= ObReferenceObjectByHandle(FileHandle
,
186 FILE_WRITE_ATTRIBUTES
,
191 if (Status
!= STATUS_SUCCESS
)
196 DeviceObject
= FileObject
->DeviceObject
;
198 KeInitializeEvent(&Event
,NotificationEvent
,FALSE
);
200 Irp
= IoBuildVolumeInformationIrp(IRP_MJ_SET_VOLUME_INFORMATION
,
204 VolumeInformationClass
,
207 Status
= IoCallDriver(DeviceObject
,Irp
);
208 if (Status
== STATUS_PENDING
)
210 KeWaitForSingleObject(&Event
,UserRequest
,KernelMode
,FALSE
,NULL
);