ReactOS  0.4.12-dev-918-g6c6e7b8
format.c File Reference
#include <stdio.h>
#include <tchar.h>
#include <windef.h>
#include <winbase.h>
#include <conutils.h>
#include <ndk/rtlfuncs.h>
#include <fmifs/fmifs.h>
#include "resource.h"
Include dependency graph for format.c:

Go to the source code of this file.

Classes

struct  SIZEDEFINITION
 

Macros

#define WIN32_NO_STATUS
 
#define NTOS_MODE_USER
 
#define FMIFS_IMPORT_DLL
 

Typedefs

typedef struct SIZEDEFINITIONPSIZEDEFINITION
 

Functions

static VOID PrintWin32Error (LPWSTR Message, DWORD ErrorCode)
 
static int ParseCommandLine (int argc, WCHAR *argv[])
 
BOOLEAN WINAPI FormatExCallback (CALLBACKCOMMAND Command, ULONG Modifier, PVOID Argument)
 
static VOID Usage (LPWSTR ProgramName)
 
int wmain (int argc, WCHAR *argv[])
 

Variables

BOOL Error = FALSE
 
BOOL QuickFormat = FALSE
 
DWORD ClusterSize = 0
 
BOOL CompressDrive = FALSE
 
BOOL GotALabel = FALSE
 
PWCHAR Label = L""
 
PWCHAR Drive = NULL
 
PWCHAR FileSystem = L"FAT"
 
WCHAR RootDirectory [MAX_PATH]
 
WCHAR LabelString [12]
 
SIZEDEFINITION LegalSizes []
 

Macro Definition Documentation

◆ FMIFS_IMPORT_DLL

#define FMIFS_IMPORT_DLL

Definition at line 60 of file format.c.

◆ NTOS_MODE_USER

#define NTOS_MODE_USER

Definition at line 52 of file format.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 46 of file format.c.

Typedef Documentation

◆ PSIZEDEFINITION

Function Documentation

◆ FormatExCallback()

BOOLEAN WINAPI FormatExCallback ( CALLBACKCOMMAND  Command,
ULONG  Modifier,
PVOID  Argument 
)

Definition at line 215 of file format.c.

219 {
220  PDWORD percent;
223 
224  //
225  // We get other types of commands, but we don't have to pay attention to them
226  //
227  switch (Command)
228  {
229  case PROGRESS:
230  percent = (PDWORD)Argument;
231  ConResPrintf(StdOut, STRING_COMPLETE, *percent);
232  break;
233 
234  case OUTPUT:
235  output = (PTEXTOUTPUT)Argument;
236  ConPrintf(StdOut, L"%S\n", output->Output);
237  break;
238 
239  case DONE:
240  status = (PBOOLEAN)Argument;
241  if (*status == FALSE)
242  {
244  Error = TRUE;
245  }
246  break;
247 
248  case DONEWITHSTRUCTURE:
249  case UNKNOWN2:
250  case UNKNOWN3:
251  case UNKNOWN4:
252  case UNKNOWN5:
253  case INSUFFICIENTRIGHTS:
254  case FSNOTSUPPORTED:
255  case VOLUMEINUSE:
256  case UNKNOWN9:
257  case UNKNOWNA:
258  case UNKNOWNC:
259  case UNKNOWND:
260  case STRUCTUREPROGRESS:
261  case CLUSTERSIZETOOSMALL:
263  return FALSE;
264  }
265  return TRUE;
266 }
#define TRUE
Definition: types.h:120
Definition: fmifs.h:71
static UCHAR ULONG UCHAR ULONG UCHAR * output
Definition: bcrypt.c:29
#define STRING_FORMAT_FAIL
Definition: resource.h:7
Definition: fmifs.h:72
Definition: fmifs.h:70
#define STRING_NO_SUPPORT
Definition: resource.h:8
Definition: fmifs.h:68
Definition: fmifs.h:78
Definition: fmifs.h:73
Definition: shell.h:41
struct TEXTOUTPUT * PTEXTOUTPUT
Definition: fmifs.h:77
Definition: fmifs.h:80
INT __cdecl ConPrintf(IN PCON_STREAM Stream, IN LPWSTR szStr,...)
Definition: outstream.c:520
#define STRING_COMPLETE
Definition: resource.h:6
INT __cdecl ConResPrintf(IN PCON_STREAM Stream, IN UINT uID,...)
Definition: outstream.c:781
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
char * PBOOLEAN
Definition: retypes.h:11
static const WCHAR L[]
Definition: oid.c:1250
BOOL Error
Definition: format.c:63
DWORD * PDWORD
Definition: pedump.c:68
Definition: fmifs.h:81
#define StdOut
Definition: stream.h:76
#define DONE
Definition: rnr20lib.h:14
Definition: fmifs.h:82
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by wmain().

