ReactOS  0.4.14-dev-1332-g6db3d88
vfatxlib.c File Reference
#include "vfatxlib.h"
#include <ndk/obfuncs.h>
#include <debug.h>
Include dependency graph for vfatxlib.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI VfatxFormat (IN PUNICODE_STRING DriveRoot, IN FMIFS_MEDIA_FLAG MediaFlag, IN PUNICODE_STRING Label, IN BOOLEAN QuickFormat, IN ULONG ClusterSize, IN PFMIFSCALLBACK Callback)
 
NTSTATUS NTAPI VfatxChkdsk (IN PUNICODE_STRING DriveRoot, IN BOOLEAN FixErrors, IN BOOLEAN Verbose, IN BOOLEAN CheckOnlyIfDirty, IN BOOLEAN ScanDrive, IN PFMIFSCALLBACK Callback)
 
VOID VfatxUpdateProgress (IN PFORMAT_CONTEXT Context, IN ULONG Increment)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 15 of file vfatxlib.c.

Function Documentation

◆ VfatxChkdsk()

NTSTATUS NTAPI VfatxChkdsk ( IN PUNICODE_STRING  DriveRoot,
IN BOOLEAN  FixErrors,
IN BOOLEAN  Verbose,
IN BOOLEAN  CheckOnlyIfDirty,
IN BOOLEAN  ScanDrive,
IN PFMIFSCALLBACK  Callback 
)

Definition at line 156 of file vfatxlib.c.

162 {
164  return STATUS_SUCCESS;
165 }
#define UNIMPLEMENTED
Definition: debug.h:114
return STATUS_SUCCESS
Definition: btrfs.c:2938

◆ VfatxFormat()

NTSTATUS NTAPI VfatxFormat ( IN PUNICODE_STRING  DriveRoot,
IN FMIFS_MEDIA_FLAG  MediaFlag,
IN PUNICODE_STRING  Label,
IN BOOLEAN  QuickFormat,
IN ULONG  ClusterSize,
IN PFMIFSCALLBACK  Callback 
)

Definition at line 19 of file vfatxlib.c.

