ReactOS  0.4.15-dev-3303-g1ade494
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

BOOLEAN NTAPI VfatxFormat (IN PUNICODE_STRING DriveRoot, IN PFMIFSCALLBACK Callback, IN BOOLEAN QuickFormat, IN BOOLEAN BackwardCompatible, IN MEDIA_TYPE MediaType, IN PUNICODE_STRING Label, IN ULONG ClusterSize)
 
BOOLEAN NTAPI VfatxChkdsk (IN PUNICODE_STRING DriveRoot, IN PFMIFSCALLBACK Callback, IN BOOLEAN FixErrors, IN BOOLEAN Verbose, IN BOOLEAN CheckOnlyIfDirty, IN BOOLEAN ScanDrive, IN PVOID pUnknown1, IN PVOID pUnknown2, IN PVOID pUnknown3, IN PVOID pUnknown4, IN PULONG ExitStatus)
 
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()

BOOLEAN NTAPI VfatxChkdsk ( IN PUNICODE_STRING  DriveRoot,
IN PFMIFSCALLBACK  Callback,
IN BOOLEAN  FixErrors,
IN BOOLEAN  Verbose,
IN BOOLEAN  CheckOnlyIfDirty,
IN BOOLEAN  ScanDrive,
IN PVOID  pUnknown1,
IN PVOID  pUnknown2,
IN PVOID  pUnknown3,
IN PVOID  pUnknown4,
IN PULONG  ExitStatus 
)

Definition at line 162 of file vfatxlib.c.

174 {
177  return TRUE;
178 }
#define TRUE
Definition: types.h:120
_In_ NTSTATUS ExitStatus
Definition: psfuncs.h:859
unsigned int ULONG
Definition: retypes.h:1
#define UNIMPLEMENTED
Definition: debug.h:115
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ VfatxFormat()

BOOLEAN NTAPI VfatxFormat ( IN PUNICODE_STRING  DriveRoot,
IN PFMIFSCALLBACK  Callback,
IN BOOLEAN  QuickFormat,
IN BOOLEAN  BackwardCompatible,
IN MEDIA_TYPE  MediaType,
IN PUNICODE_STRING  Label,
IN ULONG  ClusterSize 
)

Definition at line 20 of file vfatxlib.c.

