ReactOS 0.4.17-dev-1190-g4c812f4
volinfo.c File Reference
#include "ntfs.h"
#include <debug.h>
Include dependency graph for volinfo.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NtfsLoadVolumeBitmap

Reads $Bitmap into memory once at mount. Cluster allocation and freeing work on this copy and write back only the sectors they change.

Parameters
DeviceExtVolume being mounted. Its file record lookaside list and MFT context must be ready.
Returns
STATUS_SUCCESS, or an error if $Bitmap could not be found or read.
NTSTATUS NtfsLoadVolumeBitmap (_In_ PDEVICE_EXTENSION DeviceExt)
 
NtfsFreeVolumeBitmap

Releases what NtfsLoadVolumeBitmap() set up. Safe on a partly loaded volume.

Parameters
DeviceExtVolume whose bitmap copy is released.
VOID NtfsFreeVolumeBitmap (_In_ PDEVICE_EXTENSION DeviceExt)
 
NtfsWriteVolumeBitmap

Writes the sectors of $Bitmap that hold the given clusters' bits. The caller holds BitmapResource exclusively.

Parameters
DeviceExtVolume whose bitmap changed.
FirstClusterFirst cluster whose bit changed.
ClusterCountNumber of clusters, starting at FirstCluster, to cover. Can't be 0.
Returns
Status from WriteAttribute().
NTSTATUS NtfsWriteVolumeBitmap (_In_ PDEVICE_EXTENSION DeviceExt, _In_ ULONG FirstCluster, _In_ ULONG ClusterCount)
 
ULONGLONG NtfsGetFreeClusters (PDEVICE_EXTENSION DeviceExt)
 
NTSTATUS NtfsAllocateClusters (PDEVICE_EXTENSION DeviceExt, ULONG FirstDesiredCluster, ULONG DesiredClusters, PULONG FirstAssignedCluster, PULONG AssignedClusters)
 
static NTSTATUS NtfsGetFsVolumeInformation (PDEVICE_OBJECT DeviceObject, PFILE_FS_VOLUME_INFORMATION FsVolumeInfo, PULONG BufferLength)
 
static NTSTATUS NtfsGetFsAttributeInformation (PDEVICE_EXTENSION DeviceExt, PFILE_FS_ATTRIBUTE_INFORMATION FsAttributeInfo, PULONG BufferLength)
 
static NTSTATUS NtfsGetFsSizeInformation (PDEVICE_OBJECT DeviceObject, PFILE_FS_SIZE_INFORMATION FsSizeInfo, PULONG BufferLength)
 
static NTSTATUS NtfsGetFsDeviceInformation (PDEVICE_OBJECT DeviceObject, PFILE_FS_DEVICE_INFORMATION FsDeviceInfo, PULONG BufferLength)
 
NTSTATUS NtfsQueryVolumeInformation (PNTFS_IRP_CONTEXT IrpContext)
 
NTSTATUS NtfsSetVolumeInformation (PNTFS_IRP_CONTEXT IrpContext)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 31 of file volinfo.c.

Function Documentation

◆ NtfsAllocateClusters()

NTSTATUS NtfsAllocateClusters ( PDEVICE_EXTENSION  DeviceExt,
ULONG  FirstDesiredCluster,
ULONG  DesiredClusters,
PULONG  FirstAssignedCluster,
PULONG  AssignedClusters 
)

NtfsAllocateClusters Allocates a run of clusters. The run allocated might be smaller than DesiredClusters.

Definition at line 213 of file volinfo.c.