25 {
27  DISK_GEOMETRY DiskGeometry;
33 
34  DPRINT("VfatxFormat(DriveRoot '%wZ')\n", DriveRoot);
35 
36  Context.TotalSectorCount = 0;
37  Context.CurrentSectorCount = 0;
38  Context.Callback = Callback;
39  Context.Success = FALSE;
40  Context.Percent = 0;
41 
43  DriveRoot,
44  0,
45  NULL,
46  NULL);
47 
51  &Iosb,
54  if (!NT_SUCCESS(Status))
55  {
56  DPRINT("NtOpenFile() failed with status 0x%.08x\n", Status);
57  return Status;
58  }
59 
61  NULL,
62  NULL,
63  NULL,
64  &Iosb,
66  NULL,
67  0,
68  &DiskGeometry,
69  sizeof(DISK_GEOMETRY));
70  if (!NT_SUCCESS(Status))
71  {
72  DPRINT("IOCTL_DISK_GET_DRIVE_GEOMETRY failed with status 0x%.08x\n", Status);
74  return Status;
75  }
76 
77  if (DiskGeometry.MediaType == FixedMedia)
78  {
79  DPRINT("Cylinders %I64d\n", DiskGeometry.Cylinders.QuadPart);
80  DPRINT("TracksPerCylinder %ld\n", DiskGeometry.TracksPerCylinder);
81  DPRINT("SectorsPerTrack %ld\n", DiskGeometry.SectorsPerTrack);
82  DPRINT("BytesPerSector %ld\n", DiskGeometry.BytesPerSector);
83  DPRINT("DiskSize %I64d\n",
84  DiskGeometry.Cylinders.QuadPart *
85  (ULONGLONG)DiskGeometry.TracksPerCylinder *
86  (ULONGLONG)DiskGeometry.SectorsPerTrack *
87  (ULONGLONG)DiskGeometry.BytesPerSector);
88 
90  NULL,
91  NULL,
92  NULL,
93  &Iosb,
95  NULL,
96  0,
98  sizeof(PARTITION_INFORMATION));
99  if (!NT_SUCCESS(Status))
100  {
101  DPRINT("IOCTL_DISK_GET_PARTITION_INFO failed with status 0x%.08x\n", Status);
103  return Status;
104  }
105  }
106  else
107  {
108  PartitionInfo.PartitionType = 0;
109  PartitionInfo.StartingOffset.QuadPart = 0ULL;
110  PartitionInfo.PartitionLength.QuadPart =
111  DiskGeometry.Cylinders.QuadPart *
112  (ULONGLONG)DiskGeometry.TracksPerCylinder *
113  (ULONGLONG)DiskGeometry.SectorsPerTrack *
114  (ULONGLONG)DiskGeometry.BytesPerSector;
115  PartitionInfo.HiddenSectors = 0;
116  PartitionInfo.PartitionNumber = 0;
117  PartitionInfo.BootIndicator = FALSE;
118  PartitionInfo.RewritePartition = FALSE;
119  PartitionInfo.RecognizedPartition = FALSE;
120  }
121 
122  DPRINT("PartitionType 0x%x\n", PartitionInfo.PartitionType);
123  DPRINT("StartingOffset %I64d\n", PartitionInfo.StartingOffset.QuadPart);
124  DPRINT("PartitionLength %I64d\n", PartitionInfo.PartitionLength.QuadPart);
125  DPRINT("HiddenSectors %lu\n", PartitionInfo.HiddenSectors);
126  DPRINT("PartitionNumber %d\n", PartitionInfo.PartitionNumber);
127  DPRINT("BootIndicator 0x%x\n", PartitionInfo.BootIndicator);
128  DPRINT("RewritePartition %d\n", PartitionInfo.RewritePartition);
129  DPRINT("RecognizedPartition %d\n", PartitionInfo.RecognizedPartition);
130 
131  if (Callback != NULL)
132  {
133  Context.Percent = 0;
134  Callback(PROGRESS, 0, (PVOID)&Context.Percent);
135  }
136 
138  &PartitionInfo,
139  &DiskGeometry,
140  QuickFormat,
141  &Context);
143 
144  if (Callback != NULL)
145  {
146  Context.Success = (BOOLEAN)(NT_SUCCESS(Status));
147  Callback(DONE, 0, (PVOID)&Context.Success);
148  }
149 
150  DPRINT("VfatxFormat() done. Status 0x%.08x\n", Status);
151 
152  return Status;
153 }
#define FILE_GENERIC_READ
Definition: nt_native.h:653
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
LONG NTSTATUS
Definition: precomp.h:26
Definition: fmifs.h:68
ULONG BytesPerSector
Definition: ntdddisk.h:381
ULONG TracksPerCylinder
Definition: ntdddisk.h:379
NTSYSAPI NTSTATUS NTAPI NtDeviceIoControlFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG DeviceIoControlCode, IN PVOID InBuffer OPTIONAL, IN ULONG InBufferLength, OUT PVOID OutBuffer OPTIONAL, IN ULONG OutBufferLength)
#define FILE_SHARE_READ
Definition: compat.h:125
HANDLE FileHandle
Definition: stats.c:38
#define FILE_SYNCHRONOUS_IO_ALERT
Definition: from_kernel.h:30
NTSTATUS FatxFormat(IN HANDLE FileHandle, IN PPARTITION_INFORMATION PartitionInfo, IN PDISK_GEOMETRY DiskGeometry, IN BOOLEAN QuickFormat, IN OUT PFORMAT_CONTEXT Context)
Definition: fatx.c:343
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
BOOL QuickFormat
Definition: format.c:66
#define ULL(a, b)
Definition: format_msg.c:27
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3951
return Iosb
Definition: create.c:4426
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
uint64_t ULONGLONG
Definition: typedefs.h:66
LARGE_INTEGER Cylinders
Definition: ntdddisk.h:377
ULONG SectorsPerTrack
Definition: ntdddisk.h:380
_In_ ULONG _In_ struct _SET_PARTITION_INFORMATION_EX * PartitionInfo
Definition: iofuncs.h:2101
MEDIA_TYPE MediaType
Definition: ntdddisk.h:378
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define IOCTL_DISK_GET_PARTITION_INFO
Definition: ntdddisk.h:88
Status
Definition: gdiplustypes.h:24
#define FILE_GENERIC_WRITE
Definition: nt_native.h:660
#define BOOLEAN
Definition: pedump.c:73
struct tagContext Context
Definition: acpixf.h:1034
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define DONE
Definition: rnr20lib.h:14
LPFNPSPCALLBACK Callback
Definition: desk.c:112
#define IOCTL_DISK_GET_DRIVE_GEOMETRY
Definition: cdrw_usr.h:169
LONGLONG QuadPart
Definition: typedefs.h:113

◆ VfatxUpdateProgress()

VOID VfatxUpdateProgress ( IN PFORMAT_CONTEXT  Context,
IN ULONG  Increment 
)

Definition at line 168 of file vfatxlib.c.

170 {
171  ULONG NewPercent;
172 
173  Context->CurrentSectorCount += (ULONGLONG)Increment;
174 
175  NewPercent = (Context->CurrentSectorCount * 100ULL) / Context->TotalSectorCount;
176 
177  if (NewPercent > Context->Percent)
178  {
179  Context->Percent = NewPercent;
180  if (Context->Callback != NULL)
181  {
182  Context->Callback(PROGRESS, 0, &Context->Percent);
183  }
184  }
185 }
Definition: fmifs.h:68
smooth NULL
Definition: ftsmooth.c:416
#define ULL(a, b)
Definition: format_msg.c:27
if(!(yy_init))
Definition: macro.lex.yy.c:714
uint64_t ULONGLONG
Definition: typedefs.h:66
unsigned int ULONG
Definition: retypes.h:1
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG Increment
Definition: CrNtStubs.h:42

Referenced by Fatx16WriteFAT(), Fatx32WriteFAT(), and FatxWriteBootSector().