28 {
30  DISK_GEOMETRY DiskGeometry;
36 
37  DPRINT("VfatxFormat(DriveRoot '%wZ')\n", DriveRoot);
38 
39  // FIXME:
40  UNREFERENCED_PARAMETER(MediaType);
41 
42  if (BackwardCompatible)
43  {
44  DPRINT1("BackwardCompatible == TRUE is unsupported!\n");
45  return FALSE;
46  }
47 
48  Context.TotalSectorCount = 0;
49  Context.CurrentSectorCount = 0;
50  Context.Callback = Callback;
51  Context.Success = FALSE;
52  Context.Percent = 0;
53 
55  DriveRoot,
56  0,
57  NULL,
58  NULL);
59 
63  &Iosb,
66  if (!NT_SUCCESS(Status))
67  {
68  DPRINT("NtOpenFile() failed with status 0x%08x\n", Status);
69  return FALSE;
70  }
71 
73  NULL,
74  NULL,
75  NULL,
76  &Iosb,
78  NULL,
79  0,
80  &DiskGeometry,
81  sizeof(DISK_GEOMETRY));
82  if (!NT_SUCCESS(Status))
83  {
84  DPRINT("IOCTL_DISK_GET_DRIVE_GEOMETRY failed with status 0x%08x\n", Status);
86  return FALSE;
87  }
88 
89  if (DiskGeometry.MediaType == FixedMedia)
90  {
91  DPRINT("Cylinders %I64d\n", DiskGeometry.Cylinders.QuadPart);
92  DPRINT("TracksPerCylinder %ld\n", DiskGeometry.TracksPerCylinder);
93  DPRINT("SectorsPerTrack %ld\n", DiskGeometry.SectorsPerTrack);
94  DPRINT("BytesPerSector %ld\n", DiskGeometry.BytesPerSector);
95  DPRINT("DiskSize %I64d\n",
96  DiskGeometry.Cylinders.QuadPart *
97  (ULONGLONG)DiskGeometry.TracksPerCylinder *
98  (ULONGLONG)DiskGeometry.SectorsPerTrack *
99  (ULONGLONG)DiskGeometry.BytesPerSector);
100 
102  NULL,
103  NULL,
104  NULL,
105  &Iosb,
107  NULL,
108  0,
109  &PartitionInfo,
110  sizeof(PARTITION_INFORMATION));
111  if (!NT_SUCCESS(Status))
112  {
113  DPRINT("IOCTL_DISK_GET_PARTITION_INFO failed with status 0x%08x\n", Status);
115  return FALSE;
116  }
117  }
118  else
119  {
120  PartitionInfo.PartitionType = 0;
121  PartitionInfo.StartingOffset.QuadPart = 0ULL;
122  PartitionInfo.PartitionLength.QuadPart =
123  DiskGeometry.Cylinders.QuadPart *
124  (ULONGLONG)DiskGeometry.TracksPerCylinder *
125  (ULONGLONG)DiskGeometry.SectorsPerTrack *
126  (ULONGLONG)DiskGeometry.BytesPerSector;
127  PartitionInfo.HiddenSectors = 0;
128  PartitionInfo.PartitionNumber = 0;
129  PartitionInfo.BootIndicator = FALSE;
130  PartitionInfo.RewritePartition = FALSE;
131  PartitionInfo.RecognizedPartition = FALSE;
132  }
133 
134  DPRINT("PartitionType 0x%x\n", PartitionInfo.PartitionType);
135  DPRINT("StartingOffset %I64d\n", PartitionInfo.StartingOffset.QuadPart);
136  DPRINT("PartitionLength %I64d\n", PartitionInfo.PartitionLength.QuadPart);
137  DPRINT("HiddenSectors %lu\n", PartitionInfo.HiddenSectors);
138  DPRINT("PartitionNumber %d\n", PartitionInfo.PartitionNumber);
139  DPRINT("BootIndicator 0x%x\n", PartitionInfo.BootIndicator);
140  DPRINT("RewritePartition %d\n", PartitionInfo.RewritePartition);
141  DPRINT("RecognizedPartition %d\n", PartitionInfo.RecognizedPartition);
142 
143  if (Callback != NULL)
144  {
145  Context.Percent = 0;
146  Callback(PROGRESS, 0, (PVOID)&Context.Percent);
147  }
148 
150  &PartitionInfo,
151  &DiskGeometry,
152  QuickFormat,
153  &Context);
155 
156  DPRINT("VfatxFormat() done. Status 0x%08x\n", Status);
157  return NT_SUCCESS(Status);
158 }
#define FILE_GENERIC_READ
Definition: nt_native.h:653
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
LONG NTSTATUS
Definition: precomp.h:26
Definition: fmifs.h:68
ULONG BytesPerSector
Definition: ntdddisk.h:409
ULONG TracksPerCylinder
Definition: ntdddisk.h:407
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:136
HANDLE FileHandle
Definition: stats.c:38
#define FILE_SYNCHRONOUS_IO_ALERT
Definition: from_kernel.h:30
#define FALSE
Definition: types.h:117
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
BOOL QuickFormat
Definition: format.c:66
#define ULL(a, b)
Definition: format_msg.c:27
Status
Definition: gdiplustypes.h:24
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:4402
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
uint64_t ULONGLONG
Definition: typedefs.h:67
LARGE_INTEGER Cylinders
Definition: ntdddisk.h:405
ULONG SectorsPerTrack
Definition: ntdddisk.h:408
_In_ ULONG _In_ struct _SET_PARTITION_INFORMATION_EX * PartitionInfo
Definition: iofuncs.h:2105
MEDIA_TYPE MediaType
Definition: ntdddisk.h:406
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3398
#define IOCTL_DISK_GET_PARTITION_INFO
Definition: ntdddisk.h:106
_In_ WDFINTERRUPT _In_ PFN_WDF_INTERRUPT_SYNCHRONIZE Callback
Definition: wdfinterrupt.h:456
#define FILE_GENERIC_WRITE
Definition: nt_native.h:660
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
struct tagContext Context
Definition: acpixf.h:1034
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define DPRINT
Definition: sndvol32.h:71
#define IOCTL_DISK_GET_DRIVE_GEOMETRY
Definition: cdrw_usr.h:169
LONGLONG QuadPart
Definition: typedefs.h:114

◆ VfatxUpdateProgress()

VOID VfatxUpdateProgress ( IN PFORMAT_CONTEXT  Context,
IN ULONG  Increment 
)

Definition at line 181 of file vfatxlib.c.

183 {
184  ULONG NewPercent;
185 
186  Context->CurrentSectorCount += (ULONGLONG)Increment;
187 
188  NewPercent = (Context->CurrentSectorCount * 100ULL) / Context->TotalSectorCount;
189 
190  if (NewPercent > Context->Percent)
191  {
192  Context->Percent = NewPercent;
193  if (Context->Callback != NULL)
194  {
195  Context->Callback(PROGRESS, 0, &Context->Percent);
196  }
197  }
198 }
Definition: fmifs.h:68
if(dx==0 &&dy==0)
Definition: linetemp.h:174
#define ULL(a, b)
Definition: format_msg.c:27
uint64_t ULONGLONG
Definition: typedefs.h:67
#define NULL
Definition: types.h:112
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().