◆ ParseCommandLine()

static int ParseCommandLine ( int  argc,
WCHAR argv[] 
)
static

Definition at line 133 of file format.c.

134 {
135  int i, j;
136  BOOLEAN gotFormat = FALSE;
137  BOOLEAN gotQuick = FALSE;
138  BOOLEAN gotSize = FALSE;
139  BOOLEAN gotLabel = FALSE;
140  BOOLEAN gotCompressed = FALSE;
141 
142  for (i = 1; i < argc; i++)
143  {
144  switch (argv[i][0])
145  {
146  case L'-': case L'/':
147 
148  if (!_wcsnicmp(&argv[i][1], L"FS:", 3))
149  {
150  if (gotFormat) return -1;
151  FileSystem = &argv[i][4];
152  gotFormat = TRUE;
153  }
154  else if (!_wcsnicmp(&argv[i][1], L"A:", 2))
155  {
156  if (gotSize) return -1;
157  j = 0;
158  while (LegalSizes[j].ClusterSize &&
159  wcsicmp(LegalSizes[j].SizeString, &argv[i][3]))
160  {
161  j++;
162  }
163 
164  if (!LegalSizes[j].ClusterSize) return i;
166  gotSize = TRUE;
167  }
168  else if (!_wcsnicmp(&argv[i][1], L"V:", 2))
169  {
170  if (gotLabel) return -1;
171  Label = &argv[i][3];
172  gotLabel = TRUE;
173  GotALabel = TRUE;
174  }
175  else if (!wcsicmp(&argv[i][1], L"Q"))
176  {
177  if (gotQuick) return -1;
178  QuickFormat = TRUE;
179  gotQuick = TRUE;
180  }
181  else if (!wcsicmp(&argv[i][1], L"C"))
182  {
183  if (gotCompressed) return -1;
185  gotCompressed = TRUE;
186  }
187  else
188  {
189  return i;
190  }
191  break;
192 
193  default:
194  {
195  if (Drive) return i;
196  if (argv[i][1] != L':') return i;
197 
198  Drive = argv[i];
199  break;
200  }
201  }
202  }
203  return 0;
204 }
static int argc
Definition: ServiceArgs.c:12
#define TRUE
Definition: types.h:120
PWCHAR FileSystem
Definition: format.c:72
BOOL CompressDrive
Definition: format.c:68
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define argv
Definition: mplay32.c:18
PWCHAR Drive
Definition: format.c:71
DWORD ClusterSize
Definition: format.c:92
unsigned char BOOLEAN
BOOL QuickFormat
Definition: format.c:66
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
BOOL GotALabel
Definition: format.c:69
DWORD ClusterSize
Definition: format.c:67
SIZEDEFINITION LegalSizes[]
Definition: format.c:95
static const WCHAR L[]
Definition: oid.c:1250
#define wcsicmp
Definition: string.h:1152
int i
Definition: format.c:271
PWCHAR Label
Definition: format.c:70

Referenced by wmain().

◆ PrintWin32Error()

static VOID PrintWin32Error ( LPWSTR  Message,
DWORD  ErrorCode 
)
static

Definition at line 117 of file format.c.

118 {
119  ConPrintf(StdErr, L"%s: ", Message);
122  ConPuts(StdErr, L"\n");
123 }
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4418
INT __cdecl ConPrintf(IN PCON_STREAM Stream, IN LPWSTR szStr,...)
Definition: outstream.c:520
smooth NULL
Definition: ftsmooth.c:416
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:404
INT ConMsgPuts(IN PCON_STREAM Stream, IN DWORD dwFlags, IN LPCVOID lpSource OPTIONAL, IN DWORD dwMessageId, IN DWORD dwLanguageId)
Definition: outstream.c:837
#define StdErr
Definition: stream.h:77
CHAR Message[80]
Definition: alive.c:5
static const WCHAR L[]
Definition: oid.c:1250
INT ConPuts(IN PCON_STREAM Stream, IN LPWSTR szStr)
Definition: outstream.c:427
#define LANG_USER_DEFAULT
Definition: tnerror.cpp:50