218{
220 PRTL_BITMAP Bitmap = &DeviceExt->ClusterBitmap;
221 ULONG AssignedRun;
222
223 DPRINT("NtfsAllocateClusters(%p, %lu, %lu, %p, %p)\n", DeviceExt, FirstDesiredCluster, DesiredClusters, FirstAssignedCluster, AssignedClusters);
224
225 *AssignedClusters = 0;
226
227 /* Files growing in parallel must not both claim the same free run */
229 ExAcquireResourceExclusiveLite(&DeviceExt->BitmapResource, TRUE);
230
231 if (DeviceExt->FreeClusterCount < DesiredClusters)
232 {
234 goto Quit;
235 }
236
237 /* The hint is just past the file's last cluster, which can be past the volume end */
238 if (FirstDesiredCluster >= Bitmap->SizeOfBitMap)
239 FirstDesiredCluster = 0;
240
241 // TODO: Observe MFT reservation zone
242
243 // Can we get one contiguous run?
244 AssignedRun = RtlFindClearBitsAndSet(Bitmap, DesiredClusters, FirstDesiredCluster);
245
246 if (AssignedRun != 0xFFFFFFFF)
247 {
248 *FirstAssignedCluster = AssignedRun;
249 *AssignedClusters = DesiredClusters;
250 }
251 else
252 {
253 // we can't get one contiguous run
254 *AssignedClusters = RtlFindNextForwardRunClear(Bitmap, FirstDesiredCluster, FirstAssignedCluster);
255
256 if (*AssignedClusters == 0)
257 {
258 // we couldn't find any runs starting at DesiredFirstCluster
259 *AssignedClusters = RtlFindLongestRunClear(Bitmap, FirstAssignedCluster);
260 }
261
262 if (*AssignedClusters == 0)
263 {
265 goto Quit;
266 }
267
268 /* Hand out no more than was asked for, and mark it in use */
269 *AssignedClusters = min(*AssignedClusters, DesiredClusters);
270 RtlSetBits(Bitmap, *FirstAssignedCluster, *AssignedClusters);
271 }
272
273 Status = NtfsWriteVolumeBitmap(DeviceExt, *FirstAssignedCluster, *AssignedClusters);
274 if (NT_SUCCESS(Status))
275 {
276 DeviceExt->FreeClusterCount -= *AssignedClusters;
277 }
278 else
279 {
280 /* Keep the copy in step with what the disk says */
281 RtlClearBits(Bitmap, *FirstAssignedCluster, *AssignedClusters);
282 *AssignedClusters = 0;
283 }
284
285Quit:
286 ExReleaseResourceLite(&DeviceExt->BitmapResource);
288
289 return Status;
290}
LONG NTSTATUS
Definition: precomp.h:26
#define RtlClearBits
Definition: dbgbitmap.h:331
#define RtlFindNextForwardRunClear
Definition: dbgbitmap.h:338
#define RtlFindClearBitsAndSet
Definition: dbgbitmap.h:333
#define RtlFindLongestRunClear
Definition: dbgbitmap.h:337
#define RtlSetBits
Definition: dbgbitmap.h:345
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define ExAcquireResourceExclusiveLite(res, wait)
Definition: env_spec_w32.h:615
Status
Definition: gdiplustypes.h:24
#define KeLeaveCriticalRegion()
Definition: ke_x.h:119
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
#define min(a, b)
Definition: monoChain.cc:55
NTSTATUS NtfsWriteVolumeBitmap(_In_ PDEVICE_EXTENSION DeviceExt, _In_ ULONG FirstCluster, _In_ ULONG ClusterCount)
Definition: volinfo.c:167
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1822
#define DPRINT
Definition: sndvol32.h:73
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_DISK_FULL
Definition: udferr_usr.h:155

Referenced by NtfsExtendAllocation().

◆ NtfsFreeVolumeBitmap()

VOID NtfsFreeVolumeBitmap ( _In_ PDEVICE_EXTENSION  DeviceExt)

Definition at line 132 of file volinfo.c.

134{
135 if (DeviceExt->BitmapBuffer != NULL)
136 {
137 ExFreePoolWithTag(DeviceExt->BitmapBuffer, TAG_NTFS);
138 DeviceExt->BitmapBuffer = NULL;
139 }
140
141 if (DeviceExt->BitmapContext != NULL)
142 {
143 ReleaseAttributeContext(DeviceExt->BitmapContext);
144 DeviceExt->BitmapContext = NULL;
145 }
146}
#define NULL
Definition: types.h:112
#define TAG_NTFS
Definition: ntfs.h:12
VOID ReleaseAttributeContext(PNTFS_ATTR_CONTEXT Context)
Definition: mft.c:104
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109

