Author: jmorlan
Date: Mon Aug 4 09:16:01 2008
New Revision: 35098
URL:
http://svn.reactos.org/svn/reactos?rev=35098&view=rev
Log:
- cmd_label: If a label is given on the command line, don't truncate it to only 12
characters; NTFS supports up to 32. Also, use _tcsncat, since _tcsncpy won't always
nul-terminate.
- Don't show the old volume information if a label was given on the command line. (Bug
3621)
- If setting the label was unsuccessful, give an error message.
Modified:
trunk/reactos/base/shell/cmd/label.c
Modified: trunk/reactos/base/shell/cmd/label.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/label.c?rev…
==============================================================================
--- trunk/reactos/base/shell/cmd/label.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/label.c [iso-8859-1] Mon Aug 4 09:16:01 2008
@@ -57,7 +57,7 @@
szRootPath[0] = szCurPath[0];
}
- _tcsncpy (szLabel, param, 12);
+ _tcsncat(szLabel, param, 79);
/* check root path */
if (!IsValidPathName (szRootPath))
@@ -67,30 +67,35 @@
return 1;
}
- GetVolumeInformation(szRootPath, szOldLabel, 80, &dwSerialNr,
- NULL, NULL, NULL, 0);
-
- /* print drive info */
- if (szOldLabel[0] != _T('\0'))
- {
- ConOutResPrintf(STRING_LABEL_HELP2, _totupper(szRootPath[0]), szOldLabel);
- }
- else
- {
- ConOutResPrintf(STRING_LABEL_HELP3, _totupper(szRootPath[0]));
- }
-
- /* print the volume serial number */
- ConOutResPrintf(STRING_LABEL_HELP4, HIWORD(dwSerialNr), LOWORD(dwSerialNr));
-
if (szLabel[0] == _T('\0'))
{
+ GetVolumeInformation(szRootPath, szOldLabel, 80, &dwSerialNr,
+ NULL, NULL, NULL, 0);
+
+ /* print drive info */
+ if (szOldLabel[0] != _T('\0'))
+ {
+ ConOutResPrintf(STRING_LABEL_HELP2, _totupper(szRootPath[0]), szOldLabel);
+ }
+ else
+ {
+ ConOutResPrintf(STRING_LABEL_HELP3, _totupper(szRootPath[0]));
+ }
+
+ /* print the volume serial number */
+ ConOutResPrintf(STRING_LABEL_HELP4, HIWORD(dwSerialNr), LOWORD(dwSerialNr));
+
ConOutResPuts(STRING_LABEL_HELP5);
ConInString(szLabel, 80);
}
- SetVolumeLabel(szRootPath, szLabel);
+ if (!SetVolumeLabel(szRootPath, szLabel))
+ {
+ ConOutFormatMessage(GetLastError());
+ nErrorLevel = 1;
+ return 1;
+ }
return 0;
}