From 489d4d8089f805f9957b31573bef47f9257784a6 Mon Sep 17 00:00:00 2001 From: Jeffrey Morlan Date: Mon, 4 Aug 2008 14:16:01 +0000 Subject: [PATCH] - 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. svn path=/trunk/; revision=35098 --- reactos/base/shell/cmd/label.c | 41 +++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/reactos/base/shell/cmd/label.c b/reactos/base/shell/cmd/label.c index f87d294b873..745ff900dcd 100644 --- a/reactos/base/shell/cmd/label.c +++ b/reactos/base/shell/cmd/label.c @@ -57,7 +57,7 @@ INT cmd_label (LPTSTR cmd, LPTSTR param) szRootPath[0] = szCurPath[0]; } - _tcsncpy (szLabel, param, 12); + _tcsncat(szLabel, param, 79); /* check root path */ if (!IsValidPathName (szRootPath)) @@ -67,30 +67,35 @@ INT cmd_label (LPTSTR cmd, LPTSTR param) 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; }