Referenced by NtfsLoadVolumeBitmap().

◆ NtfsGetFreeClusters()

ULONGLONG NtfsGetFreeClusters ( PDEVICE_EXTENSION  DeviceExt)

Definition at line 193 of file volinfo.c.

194{
196
197 DPRINT("NtfsGetFreeClusters(%p)\n", DeviceExt);
198
200 ExAcquireResourceSharedLite(&DeviceExt->BitmapResource, TRUE);
201 FreeClusters = DeviceExt->FreeClusterCount;
202 ExReleaseResourceLite(&DeviceExt->BitmapResource);
204
205 return FreeClusters;
206}
NTSTATUS FreeClusters(PNTFS_VCB Vcb, PNTFS_ATTR_CONTEXT AttrContext, ULONG AttrOffset, PFILE_RECORD_HEADER FileRecord, ULONG ClustersToFree)
Definition: attrib.c:1101
#define ExAcquireResourceSharedLite(res, wait)
Definition: env_spec_w32.h:621
uint64_t ULONGLONG
Definition: typedefs.h:67

Referenced by GetNfsVolumeData(), and NtfsGetFsSizeInformation().

◆ NtfsGetFsAttributeInformation()

static NTSTATUS NtfsGetFsAttributeInformation ( PDEVICE_EXTENSION  DeviceExt,
PFILE_FS_ATTRIBUTE_INFORMATION  FsAttributeInfo,
PULONG  BufferLength 
)
static

Definition at line 340 of file volinfo.c.

343{
344 UNREFERENCED_PARAMETER(DeviceExt);
345
346 DPRINT("NtfsGetFsAttributeInformation()\n");
347 DPRINT("FsAttributeInfo = %p\n", FsAttributeInfo);
348 DPRINT("BufferLength %lu\n", *BufferLength);
349 DPRINT("Required length %lu\n", (sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 8));
350
353
354 if (*BufferLength < (sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 8))
356
357 FsAttributeInfo->FileSystemAttributes =
359 FsAttributeInfo->MaximumComponentNameLength = 255;
360 FsAttributeInfo->FileSystemNameLength = 8;
361
362 memcpy(FsAttributeInfo->FileSystemName, L"NTFS", 8);
363
364 DPRINT("Finished NtfsGetFsAttributeInformation()\n");
365
367 DPRINT("BufferLength %lu\n", *BufferLength);
368
369 return STATUS_SUCCESS;
370}
#define L(x)
Definition: resources.c:13
#define FILE_READ_ONLY_VOLUME
Definition: from_kernel.h:246
struct _FILE_FS_ATTRIBUTE_INFORMATION FILE_FS_ATTRIBUTE_INFORMATION
#define FILE_CASE_PRESERVED_NAMES
Definition: from_kernel.h:234
#define FILE_UNICODE_ON_DISK
Definition: from_kernel.h:235
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3777

Referenced by NtfsQueryVolumeInformation().

◆ NtfsGetFsDeviceInformation()

static NTSTATUS NtfsGetFsDeviceInformation ( PDEVICE_OBJECT  DeviceObject,
PFILE_FS_DEVICE_INFORMATION  FsDeviceInfo,
PULONG  BufferLength 
)
static

Definition at line 405 of file volinfo.c.

408{
409 DPRINT("NtfsGetFsDeviceInformation()\n");
410 DPRINT("FsDeviceInfo = %p\n", FsDeviceInfo);
411 DPRINT("BufferLength %lu\n", *BufferLength);
412 DPRINT("Required length %lu\n", sizeof(FILE_FS_DEVICE_INFORMATION));
413
416
417 FsDeviceInfo->DeviceType = FILE_DEVICE_DISK;
418 FsDeviceInfo->Characteristics = DeviceObject->Characteristics;
419
420 DPRINT("NtfsGetFsDeviceInformation() finished.\n");
421
423 DPRINT("BufferLength %lu\n", *BufferLength);
424
425 return STATUS_SUCCESS;
426}
struct _FILE_FS_DEVICE_INFORMATION FILE_FS_DEVICE_INFORMATION
#define FILE_DEVICE_DISK
Definition: winioctl.h:52
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2061

