ReactOS  0.4.15-dev-5461-g062a8f2
filesystems.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS DiskPart
3  * LICENSE: GPL - See COPYING in the top level directory
4  * FILE: base/system/diskpart/filesystems.c
5  * PURPOSE: Manages all the partitions of the OS in an interactive way.
6  * PROGRAMMERS: Lee Schroeder
7  */
8 
9 #include "diskpart.h"
10 
11 #define NDEBUG
12 #include <debug.h>
13 
14 static
15 BOOL
17  PVOLENTRY VolumeEntry)
18 {
19  WCHAR VolumeNameBuffer[MAX_PATH];
24  ULONG ulSize, ulClusterSize = 0;
26  FILE_FS_FULL_SIZE_INFORMATION FullSizeInfo;
27  PFILE_FS_ATTRIBUTE_INFORMATION pAttributeInfo = NULL;
29 
30  wcscpy(VolumeNameBuffer, VolumeEntry->DeviceName);
31  wcscat(VolumeNameBuffer, L"\\");
32 
33  RtlInitUnicodeString(&VolumeName, VolumeNameBuffer);
34 
36  &VolumeName,
37  0,
38  NULL,
39  NULL);
40 
45  0,
47  if (!NT_SUCCESS(Status))
48  {
50  {
52  return FALSE;
53  }
55  {
57  ConPuts(StdOut, L"\n");
60  }
61 
62  return TRUE;
63  }
64 
65  ulSize = sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 255 * sizeof(WCHAR);
66  pAttributeInfo = RtlAllocateHeap(RtlGetProcessHeap(),
68  ulSize);
69 
72  pAttributeInfo,
73  ulSize,
75 
78  &FullSizeInfo,
81  if (NT_SUCCESS(Status))
82  {
83  ulClusterSize = FullSizeInfo.BytesPerSector * FullSizeInfo.SectorsPerAllocationUnit;
84  }
85  else
86  {
89  &SizeInfo,
92  if (NT_SUCCESS(Status))
93  {
94  ulClusterSize = SizeInfo.BytesPerSector * SizeInfo.SectorsPerAllocationUnit;
95  }
96  }
97 
98 
100  ConPuts(StdOut, L"\n");
101 
104 
105  if (pAttributeInfo)
106  RtlFreeHeap(RtlGetProcessHeap(), 0, pAttributeInfo);
107 
109 
110  return TRUE;
111 }
112 
113 BOOL
115  _In_ INT argc,
116  _In_ PWSTR *argv)
117 {
118  if (CurrentVolume == NULL)
119  {
121  return TRUE;
122  }
123 
124  ConPuts(StdOut, L"\n");
125 
127  {
128  ConPuts(StdOut, L"\n");
130 
131  /* FIXME: List available file systems */
132 
133  }
134 
135  ConPuts(StdOut, L"\n");
136 
137  return TRUE;
138 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
static int argc
Definition: ServiceArgs.c:12
#define STATUS_NO_MEDIA_IN_DEVICE
Definition: udferr_usr.h:141
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:56
#define FILE_DIRECTORY_FILE
Definition: constants.h:491
#define FileFsFullSizeInformation
Definition: ntifs_ex.h:389
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
#define IDS_FILESYSTEMS_CLUSTERSIZE
Definition: resource.h:62
#define IDS_FILESYSTEMS_FORMATTING
Definition: resource.h:60
#define argv
Definition: mplay32.c:18
struct _FILE_FS_ATTRIBUTE_INFORMATION FILE_FS_ATTRIBUTE_INFORMATION
#define IDS_FILESYSTEMS_TYPE
Definition: resource.h:61
#define IDS_SELECT_NO_VOLUME
Definition: resource.h:92
int32_t INT
Definition: typedefs.h:58
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define L(x)
Definition: ntvdm.h:50
#define IDS_FILESYSTEMS_CURRENT
Definition: resource.h:59
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define STATUS_UNRECOGNIZED_VOLUME
Definition: udferr_usr.h:173
static BOOL GetFileSystemInfo(PVOLENTRY VolumeEntry)
Definition: filesystems.c:16
#define _In_
Definition: ms_sal.h:308
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
WCHAR DeviceName[MAX_PATH]
Definition: diskpart.h:193
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
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
void ConResPrintf(FILE *fp, UINT nID,...)
Definition: fc.c:33
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define MAX_PATH
Definition: compat.h:34
_Must_inspect_result_ _Out_ PHANDLE VolumeHandle
Definition: fltkernel.h:2283
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
BOOL filesystems_main(_In_ INT argc, _In_ PWSTR *argv)
Definition: filesystems.c:114
#define SYNCHRONIZE
Definition: nt_native.h:61
NTSTATUS NTAPI NtQueryVolumeInformationFile(HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, PVOID FsInformation, ULONG Length, FS_INFORMATION_CLASS FsInformationClass)
#define FILE_OPEN_FOR_BACKUP_INTENT
Definition: from_kernel.h:42
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
_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 NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
_Must_inspect_result_ _Inout_opt_ PUNICODE_STRING VolumeName
Definition: fltkernel.h:1117
#define StdOut
Definition: fc.c:14
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define IDS_ERROR_NO_MEDIUM
Definition: resource.h:188
PVOLENTRY CurrentVolume
Definition: partlist.c:76