ReactOS
0.4.16-dev-297-gc569aee
Toggle main menu visibility
Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
Functions
_
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
u
v
w
Variables
_
c
d
e
f
g
h
i
l
n
o
p
s
t
u
x
Typedefs
_
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
u
v
w
x
Enumerations
_
c
d
f
i
l
m
o
p
s
t
w
x
Enumerator
a
b
c
d
e
f
g
h
i
m
n
o
p
r
s
t
u
v
w
x
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
_
a
b
c
d
e
f
h
i
k
l
m
n
o
p
r
s
t
u
v
w
z
Enumerator
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Properties
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Related Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
v
x
Files
File List
File Members
All
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Examples
select.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/select.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
/* FUNCTIONS ******************************************************************/
15
16
BOOL
17
SelectDisk
(
18
INT
argc
,
19
PWSTR
*
argv
)
20
{
21
PLIST_ENTRY
Entry
;
22
PDISKENTRY
DiskEntry;
23
ULONG
ulValue;
24
25
DPRINT
(
"Select Disk()\n"
);
26
27
if
(
argc
> 3)
28
{
29
ConResPuts
(
StdErr
,
IDS_ERROR_INVALID_ARGS
);
30
return
TRUE
;
31
}
32
33
if
(
argc
== 2)
34
{
35
if
(
CurrentDisk
==
NULL
)
36
ConResPuts
(
StdOut
,
IDS_SELECT_NO_DISK
);
37
else
38
ConResPrintf
(
StdOut
,
IDS_SELECT_DISK
,
CurrentDisk
->
DiskNumber
);
39
return
TRUE
;
40
}
41
42
if
(!
IsDecString
(
argv
[2]))
43
{
44
ConResPuts
(
StdErr
,
IDS_ERROR_INVALID_ARGS
);
45
return
TRUE
;
46
}
47
48
ulValue =
wcstoul
(
argv
[2],
NULL
, 10);
49
if
((ulValue == 0) && (
errno
==
ERANGE
))
50
{
51
ConResPuts
(
StdErr
,
IDS_ERROR_INVALID_ARGS
);
52
return
TRUE
;
53
}
54
55
CurrentDisk
=
NULL
;
56
57
Entry
=
DiskListHead
.
Flink
;
58
while
(
Entry
!= &
DiskListHead
)
59
{
60
DiskEntry =
CONTAINING_RECORD
(
Entry
,
DISKENTRY
, ListEntry);
61
62
if
(DiskEntry->
DiskNumber
== ulValue)
63
{
64
CurrentDisk
= DiskEntry;
65
CurrentPartition
=
NULL
;
66
ConResPrintf
(
StdOut
,
IDS_SELECT_DISK
,
CurrentDisk
->
DiskNumber
);
67
return
TRUE
;
68
}
69
70
Entry
=
Entry
->Flink;
71
}
72
73
ConResPuts
(
StdErr
,
IDS_SELECT_DISK_INVALID
);
74
return
TRUE
;
75
}
76
77
78
BOOL
79
SelectPartition
(
80
INT
argc
,
81
PWSTR
*
argv
)
82
{
83
PLIST_ENTRY
Entry
;
84
PPARTENTRY
PartEntry;
85
ULONG
ulValue;
86
ULONG
PartNumber = 1;
87
88
DPRINT
(
"Select Partition()\n"
);
89
90
if
(
argc
> 3)
91
{
92
ConResPuts
(
StdErr
,
IDS_ERROR_INVALID_ARGS
);
93
return
TRUE
;
94
}
95
96
if
(
CurrentDisk
==
NULL
)
97
{
98
ConResPuts
(
StdOut
,
IDS_SELECT_PARTITION_NO_DISK
);
99
return
TRUE
;
100
}
101
102
if
(
argc
== 2)
103
{
104
if
(
CurrentPartition
==
NULL
)
105
ConResPuts
(
StdOut
,
IDS_SELECT_NO_PARTITION
);
106
else
107
ConResPrintf
(
StdOut
,
IDS_SELECT_PARTITION
,
CurrentPartition
);
108
return
TRUE
;
109
}
110
111
if
(!
IsDecString
(
argv
[2]))
112
{
113
ConResPuts
(
StdErr
,
IDS_ERROR_INVALID_ARGS
);
114
return
TRUE
;
115
}
116
117
ulValue =
wcstoul
(
argv
[2],
NULL
, 10);
118
if
((ulValue == 0) && (
errno
==
ERANGE
))
119
{
120
ConResPuts
(
StdErr
,
IDS_ERROR_INVALID_ARGS
);
121
return
TRUE
;
122
}
123
124
Entry
=
CurrentDisk
->
PrimaryPartListHead
.
Flink
;
125
while
(
Entry
!= &
CurrentDisk
->
PrimaryPartListHead
)
126
{
127
PartEntry =
CONTAINING_RECORD
(
Entry
,
PARTENTRY
, ListEntry);
128
129
if
(PartEntry->
PartitionType
!= 0)
130
{
131
if
(PartNumber == ulValue)
132
{
133
CurrentPartition
= PartEntry;
134
ConResPrintf
(
StdOut
,
IDS_SELECT_PARTITION
, PartNumber);
135
return
TRUE
;
136
}
137
138
PartNumber++;
139
}
140
141
Entry
=
Entry
->Flink;
142
}
143
144
Entry
=
CurrentDisk
->
LogicalPartListHead
.
Flink
;
145
while
(
Entry
!= &
CurrentDisk
->
LogicalPartListHead
)
146
{
147
PartEntry =
CONTAINING_RECORD
(
Entry
,
PARTENTRY
, ListEntry);
148
149
if
(PartEntry->
PartitionType
!= 0)
150
{
151
if
(PartNumber == ulValue)
152
{
153
CurrentPartition
= PartEntry;
154
ConResPrintf
(
StdOut
,
IDS_SELECT_PARTITION
, PartNumber);
155
return
TRUE
;
156
}
157
158
PartNumber++;
159
}
160
Entry
=
Entry
->Flink;
161
}
162
163
ConResPuts
(
StdErr
,
IDS_SELECT_PARTITION_INVALID
);
164
return
TRUE
;
165
}
166
167
168
BOOL
169
SelectVolume
(
170
INT
argc
,
171
PWSTR
*
argv
)
172
{
173
PLIST_ENTRY
Entry
;
174
PVOLENTRY
VolumeEntry;
175
ULONG
ulValue;
176
177
DPRINT
(
"SelectVolume()\n"
);
178
179
if
(
argc
> 3)
180
{
181
ConResPuts
(
StdErr
,
IDS_ERROR_INVALID_ARGS
);
182
return
TRUE
;
183
}
184
185
if
(
argc
== 2)
186
{
187
if
(
CurrentDisk
==
NULL
)
188
ConResPuts
(
StdOut
,
IDS_SELECT_NO_VOLUME
);
189
else
190
ConResPrintf
(
StdOut
,
IDS_SELECT_VOLUME
,
CurrentVolume
->
VolumeNumber
);
191
return
TRUE
;
192
}
193
194
if
(!
IsDecString
(
argv
[2]))
195
{
196
ConResPuts
(
StdErr
,
IDS_ERROR_INVALID_ARGS
);
197
return
TRUE
;
198
}
199
200
ulValue =
wcstoul
(
argv
[2],
NULL
, 10);
201
if
((ulValue == 0) && (
errno
==
ERANGE
))
202
{
203
ConResPuts
(
StdErr
,
IDS_ERROR_INVALID_ARGS
);
204
return
TRUE
;
205
}
206
207
CurrentVolume
=
NULL
;
208
209
Entry
=
VolumeListHead
.
Flink
;
210
while
(
Entry
!= &
VolumeListHead
)
211
{
212
VolumeEntry =
CONTAINING_RECORD
(
Entry
,
VOLENTRY
, ListEntry);
213
214
if
(VolumeEntry->
VolumeNumber
== ulValue)
215
{
216
CurrentVolume
= VolumeEntry;
217
ConResPrintf
(
StdOut
,
IDS_SELECT_VOLUME
,
CurrentVolume
->
VolumeNumber
);
218
return
TRUE
;
219
}
220
221
Entry
=
Entry
->Flink;
222
}
223
224
ConResPuts
(
StdErr
,
IDS_SELECT_VOLUME_INVALID
);
225
return
TRUE
;
226
}
argc
static int argc
Definition:
ServiceArgs.c:12
ERANGE
#define ERANGE
Definition:
acclib.h:92
StdOut
#define StdOut
Definition:
fc.c:14
ConResPrintf
void ConResPrintf(FILE *fp, UINT nID,...)
Definition:
fc.c:33
StdErr
#define StdErr
Definition:
fc.c:15
ConResPuts
void ConResPuts(FILE *fp, UINT nID)
Definition:
fc.c:27
IDS_SELECT_DISK_INVALID
#define IDS_SELECT_DISK_INVALID
Definition:
resource.h:87
IDS_SELECT_NO_VOLUME
#define IDS_SELECT_NO_VOLUME
Definition:
resource.h:92
IDS_SELECT_NO_PARTITION
#define IDS_SELECT_NO_PARTITION
Definition:
resource.h:88
IDS_ERROR_INVALID_ARGS
#define IDS_ERROR_INVALID_ARGS
Definition:
resource.h:187
IDS_SELECT_DISK
#define IDS_SELECT_DISK
Definition:
resource.h:86
IDS_SELECT_PARTITION_NO_DISK
#define IDS_SELECT_PARTITION_NO_DISK
Definition:
resource.h:90
IDS_SELECT_VOLUME
#define IDS_SELECT_VOLUME
Definition:
resource.h:93
IDS_SELECT_NO_DISK
#define IDS_SELECT_NO_DISK
Definition:
resource.h:85
IDS_SELECT_PARTITION_INVALID
#define IDS_SELECT_PARTITION_INVALID
Definition:
resource.h:91
IDS_SELECT_PARTITION
#define IDS_SELECT_PARTITION
Definition:
resource.h:89
IDS_SELECT_VOLUME_INVALID
#define IDS_SELECT_VOLUME_INVALID
Definition:
resource.h:94
SelectDisk
BOOL SelectDisk(INT argc, PWSTR *argv)
Definition:
select.c:17
SelectPartition
BOOL SelectPartition(INT argc, PWSTR *argv)
Definition:
select.c:79
SelectVolume
BOOL SelectVolume(INT argc, PWSTR *argv)
Definition:
select.c:169
diskpart.h
VolumeListHead
LIST_ENTRY VolumeListHead
Definition:
partlist.c:72
CurrentDisk
PDISKENTRY CurrentDisk
Definition:
partlist.c:74
DiskListHead
LIST_ENTRY DiskListHead
Definition:
partlist.c:70
CurrentVolume
PVOLENTRY CurrentVolume
Definition:
partlist.c:76
IsDecString
BOOL IsDecString(_In_ PWSTR pszDecString)
Definition:
misc.c:14
NULL
#define NULL
Definition:
types.h:112
TRUE
#define TRUE
Definition:
types.h:120
BOOL
unsigned int BOOL
Definition:
ntddk_ex.h:94
wcstoul
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
argv
#define argv
Definition:
mplay32.c:18
errno
#define errno
Definition:
errno.h:18
DPRINT
#define DPRINT
Definition:
sndvol32.h:73
Entry
base of all file and directory entries
Definition:
entries.h:83
_DISKENTRY
Definition:
partlist.h:100
_DISKENTRY::LogicalPartListHead
LIST_ENTRY LogicalPartListHead
Definition:
partlist.h:150
_DISKENTRY::DiskNumber
ULONG DiskNumber
Definition:
partlist.h:129
_DISKENTRY::PrimaryPartListHead
LIST_ENTRY PrimaryPartListHead
Definition:
partlist.h:149
_LIST_ENTRY
Definition:
typedefs.h:120
_LIST_ENTRY::Flink
struct _LIST_ENTRY * Flink
Definition:
typedefs.h:121
_PARTENTRY
Definition:
partlist.h:62
_PARTENTRY::PartitionType
UCHAR PartitionType
Definition:
partlist.h:73
_VOLENTRY
Definition:
partlist.h:44
_VOLENTRY::VolumeNumber
ULONG VolumeNumber
Definition:
diskpart.h:193
PWSTR
uint16_t * PWSTR
Definition:
typedefs.h:56
INT
int32_t INT
Definition:
typedefs.h:58
CONTAINING_RECORD
#define CONTAINING_RECORD(address, type, field)
Definition:
typedefs.h:260
ULONG
uint32_t ULONG
Definition:
typedefs.h:59
CurrentPartition
static PPARTENTRY CurrentPartition
Definition:
usetup.c:78
base
system
diskpart
select.c
Generated on Tue Nov 26 2024 06:04:18 for ReactOS by
1.9.6