Referenced by NtfsQueryVolumeInformation().

◆ NtfsGetFsSizeInformation()

static NTSTATUS NtfsGetFsSizeInformation ( PDEVICE_OBJECT  DeviceObject,
PFILE_FS_SIZE_INFORMATION  FsSizeInfo,
PULONG  BufferLength 
)
static

Definition at line 375 of file volinfo.c.

378{
379 PDEVICE_EXTENSION DeviceExt;
381
382 DPRINT("NtfsGetFsSizeInformation()\n");
383 DPRINT("FsSizeInfo = %p\n", FsSizeInfo);
384
387
388 DeviceExt = DeviceObject->DeviceExtension;
389
391 FsSizeInfo->TotalAllocationUnits.QuadPart = DeviceExt->NtfsInfo.ClusterCount;
392 FsSizeInfo->SectorsPerAllocationUnit = DeviceExt->NtfsInfo.SectorsPerCluster;
393 FsSizeInfo->BytesPerSector = DeviceExt->NtfsInfo.BytesPerSector;
394
395 DPRINT("Finished NtfsGetFsSizeInformation()\n");
396 if (NT_SUCCESS(Status))
398
399 return Status;
400}
struct _FILE_FS_SIZE_INFORMATION FILE_FS_SIZE_INFORMATION
ULONGLONG NtfsGetFreeClusters(PDEVICE_EXTENSION DeviceExt)
Definition: volinfo.c:193
LARGE_INTEGER TotalAllocationUnits
Definition: from_kernel.h:263
LARGE_INTEGER AvailableAllocationUnits
Definition: from_kernel.h:264
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by NtfsQueryVolumeInformation().

◆ NtfsGetFsVolumeInformation()

static NTSTATUS NtfsGetFsVolumeInformation ( PDEVICE_OBJECT  DeviceObject,
PFILE_FS_VOLUME_INFORMATION  FsVolumeInfo,
PULONG  BufferLength 
)
static

Definition at line 294 of file volinfo.c.

297{
298 DPRINT("NtfsGetFsVolumeInformation() called\n");
299 DPRINT("FsVolumeInfo = %p\n", FsVolumeInfo);
300 DPRINT("BufferLength %lu\n", *BufferLength);
301
302 DPRINT("Vpb %p\n", DeviceObject->Vpb);
303
304 DPRINT("Required length %lu\n",
305 sizeof(FILE_FS_VOLUME_INFORMATION) + DeviceObject->Vpb->VolumeLabelLength);
306 DPRINT("LabelLength %hu\n",
307 DeviceObject->Vpb->VolumeLabelLength);
308 DPRINT("Label %.*S\n",
309 DeviceObject->Vpb->VolumeLabelLength / sizeof(WCHAR),
310 DeviceObject->Vpb->VolumeLabel);
311
314
315 if (*BufferLength < (sizeof(FILE_FS_VOLUME_INFORMATION) + DeviceObject->Vpb->VolumeLabelLength))
317
318 /* valid entries */
319 FsVolumeInfo->VolumeSerialNumber = DeviceObject->Vpb->SerialNumber;
320 FsVolumeInfo->VolumeLabelLength = DeviceObject->Vpb->VolumeLabelLength;
321 memcpy(FsVolumeInfo->VolumeLabel,
322 DeviceObject->Vpb->VolumeLabel,
323 DeviceObject->Vpb->VolumeLabelLength);
324
325 /* dummy entries */
326 FsVolumeInfo->VolumeCreationTime.QuadPart = 0;
327 FsVolumeInfo->SupportsObjects = FALSE;
328
329 *BufferLength -= (sizeof(FILE_FS_VOLUME_INFORMATION) + DeviceObject->Vpb->VolumeLabelLength);
330
331 DPRINT("BufferLength %lu\n", *BufferLength);
332 DPRINT("NtfsGetFsVolumeInformation() done\n");
333
334 return STATUS_SUCCESS;
335}
#define FALSE
Definition: types.h:117
static FsInfoType * FsVolumeInfo(char *fpath)
Definition: disk.c:974
short WCHAR
Definition: pedump.c:58
struct _FILE_FS_VOLUME_INFORMATION FILE_FS_VOLUME_INFORMATION

