ReactOS 0.4.15-dev-8434-g155a7c7
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
14static
15BOOL
17 PVOLENTRY VolumeEntry)
18{
19 WCHAR VolumeNameBuffer[MAX_PATH];
24 ULONG ulSize, ulClusterSize = 0;
27 PFILE_FS_ATTRIBUTE_INFORMATION pAttributeInfo = NULL;
30
31 wcscpy(VolumeNameBuffer, VolumeEntry->DeviceName);
32 wcscat(VolumeNameBuffer, L"\\");
33
34 RtlInitUnicodeString(&VolumeName, VolumeNameBuffer);
35
38 0,
39 NULL,
40 NULL);
41
46 0,
48 if (!NT_SUCCESS(Status))
49 {
51 {
53 return FALSE;
54 }
56 {
58 ConPuts(StdOut, L"\n");
61 }
62
63 return TRUE;
64 }
65
66 ulSize = sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 255 * sizeof(WCHAR);
67 pAttributeInfo = RtlAllocateHeap(RtlGetProcessHeap(),
69 ulSize);
70 if (pAttributeInfo == NULL)
71 {
72 Result = FALSE;
73 goto done;
74 }
75
78 pAttributeInfo,
79 ulSize,
81 if (!NT_SUCCESS(Status))
82 {
83 Result = FALSE;
84 goto done;
85 }
86
89 &FullSizeInfo,
92 if (NT_SUCCESS(Status))
93 {
94 ulClusterSize = FullSizeInfo.BytesPerSector * FullSizeInfo.SectorsPerAllocationUnit;
95 }
96 else
97 {
100 &SizeInfo,
103 if (NT_SUCCESS(Status))
104 {
105 ulClusterSize = SizeInfo.BytesPerSector * SizeInfo.SectorsPerAllocationUnit;
106 }
107 }
108
109
111 ConPuts(StdOut, L"\n");
112
115 ConPuts(StdOut, L"\n");
116
117done:
118 if (pAttributeInfo)
119 RtlFreeHeap(RtlGetProcessHeap(), 0, pAttributeInfo);
120
122
123 return Result;
124}
125
126static
127VOID
129{
130 WCHAR szBuffer[256];
131 BOOLEAN ret;
132 DWORD dwIndex;
133 UCHAR uMajor, uMinor;
134 BOOLEAN bLatest;
135
137
138 for (dwIndex = 0; ; dwIndex++)
139 {
141 szBuffer,
142 &uMajor,
143 &uMinor,
144 &bLatest);
145 if (ret == FALSE)
146 break;
147
148 ConPrintf(StdOut, L" %s\n", szBuffer);
149 }
150
151 ConPuts(StdOut, L"\n");
152}
153
154BOOL
156 _In_ INT argc,
157 _In_ PWSTR *argv)
158{
159 if (CurrentVolume == NULL)
160 {
162 return TRUE;
163 }
164
165 ConPuts(StdOut, L"\n");
166
168 {
170 }
171
172 return TRUE;
173}
unsigned char BOOLEAN
static int argc
Definition: ServiceArgs.c:12
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
void ConPrintf(FILE *fp, LPCWSTR psz,...)
Definition: fc.c:20
#define StdOut
Definition: fc.c:14
void ConResPrintf(FILE *fp, UINT nID,...)
Definition: fc.c:33
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_DIRECTORY_FILE
Definition: constants.h:491
#define IDS_SELECT_NO_VOLUME
Definition: resource.h:92
#define IDS_FILESYSTEMS_FORMATTING
Definition: resource.h:60
#define IDS_FILESYSTEMS_CURRENT
Definition: resource.h:59
#define IDS_ERROR_NO_MEDIUM
Definition: resource.h:188
#define IDS_FILESYSTEMS_CLUSTERSIZE
Definition: resource.h:62
#define IDS_FILESYSTEMS_TYPE
Definition: resource.h:61
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
PVOLENTRY CurrentVolume
Definition: partlist.c:76
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define MAX_PATH
Definition: compat.h:34
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
BOOLEAN NTAPI QueryAvailableFileSystemFormat(IN DWORD Index, IN OUT PWCHAR FileSystem, OUT UCHAR *Major, OUT UCHAR *Minor, OUT BOOLEAN *LatestVersion)
Definition: query.c:14
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL filesystems_main(_In_ INT argc, _In_ PWSTR *argv)
Definition: filesystems.c:155
static VOID ShowInstalledFileSystems(VOID)
Definition: filesystems.c:128
static BOOL ShowFileSystemInfo(PVOLENTRY VolumeEntry)
Definition: filesystems.c:16
_Must_inspect_result_ _Inout_opt_ PUNICODE_STRING VolumeName
Definition: fltkernel.h:1117
_Must_inspect_result_ _Out_ PHANDLE VolumeHandle
Definition: fltkernel.h:2283
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
struct _FILE_FS_ATTRIBUTE_INFORMATION FILE_FS_ATTRIBUTE_INFORMATION
@ FileFsAttributeInformation
Definition: from_kernel.h:223
@ FileFsSizeInformation
Definition: from_kernel.h:221
#define FILE_OPEN_FOR_BACKUP_INTENT
Definition: from_kernel.h:42
Status
Definition: gdiplustypes.h:25
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define argv
Definition: mplay32.c:18
#define _In_
Definition: ms_sal.h:308
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:3952
#define SYNCHRONIZE
Definition: nt_native.h:61
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define FileFsFullSizeInformation
Definition: ntifs_ex.h:389
#define L(x)
Definition: ntvdm.h:50
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
NTSTATUS NTAPI NtQueryVolumeInformationFile(HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, PVOID FsInformation, ULONG Length, FS_INFORMATION_CLASS FsInformationClass)
WCHAR DeviceName[MAX_PATH]
Definition: diskpart.h:195
uint16_t * PWSTR
Definition: typedefs.h:56
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_UNRECOGNIZED_VOLUME
Definition: udferr_usr.h:173
#define STATUS_NO_MEDIA_IN_DEVICE
Definition: udferr_usr.h:141
int ret
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
unsigned char UCHAR
Definition: xmlstorage.h:181
__wchar_t WCHAR
Definition: xmlstorage.h:180