Referenced by wmain().

◆ Usage()

static VOID Usage ( LPWSTR  ProgramName)
static

Definition at line 315 of file format.c.

316 {
317  WCHAR szMsg[RC_STRING_MAX_SIZE];
318  WCHAR szFormats[MAX_PATH];
319  WCHAR szFormatW[MAX_PATH];
320  DWORD Index = 0;
321  BYTE dummy;
322  BOOLEAN latestVersion;
323 
325 
326 #ifndef FMIFS_IMPORT_DLL
327  if (!LoadFMIFSEntryPoints())
328  {
329  ConPrintf(StdOut, szMsg, ProgramName, L"");
330  return;
331  }
332 #endif
333 
334  szFormats[0] = 0;
335  while (QueryAvailableFileSystemFormat(Index++, szFormatW, &dummy, &dummy, &latestVersion))
336  {
337  if (!latestVersion)
338  continue;
339  if (szFormats[0])
340  wcscat(szFormats, L", ");
341 
342  wcscat(szFormats, szFormatW);
343  }
344  ConPrintf(StdOut, szMsg, ProgramName, szFormats);
345 }
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
INT WINAPI K32LoadStringW(IN HINSTANCE hInstance OPTIONAL, IN UINT uID, OUT LPWSTR lpBuffer, IN INT nBufferMax)
Definition: utils.c:173
INT __cdecl ConPrintf(IN PCON_STREAM Stream, IN LPWSTR szStr,...)
Definition: outstream.c:520
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define RC_STRING_MAX_SIZE
Definition: resource.h:3
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
static const UCHAR Index[8]
Definition: usbohci.c:18
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
unsigned char BYTE
Definition: mem.h:68
#define GetModuleHandle
Definition: winbase.h:3641
unsigned char dummy
Definition: maze.c:118
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define STRING_HELP
Definition: xcopy.h:74
#define StdOut
Definition: stream.h:76
BOOLEAN NTAPI QueryAvailableFileSystemFormat(IN DWORD Index, IN OUT PWCHAR FileSystem, OUT UCHAR *Major, OUT UCHAR *Minor, OUT BOOLEAN *LatestVersion)
Definition: query.c:14

Referenced by CheckDeviceFormat(), and wmain().

◆ wmain()

int wmain ( int  argc,
WCHAR argv[] 
)

Definition at line 360 of file format.c.