Referenced by NtfsQueryVolumeInformation().

◆ NtfsLoadVolumeBitmap()

NTSTATUS NtfsLoadVolumeBitmap ( _In_ PDEVICE_EXTENSION  DeviceExt)

Definition at line 49 of file volinfo.c.

51{
52 PFILE_RECORD_HEADER BitmapRecord;
53 ULONGLONG BitmapSize;
56
57 BitmapRecord = ExAllocateFromNPagedLookasideList(&DeviceExt->FileRecLookasideList);
58 if (BitmapRecord == NULL)
60
61 Status = ReadFileRecord(DeviceExt, NTFS_FILE_BITMAP, BitmapRecord);
62 if (NT_SUCCESS(Status))
63 {
64 /* The context keeps its own copy of the attribute record */
65 Status = FindAttribute(DeviceExt, BitmapRecord, AttributeData, L"", 0, &DeviceExt->BitmapContext, NULL);
66 }
67
68 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, BitmapRecord);
69
70 if (!NT_SUCCESS(Status))
71 {
72 DPRINT1("Unable to find $Bitmap (Status %lx)\n", Status);
73 DeviceExt->BitmapContext = NULL;
74 return Status;
75 }
76
77 BitmapSize = AttributeDataLength(DeviceExt->BitmapContext->pRecord);
78 if (BitmapSize > MAXULONG ||
79 BitmapSize * 8 < DeviceExt->NtfsInfo.ClusterCount ||
80 DeviceExt->NtfsInfo.ClusterCount > MAXULONG)
81 {
82 DPRINT1("$Bitmap size %I64u does not cover %I64u clusters\n",
83 BitmapSize, DeviceExt->NtfsInfo.ClusterCount);
85 goto Fail;
86 }
87
88 /* Whole sectors, so write back never reads first */
89 BufferSize = ROUND_UP((ULONG)BitmapSize, DeviceExt->NtfsInfo.BytesPerSector);
90 DeviceExt->BitmapBuffer = ExAllocatePoolWithTag(PagedPool, BufferSize, TAG_NTFS);
91 if (DeviceExt->BitmapBuffer == NULL)
92 {
94 goto Fail;
95 }
96 RtlZeroMemory(DeviceExt->BitmapBuffer, BufferSize);
97
98 if (ReadAttribute(DeviceExt, DeviceExt->BitmapContext, 0, (PCHAR)DeviceExt->BitmapBuffer, (ULONG)BitmapSize) != (ULONG)BitmapSize)
99 {
100 DPRINT1("Unable to read $Bitmap\n");
102 goto Fail;
103 }
104
105 DeviceExt->BitmapSize = (ULONG)BitmapSize;
106
107 /* $Bitmap is rounded up to a cluster and covers a few clusters more than
108 * the volume has. Bounding by ClusterCount ignores the surplus bits, but
109 * write back still preserves them on disk. */
110 RtlInitializeBitMap(&DeviceExt->ClusterBitmap, DeviceExt->BitmapBuffer, (ULONG)DeviceExt->NtfsInfo.ClusterCount);
111 DeviceExt->FreeClusterCount = RtlNumberOfClearBits(&DeviceExt->ClusterBitmap);
112
113 DPRINT("Volume bitmap loaded: %I64u of %I64u clusters free\n",
114 DeviceExt->FreeClusterCount, DeviceExt->NtfsInfo.ClusterCount);
115
116 return STATUS_SUCCESS;
117
118Fail:
119 NtfsFreeVolumeBitmap(DeviceExt);
120 return Status;
121}
#define DPRINT1
Definition: precomp.h:8
#define NTFS_FILE_BITMAP
Definition: ntfs.h:29
#define RtlInitializeBitMap
Definition: dbgbitmap.h:326
#define RtlNumberOfClearBits
Definition: dbgbitmap.h:342
#define BufferSize
Definition: mmc.h:75
_In_ ULONG BufferSize
Definition: dispmprt.h:490
@ AttributeData
Definition: ntfs.h:195
int Fail
Definition: ehthrow.cxx:24
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
#define ROUND_UP(n, align)
Definition: eventvwr.h:34
NTSTATUS ReadFileRecord(PDEVICE_EXTENSION Vcb, ULONGLONG index, PFILE_RECORD_HEADER file)
Definition: mft.c:1936
ULONGLONG AttributeDataLength(PNTFS_ATTR_RECORD AttrRecord)
Definition: mft.c:259
NTSTATUS FindAttribute(PDEVICE_EXTENSION Vcb, PFILE_RECORD_HEADER MftRecord, ULONG Type, PCWSTR Name, ULONG NameLength, PNTFS_ATTR_CONTEXT *AttrCtx, PULONG Offset)
Definition: mft.c:131
ULONG ReadAttribute(PDEVICE_EXTENSION Vcb, PNTFS_ATTR_CONTEXT Context, ULONGLONG Offset, PCHAR Buffer, ULONG Length)
Definition: mft.c:1625
VOID NtfsFreeVolumeBitmap(_In_ PDEVICE_EXTENSION DeviceExt)
Definition: volinfo.c:132
#define MAXULONG
Definition: typedefs.h:251
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
char * PCHAR
Definition: typedefs.h:51
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_FILE_CORRUPT_ERROR
Definition: udferr_usr.h:168
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158

