ReactOS  0.4.13-dev-455-g28ed234
fsutil.h File Reference
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
Include dependency graph for fsutil.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  HandlerItem
 

Typedefs

typedef int() HandlerProc(int argc, const TCHAR *argv[])
 
typedef HandlerProcpHandlerProc
 

Functions

int FindHandler (int argc, const TCHAR *argv[], HandlerItem *HandlersList, int HandlerListCount, void(*UsageHelper)(const TCHAR *))
 
HANDLE OpenVolume (const TCHAR *Volume, BOOLEAN AllowRemote, BOOLEAN NtfsOnly)
 
void PrintDefaultUsage (const TCHAR *Command, const TCHAR *SubCommand, HandlerItem *HandlersList, int HandlerListCount)
 
int PrintErrorMessage (DWORD Error)
 

Typedef Documentation

◆ HandlerProc

typedef int() HandlerProc(int argc, const TCHAR *argv[])

Definition at line 8 of file fsutil.h.

◆ pHandlerProc

Definition at line 9 of file fsutil.h.

Function Documentation

◆ FindHandler()

int FindHandler ( int  argc,
const TCHAR argv[],
HandlerItem HandlersList,
int  HandlerListCount,
void(*)(const TCHAR *)  UsageHelper 
)

Definition at line 11 of file common.c.

16 {
17  int i;
18  int ret;
19  const TCHAR * Command;
20 
21  ret = 1;
22  Command = NULL;
23  i = HandlerListCount;
24 
25  /* If we have a command, does it match a known one? */
26  if (argc > 1)
27  {
28  /* Browse all the known commands finding the right one */
29  Command = argv[1];
30  for (i = 0; i < HandlerListCount; ++i)
31  {
33  {
34  ret = HandlersList[i].Handler(argc - 1, &argv[1]);
35  break;
36  }
37  }
38  }
39 
40  /* We failed finding someone to handle the caller's needs, print out */
41  if (i == HandlerListCount)
42  {
43  UsageHelper(Command);
44  }
45 
46  return ret;
47 }
static int argc
Definition: ServiceArgs.c:12
#define _tcsicmp
Definition: xmlstorage.h:205
Definition: shell.h:41
#define argv
Definition: mplay32.c:18
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 i
Definition: glfuncs.h:248
static HandlerItem HandlersList[]
Definition: dirty.c:15
smooth NULL
Definition: ftsmooth.c:416
char TCHAR
Definition: xmlstorage.h:189
struct Command Command
int ret
pHandlerProc Handler
Definition: fsutil.h:13

Referenced by _tmain(), DirtyMain(), FsInfoMain(), HardLinkMain(), and VolumeMain().

◆ OpenVolume()

HANDLE OpenVolume ( const TCHAR Volume,
BOOLEAN  AllowRemote,
BOOLEAN  NtfsOnly 
)

Definition at line 49 of file common.c.

52 {
53  UINT Type;
54  HANDLE hVolume;
55  TCHAR VolumeID[PATH_MAX];
56 
57  /* Get volume type */
58  if (!AllowRemote && Volume[1] == L':')
59  {
61  if (Type == DRIVE_REMOTE)
62  {
63  _ftprintf(stderr, _T("FSUTIL needs a local device\n"));
64  return INVALID_HANDLE_VALUE;
65  }
66  }
67 
68  /* Get filesystem type */
69  if (NtfsOnly)
70  {
72 
73  _stprintf(VolumeID, _T("\\\\.\\%s\\"), Volume);
74  if (!GetVolumeInformation(VolumeID, NULL, 0, NULL, NULL, NULL, FileSystem, MAX_PATH + 1))
75  {
77  return INVALID_HANDLE_VALUE;
78  }
79 
80  if (_tcscmp(FileSystem, _T("NTFS")) != 0)
81  {
82  _ftprintf(stderr, _T("FSUTIL needs a NTFS device\n"));
83  return INVALID_HANDLE_VALUE;
84  }
85  }
86 
87  /* Create full name */
88  _stprintf(VolumeID, _T("\\\\.\\%s"), Volume);
89 
90  /* Open the volume */
93  if (hVolume == INVALID_HANDLE_VALUE)
94  {
96  return INVALID_HANDLE_VALUE;
97  }
98 
99  return hVolume;
100 }
PWCHAR FileSystem
Definition: format.c:72
Type
Definition: Type.h:6
int _tcscmp(const _TCHAR *s1, const _TCHAR *s2)
Definition: tcscmp.h:8
#define GetDriveType
Definition: winbase.h:3626
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
int PrintErrorMessage(DWORD Error)
Definition: common.c:123
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:125
#define DRIVE_REMOTE
Definition: winbase.h:250
smooth NULL
Definition: ftsmooth.c:416
#define _ftprintf
Definition: tchar.h:518
#define OPEN_EXISTING
Definition: compat.h:426
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
#define MAX_PATH
Definition: compat.h:26
#define PATH_MAX
Definition: types.h:280
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
static const WCHAR L[]
Definition: oid.c:1250
#define GENERIC_READ
Definition: compat.h:124
#define _stprintf
Definition: utility.h:124
#define GetVolumeInformation
Definition: winbase.h:3667
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:904
unsigned int UINT
Definition: ndis.h:50
FILE * stderr

Referenced by main(), NtfsInfoMain(), QueryMain(), SetMain(), and StatisticsMain().

◆ PrintDefaultUsage()

void PrintDefaultUsage ( const TCHAR Command,
const TCHAR SubCommand,
HandlerItem HandlersList,
int  HandlerListCount 
)

Definition at line 102 of file common.c.

106 {
107  int i;
108 
109  /* If we were given a command, print it's not supported */
110  if (SubCommand != NULL)
111  {
112  _ftprintf(stderr, _T("Unhandled%scommand: %s\n"), Command, SubCommand);
113  }
114 
115  /* And dump any available command */
116  _ftprintf(stderr, _T("---- Handled%scommands ----\n\n"), Command);
117  for (i = 0; i < HandlerListCount; ++i)
118  {
119  _ftprintf(stderr, _T("%s\t%s\n"), HandlersList[i].Command, HandlersList[i].Desc);
120  }
121 }
Definition: shell.h:41
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 i
Definition: glfuncs.h:248
static HandlerItem HandlersList[]
Definition: dirty.c:15
smooth NULL
Definition: ftsmooth.c:416
#define _ftprintf
Definition: tchar.h:518
#define _T(x)
Definition: vfdio.h:22
FILE * stderr

Referenced by PrintUsage().

◆ PrintErrorMessage()

int PrintErrorMessage ( DWORD  Error)

Definition at line 123 of file common.c.

124 {
125  TCHAR * String;
126 
127  /* Try to get textual error */
129  NULL, Error, 0, (TCHAR *)&String, 0, NULL) != 0)
130  {
131  /* And print it */
132  _ftprintf(stderr, _T("Error: %s\n"), String);
133  LocalFree(String);
134  }
135  else
136  {
137  /* Otherwise, just print the error number */
138  _ftprintf(stderr, _T("Error: %d\n"), Error);
139  }
140 
141  return Error;
142 }
static WCHAR String[]
Definition: stringtable.c:55
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:400
smooth NULL
Definition: ftsmooth.c:416
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:404
#define _ftprintf
Definition: tchar.h:518
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
BOOL Error
Definition: chkdsk.c:66
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
FILE * stderr