361 {
362  int badArg;
364  DWORD driveType;
365  WCHAR fileSystem[1024];
366  WCHAR volumeName[1024];
367  WCHAR input[1024];
369  DWORD flags, maxComponent;
370  ULARGE_INTEGER freeBytesAvailableToCaller, totalNumberOfBytes, totalNumberOfFreeBytes;
371  WCHAR szMsg[RC_STRING_MAX_SIZE];
372 
373  /* Initialize the Console Standard Streams */
375 
376  ConPuts(StdOut,
377  L"\n"
378  L"Formatx v1.0 by Mark Russinovich\n"
379  L"Systems Internals - http://www.sysinternals.com\n"
380  L"ReactOS adaptation 1999 by Emanuele Aliberti\n\n");
381 
382 #ifndef FMIFS_IMPORT_DLL
383  //
384  // Get function pointers
385  //
386  if (!LoadFMIFSEntryPoints())
387  {
389  return -1;
390  }
391 #endif
392 
393  //
394  // Parse command line
395  //
396  badArg = ParseCommandLine(argc, argv);
397  if (badArg)
398  {
400  Usage(argv[0]);
401  return -1;
402  }
403 
404  //
405  // Get the drive's format
406  //
407  if (!Drive)
408  {
410  Usage(argv[0]);
411  return -1;
412  }
413  else
414  {
416  }
417  RootDirectory[2] = L'\\';
418  RootDirectory[3] = L'\0';
419 
420  //
421  // See if the drive is removable or not
422  //
423  driveType = GetDriveTypeW(RootDirectory);
424  switch (driveType)
425  {
426  case DRIVE_UNKNOWN :
428  PrintWin32Error(szMsg, GetLastError());
429  return -1;
430 
431  case DRIVE_REMOTE:
432  case DRIVE_CDROM:
434  return -1;
435 
436  case DRIVE_NO_ROOT_DIR:
438  PrintWin32Error(szMsg, GetLastError());
439  return -1;
440 
441  case DRIVE_REMOVABLE:
445  break;
446 
447  case DRIVE_FIXED:
448  case DRIVE_RAMDISK:
450  break;
451  }
452 
453  // Reject attempts to format the system drive
454  {
455  WCHAR path[MAX_PATH + 1];
456  UINT rc;
458  if (rc == 0 || rc > MAX_PATH)
459  // todo: Report "Unable to query system directory"
460  return -1;
461  if (towlower(path[0]) == towlower(Drive[0]))
462  {
463  // todo: report "Cannot format system drive"
465  return -1;
466  }
467  }
468 
469  //
470  // Determine the drive's file system format
471  //
473  volumeName, ARRAYSIZE(volumeName),
474  &serialNumber, &maxComponent, &flags,
475  fileSystem, ARRAYSIZE(fileSystem)))
476  {
478  PrintWin32Error(szMsg, GetLastError());
479  return -1;
480  }
481 
483  &freeBytesAvailableToCaller,
484  &totalNumberOfBytes,
485  &totalNumberOfFreeBytes))
486  {
488  PrintWin32Error(szMsg, GetLastError());
489  return -1;
490  }
491  ConResPrintf(StdOut, STRING_FILESYSTEM, fileSystem);
492 
493  //
494  // Make sure they want to do this
495  //
496  if (driveType == DRIVE_FIXED)
497  {
498  if (volumeName[0])
499  {
500  while (TRUE)
501  {
504  input[wcslen(input) - 1] = 0;
505 
506  if (!wcsicmp(input, volumeName))
507  break;
508 
510  }
511  }
512 
514 
516  while (TRUE)
517  {
519  if (_wcsnicmp(&input[0], &szMsg[0], 1) == 0) break;
520  if (_wcsnicmp(&input[0], &szMsg[1], 1) == 0)
521  {
522  ConPuts(StdOut, L"\n");
523  return 0;
524  }
525  }
526  }
527 
528  //
529  // Tell the user we're doing a long format if appropriate
530  //
531  if (!QuickFormat)
532  {
534  if (totalNumberOfBytes.QuadPart > 1024*1024*10)
535  {
536  ConPrintf(StdOut, L"%s %luM\n", szMsg, (DWORD)(totalNumberOfBytes.QuadPart/(1024*1024)));
537  }
538  else
539  {
540  ConPrintf(StdOut, L"%s %.1fM\n", szMsg,
541  ((float)(LONGLONG)totalNumberOfBytes.QuadPart)/(float)(1024.0*1024.0));
542  }
543  }
544  else
545  {
547  if (totalNumberOfBytes.QuadPart > 1024*1024*10)
548  {
549  ConPrintf(StdOut, L"%s %luM\n", szMsg, (DWORD)(totalNumberOfBytes.QuadPart/(1024*1024)));
550  }
551  else
552  {
553  ConPrintf(StdOut, L"%s %.2fM\n", szMsg,
554  ((float)(LONGLONG)totalNumberOfBytes.QuadPart)/(float)(1024.0*1024.0));
555  }
557  }
558 
559  //
560  // Format away!
561  //
564  if (Error) return -1;
566 
567  //
568  // Enable compression if desired
569  //
570  if (CompressDrive)
571  {
574  }
575 
576  //
577  // Get the label if we don't have it
578  //
579  if (!GotALabel)
580  {
583 
584  input[wcslen(input) - 1] = 0;
586  {
588  PrintWin32Error(szMsg, GetLastError());
589  return -1;
590  }
591  }
592 
594  volumeName, ARRAYSIZE(volumeName),
595  &serialNumber, &maxComponent, &flags,
596  fileSystem, ARRAYSIZE(fileSystem)))
597  {
599  PrintWin32Error(szMsg, GetLastError());
600  return -1;
601  }
602 
603  //
604  // Print out some stuff including the formatted size
605  //
607  &freeBytesAvailableToCaller,
608  &totalNumberOfBytes,
609  &totalNumberOfFreeBytes))
610  {
612  PrintWin32Error(szMsg, GetLastError());
613  return -1;
614  }
615 
616  ConResPrintf(StdOut, STRING_FREE_SPACE, totalNumberOfBytes.QuadPart,
617  totalNumberOfFreeBytes.QuadPart);
618 
619  //
620  // Get the drive's serial number
621  //
623  volumeName, ARRAYSIZE(volumeName),
624  &serialNumber, &maxComponent, &flags,
625  fileSystem, ARRAYSIZE(fileSystem)))
626  {
628  PrintWin32Error(szMsg, GetLastError());
629  return -1;
630  }
632  (unsigned int)(serialNumber >> 16),
633  (unsigned int)(serialNumber & 0xFFFF));
634 
635  return 0;
636 }
#define STRING_ERROR_LABEL
Definition: resource.h:18
#define STRING_LABEL_NAME_EDIT
Definition: resource.h:17
static int argc
Definition: ServiceArgs.c:12
#define TRUE
Definition: types.h:120
PWCHAR FileSystem
Definition: format.c:72
#define STRING_VERIFYING
Definition: resource.h:21
WCHAR RootDirectory[MAX_PATH]
Definition: format.c:74
#define STRING_FMT_COMPLETE
Definition: resource.h:24
static const BYTE serialNumber[]
Definition: msg.c:2848
BOOL CompressDrive
Definition: format.c:68
WCHAR LabelString[12]
Definition: format.c:75
#define STRING_FAST_FMT
Definition: resource.h:22
#define DRIVE_RAMDISK
Definition: winbase.h:252
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define STRING_NO_SUPPORT
Definition: resource.h:8
#define STRING_ERROR_DRIVE_TYPE
Definition: resource.h:12
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
INT WINAPI K32LoadStringW(IN HINSTANCE hInstance OPTIONAL, IN UINT uID, OUT LPWSTR lpBuffer, IN INT nBufferMax)
Definition: utils.c:173
FILE * stdin
#define STRING_NO_VOLUME
Definition: resource.h:14
#define STRING_FILESYSTEM
Definition: resource.h:16
#define argv
Definition: mplay32.c:18
#define STRING_DRIVE_PARM
Definition: resource.h:11
#define DRIVE_REMOVABLE
Definition: winbase.h:248
UINT WINAPI GetWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2351
PWCHAR Drive
Definition: format.c:71
#define DRIVE_REMOTE
Definition: winbase.h:250
#define ConInitStdStreams()
Definition: stream.h:122
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
INT __cdecl ConPrintf(IN PCON_STREAM Stream, IN LPWSTR szStr,...)
Definition: outstream.c:520
smooth NULL
Definition: ftsmooth.c:416
#define STRING_SERIAL_NUMBER
Definition: resource.h:29
BOOL QuickFormat
Definition: format.c:66
#define DRIVE_UNKNOWN
Definition: winbase.h:253
INT __cdecl ConResPrintf(IN PCON_STREAM Stream, IN UINT uID,...)
Definition: outstream.c:781
int64_t LONGLONG
Definition: typedefs.h:66
__u8 media
Definition: mkdosfs.c:367
#define RC_STRING_MAX_SIZE
Definition: resource.h:3
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL WINAPI SetVolumeLabelW(IN LPCWSTR lpRootPathName, IN LPCWSTR lpVolumeName OPTIONAL)
Definition: volume.c:503
#define STRING_NO_VOLUME_SIZE
Definition: resource.h:15
BOOL GotALabel
Definition: format.c:69
VOID NTAPI FormatEx(IN PWCHAR DriveRoot, IN FMIFS_MEDIA_FLAG MediaFlag, IN PWCHAR Format, IN PWCHAR Label, IN BOOLEAN QuickFormat, IN ULONG ClusterSize, IN PFMIFSCALLBACK Callback)
Definition: format.c:38
#define STRING_INSERT_DISK
Definition: resource.h:13
#define MAX_PATH
Definition: compat.h:26
DWORD ClusterSize
Definition: format.c:67
#define STRING_UNKNOW_ARG
Definition: resource.h:10
unsigned long DWORD
Definition: ntddk_ex.h:95
#define STRING_CREATE_FSYS
Definition: resource.h:23
#define StdErr
Definition: stream.h:77
GLbitfield flags
Definition: glext.h:7161
INT ConResPuts(IN PCON_STREAM Stream, IN UINT uID)
Definition: outstream.c:610
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define STRING_YN_FORMAT
Definition: resource.h:19
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
#define wcsicmp
Definition: string.h:1152
#define DRIVE_NO_ROOT_DIR
Definition: winbase.h:254
#define DRIVE_FIXED
Definition: winbase.h:249
#define STRING_ENTER_LABEL
Definition: resource.h:26
BOOL WINAPI GetVolumeInformationW(IN LPCWSTR lpRootPathName, IN LPWSTR lpVolumeNameBuffer, IN DWORD nVolumeNameSize, OUT LPDWORD lpVolumeSerialNumber OPTIONAL, OUT LPDWORD lpMaximumComponentLength OPTIONAL, OUT LPDWORD lpFileSystemFlags OPTIONAL, OUT LPWSTR lpFileSystemNameBuffer OPTIONAL, IN DWORD nFileSystemNameSize)
Definition: volume.c:226
#define STRING_YES_NO_FAQ
Definition: resource.h:20
BOOLEAN WINAPI FormatExCallback(CALLBACKCOMMAND Command, ULONG Modifier, PVOID Argument)
Definition: format.c:215
GLenum GLenum GLenum input
Definition: glext.h:9031
#define GetModuleHandle
Definition: winbase.h:3641
static int ParseCommandLine(int argc, WCHAR *argv[])
Definition: format.c:133
#define STRING_FMIFS_FAIL
Definition: resource.h:9
Definition: services.c:325
#define DRIVE_CDROM
Definition: winbase.h:251
static VOID PrintWin32Error(LPWSTR Message, DWORD ErrorCode)
Definition: format.c:117
unsigned int UINT
Definition: ndis.h:50
BOOL Error
Definition: format.c:63
INT ConPuts(IN PCON_STREAM Stream, IN LPWSTR szStr)
Definition: outstream.c:427
BOOLEAN NTAPI EnableVolumeCompression(IN PWCHAR DriveRoot, IN USHORT Compression)
Definition: compress.c:17
#define STRING_NO_LABEL
Definition: resource.h:27
#define StdOut
Definition: stream.h:76
wchar_t * fgetws(wchar_t *buf, int bufsize, FILE *file)
Definition: wmain.c:22
#define towlower(c)
Definition: wctype.h:97
static VOID Usage(LPWSTR ProgramName)
Definition: format.c:315
PWCHAR Label
Definition: format.c:70
#define STRING_VOL_COMPRESS
Definition: resource.h:25
#define STRING_FREE_SPACE
Definition: resource.h:28
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
BOOL WINAPI GetDiskFreeSpaceExW(IN LPCWSTR lpDirectoryName OPTIONAL, OUT PULARGE_INTEGER lpFreeBytesAvailableToCaller, OUT PULARGE_INTEGER lpTotalNumberOfBytes, OUT PULARGE_INTEGER lpTotalNumberOfFreeBytes)
Definition: disk.c:342
FMIFS_MEDIA_FLAG
Definition: fmifs.h:37