◆ NtfsQueryVolumeInformation()

NTSTATUS NtfsQueryVolumeInformation ( PNTFS_IRP_CONTEXT  IrpContext)

Definition at line 430 of file volinfo.c.

431{
432 PIRP Irp;
437 PVOID SystemBuffer;
439 PDEVICE_EXTENSION DeviceExt;
440
441 DPRINT("NtfsQueryVolumeInformation() called\n");
442
443 ASSERT(IrpContext);
444
445 Irp = IrpContext->Irp;
446 DeviceObject = IrpContext->DeviceObject;
447 DeviceExt = DeviceObject->DeviceExtension;
448 Stack = IrpContext->Stack;
449
450 if (!ExAcquireResourceSharedLite(&DeviceExt->DirResource,
452 {
453 return NtfsMarkIrpContextForQueue(IrpContext);
454 }
455
456 FsInformationClass = Stack->Parameters.QueryVolume.FsInformationClass;
457 BufferLength = Stack->Parameters.QueryVolume.Length;
458 SystemBuffer = Irp->AssociatedIrp.SystemBuffer;
459 RtlZeroMemory(SystemBuffer, BufferLength);
460
461 DPRINT("FsInformationClass %d\n", FsInformationClass);
462 DPRINT("SystemBuffer %p\n", SystemBuffer);
463
464 switch (FsInformationClass)
465 {
468 SystemBuffer,
469 &BufferLength);
470 break;
471
474 SystemBuffer,
475 &BufferLength);
476 break;
477
480 SystemBuffer,
481 &BufferLength);
482 break;
483
486 SystemBuffer,
487 &BufferLength);
488 break;
489
490 default:
492 }
493
494 ExReleaseResourceLite(&DeviceExt->DirResource);
495
496 if (NT_SUCCESS(Status))
497 Irp->IoStatus.Information =
498 Stack->Parameters.QueryVolume.Length - BufferLength;
499 else
500 Irp->IoStatus.Information = 0;
501
502 return Status;
503}
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
FORCEINLINE NTSTATUS NtfsMarkIrpContextForQueue(PNTFS_IRP_CONTEXT IrpContext)
Definition: ntfs.h:652
#define IRPCONTEXT_CANWAIT
Definition: ntfs.h:505
#define BooleanFlagOn(F, SF)
Definition: ext2fs.h:183
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG _In_ FS_INFORMATION_CLASS FsInformationClass
Definition: fltkernel.h:1330
@ FileFsDeviceInformation
Definition: from_kernel.h:222
@ FileFsAttributeInformation
Definition: from_kernel.h:223
@ FileFsVolumeInformation
Definition: from_kernel.h:219
@ FileFsSizeInformation
Definition: from_kernel.h:221
enum _FSINFOCLASS FS_INFORMATION_CLASS
_In_ PIRP Irp
Definition: kse.h:79
#define ASSERT(a)
Definition: mode.c:44
static NTSTATUS NtfsGetFsDeviceInformation(PDEVICE_OBJECT DeviceObject, PFILE_FS_DEVICE_INFORMATION FsDeviceInfo, PULONG BufferLength)
Definition: volinfo.c:405
static NTSTATUS NtfsGetFsVolumeInformation(PDEVICE_OBJECT DeviceObject, PFILE_FS_VOLUME_INFORMATION FsVolumeInfo, PULONG BufferLength)
Definition: volinfo.c:294
static NTSTATUS NtfsGetFsAttributeInformation(PDEVICE_EXTENSION DeviceExt, PFILE_FS_ATTRIBUTE_INFORMATION FsAttributeInfo, PULONG BufferLength)
Definition: volinfo.c:340
static NTSTATUS NtfsGetFsSizeInformation(PDEVICE_OBJECT DeviceObject, PFILE_FS_SIZE_INFORMATION FsSizeInfo, PULONG BufferLength)
Definition: volinfo.c:375
ULONG Flags
Definition: ntfs.h:556
PIO_STACK_LOCATION Stack
Definition: ntfs.h:557
PDEVICE_OBJECT DeviceObject
Definition: ntfs.h:563
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:639

