ReactOS 0.4.16-dev-2206-gc56950d
assign.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/assign.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
18{
19 PWSTR pszSuffix = NULL;
20 WCHAR DriveLetter = UNICODE_NULL;
21 INT i, nExclusive = 0;
22 BOOL bResult;
23
24 DPRINT1("assign_main()\n");
25
26 if (CurrentVolume == NULL)
27 {
29 return EXIT_SUCCESS;
30 }
31
32 for (i = 1; i < argc; i++)
33 {
34 if (_wcsicmp(argv[i], L"noerr") == 0)
35 {
36 /* noerr */
37 DPRINT("NoErr\n", pszSuffix);
38 ConPuts(StdOut, L"The NOERR option is not supported yet!\n");
39#if 0
40 bNoErr = TRUE;
41#endif
42 }
43 }
44
45 for (i = 1; i < argc; i++)
46 {
47 if (HasPrefix(argv[i], L"letter=", &pszSuffix))
48 {
49 if (wcslen(pszSuffix) == 1)
50 {
51 DriveLetter = towupper(*pszSuffix);
52 nExclusive++;
53 }
54 else
55 {
57 return EXIT_SUCCESS;
58 }
59 }
60 else if (HasPrefix(argv[i], L"mount=", &pszSuffix))
61 {
62 DPRINT("Mount\n", pszSuffix);
63 ConPuts(StdOut, L"The MOUNT option is not supported yet!\n");
64 nExclusive++;
65 }
66 else if (_wcsicmp(argv[i], L"noerr") == 0)
67 {
68 /* noerr - Already handled above */
69 }
70 else
71 {
73 return EXIT_SUCCESS;
74 }
75 }
76
78 {
80 return EXIT_SUCCESS;
81 }
82
83 if (nExclusive > 1)
84 {
86 return EXIT_SUCCESS;
87 }
88
89 DPRINT1("VolumeName: %S\n", CurrentVolume->VolumeName);
90 DPRINT1("DeviceName: %S\n", CurrentVolume->DeviceName);
91 DPRINT1("DriveLetter: %C\n", CurrentVolume->DriveLetter);
92
93 if (DriveLetter != UNICODE_NULL)
94 {
95 DPRINT1("DriveLetter: %C\n", DriveLetter);
96
97 if ((DriveLetter < L'C') || (DriveLetter > L'Z'))
98 {
100 return EXIT_SUCCESS;
101 }
102
103 if (DriveLetter == CurrentVolume->DriveLetter)
104 {
106 return EXIT_SUCCESS;
107 }
108 }
109
111 {
112 /* Remove the current drive letter */
114 if (bResult == FALSE)
115 {
117 return EXIT_SUCCESS;
118 }
119
121 }
122
123 if (DriveLetter != UNICODE_NULL)
124 {
125 /* Assign the new drive letter */
127 DriveLetter);
128 if (bResult == FALSE)
129 {
131 return EXIT_SUCCESS;
132 }
133
134 CurrentVolume->DriveLetter = DriveLetter;
135 }
136 else
137 {
140 if (bResult == FALSE)
141 {
143 return EXIT_SUCCESS;
144 }
145
147 {
149 return EXIT_SUCCESS;
150 }
151 }
152
154
155 return EXIT_SUCCESS;
156}
static int argc
Definition: ServiceArgs.c:12
EXIT_CODE assign_main(_In_ INT argc, _In_ LPWSTR *argv)
Definition: assign.c:15
void ConPuts(FILE *fp, LPCWSTR psz)
Definition: fc.c:16
#define StdOut
Definition: fc.c:14
#define StdErr
Definition: fc.c:15
void ConResPuts(FILE *fp, UINT nID)
Definition: fc.c:27
#define DPRINT1
Definition: precomp.h:8
#define IDS_SELECT_NO_VOLUME
Definition: resource.h:132
#define IDS_ASSIGN_FAIL
Definition: resource.h:30
#define IDS_ASSIGN_INVALID_LETTER
Definition: resource.h:33
#define IDS_ASSIGN_NO_MORE_LETTER
Definition: resource.h:34
#define IDS_ERROR_INVALID_ARGS
Definition: resource.h:233
#define IDS_REMOVE_SUCCESS
Definition: resource.h:116
#define IDS_ASSIGN_ALREADY_ASSIGNED
Definition: resource.h:32
#define IDS_ASSIGN_SYSTEM_VOLUME
Definition: resource.h:35
BOOL HasPrefix(_In_ PWSTR pszString, _In_ PWSTR pszPrefix, _Out_opt_ PWSTR *pszSuffix)
Definition: misc.c:58
enum _EXIT_CODE EXIT_CODE
BOOL DeleteDriveLetter(_In_ WCHAR DriveLetter)
Definition: mountmgr.c:338
PVOLENTRY CurrentVolume
Definition: partlist.c:77
BOOL AssignNextDriveLetter(_In_ PWSTR DeviceName, _Out_ PWCHAR DriveLetter)
Definition: mountmgr.c:261
BOOL AssignDriveLetter(_In_ PWSTR DeviceName, _In_ WCHAR DriveLetter)
Definition: mountmgr.c:181
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:159
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2983
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
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
#define argv
Definition: mplay32.c:18
#define _In_
Definition: no_sal2.h:158
#define UNICODE_NULL
#define EXIT_SUCCESS
Definition: rdjpgcom.c:55
#define towupper(c)
Definition: wctype.h:99
#define DPRINT
Definition: sndvol32.h:73
BOOL IsBoot
Definition: diskpart.h:260
BOOL IsSystem
Definition: diskpart.h:259
WCHAR VolumeName[MAX_PATH]
Definition: diskpart.h:243
WCHAR DeviceName[MAX_PATH]
Definition: diskpart.h:244
WCHAR DriveLetter
Definition: diskpart.h:247
uint16_t * PWSTR
Definition: typedefs.h:56
int32_t INT
Definition: typedefs.h:58
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184