Variable Documentation

◆ ClusterSize

◆ CompressDrive

BOOL CompressDrive = FALSE

Definition at line 68 of file format.c.

Referenced by ParseCommandLine(), and wmain().

◆ Drive

PWCHAR Drive = NULL

Definition at line 71 of file format.c.

Referenced by ParseCommandLine(), and wmain().

◆ Error

BOOL Error = FALSE

Definition at line 63 of file format.c.

Referenced by FormatExCallback(), and wmain().

◆ FileSystem

◆ GotALabel

BOOL GotALabel = FALSE

Definition at line 69 of file format.c.

Referenced by ParseCommandLine(), and wmain().

◆ Label

◆ LabelString

WCHAR LabelString[12]

Definition at line 75 of file format.c.

Referenced by wmain().

◆ LegalSizes

SIZEDEFINITION LegalSizes[]
Initial value:
= {
{ L"512", 512 },
{ L"1024", 1024 },
{ L"2048", 2048 },
{ L"4096", 4096 },
{ L"8192", 8192 },
{ L"16K", 16384 },
{ L"32K", 32768 },
{ L"64K", 65536 },
{ L"128K", 65536 * 2 },
{ L"256K", 65536 * 4 },
{ L"", 0 },
}
static const WCHAR L[]
Definition: oid.c:1250

Definition at line 95 of file format.c.

Referenced by ParseCommandLine().

◆ QuickFormat

◆ RootDirectory