Referenced by NtfsDispatch().

◆ NtfsSetVolumeInformation()

NTSTATUS NtfsSetVolumeInformation ( PNTFS_IRP_CONTEXT  IrpContext)

Definition at line 507 of file volinfo.c.

508{
509 PIRP Irp;
510
511 DPRINT("NtfsSetVolumeInformation() called\n");
512
513 ASSERT(IrpContext);
514
515 Irp = IrpContext->Irp;
517 Irp->IoStatus.Information = 0;
518
520}
IO_STATUS_BLOCK IoStatus

Referenced by NtfsDispatch().

◆ NtfsWriteVolumeBitmap()

NTSTATUS NtfsWriteVolumeBitmap ( _In_ PDEVICE_EXTENSION  DeviceExt,
_In_ ULONG  FirstCluster,
_In_ ULONG  ClusterCount 
)

Definition at line 167 of file volinfo.c.

171{
172 ULONG SectorSize = DeviceExt->NtfsInfo.BytesPerSector;
173 ULONG Start;
174 ULONG End;
175 ULONG LengthWritten;
176
177 ASSERT(ClusterCount != 0);
178
179 Start = ROUND_DOWN(FirstCluster / 8, SectorSize);
180 End = ROUND_UP((FirstCluster + ClusterCount - 1) / 8 + 1, SectorSize);
181 End = min(End, ROUND_UP(DeviceExt->BitmapSize, SectorSize));
182
183 return WriteAttribute(DeviceExt,
184 DeviceExt->BitmapContext,
185 Start,
186 (PUCHAR)DeviceExt->BitmapBuffer + Start,
187 End - Start,
188 &LengthWritten,
189 NULL);
190}
static _Out_opt_ PULONGLONG Start
#define ROUND_DOWN(n, align)
Definition: eventvwr.h:33
NTSTATUS WriteAttribute(PDEVICE_EXTENSION Vcb, PNTFS_ATTR_CONTEXT Context, ULONGLONG Offset, const PUCHAR Buffer, ULONG Length, PULONG RealLengthWritten, PFILE_RECORD_HEADER FileRecord)
Definition: mft.c:1829
unsigned char * PUCHAR
Definition: typedefs.h:53
_In_ ULONG SectorSize
Definition: halfuncs.h:291

Referenced by FreeClusters(), and NtfsAllocateClusters().