ReactOS 0.4.16-dev-2104-gb84fa49
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
77 if (nExclusive > 1)
78 {
80 return EXIT_SUCCESS;
81 }
82
83 DPRINT1("VolumeName: %S\n", CurrentVolume->VolumeName);
84 DPRINT1("DeviceName: %S\n", CurrentVolume->DeviceName);
85 DPRINT1("DriveLetter: %C\n", CurrentVolume->DriveLetter);
86
87 if (DriveLetter != UNICODE_NULL)
88 {
89 DPRINT1("DriveLetter: %C\n", DriveLetter);
90
91 if ((DriveLetter < L'C') || (DriveLetter > L'Z'))
92 {
94 return EXIT_SUCCESS;
95 }
96
97 if (DriveLetter == CurrentVolume->DriveLetter)
98 {
100 return EXIT_SUCCESS;
101 }
102 }
103
105 {
106 /* Remove the current drive letter */
108 if (bResult == FALSE)
109 {
111 return EXIT_SUCCESS;
112 }
113
115 }
116
117 if (DriveLetter != UNICODE_NULL)
118 {
119 /* Assign the new drive letter */
121 DriveLetter);
122 if (bResult == FALSE)
123 {
125 return EXIT_SUCCESS;
126 }
127
128 CurrentVolume->DriveLetter = DriveLetter;
129 }
130 else
131 {
134 if (bResult == FALSE)
135 {
137 return EXIT_SUCCESS;
138 }
139
141 {
143 return EXIT_SUCCESS;
144 }
145 }
146
148
149 return EXIT_SUCCESS;
150}
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:130
#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:229
#define IDS_REMOVE_SUCCESS
Definition: resource.h:114
#define IDS_ASSIGN_ALREADY_ASSIGNED
Definition: resource.h:32
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
WCHAR VolumeName[MAX_PATH]
Definition: diskpart.h:237
WCHAR DeviceName[MAX_PATH]
Definition: diskpart.h:238
WCHAR DriveLetter
Definition: diskpart.h:241
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