|
Packit Service |
310c69 |
/*
|
|
Packit Service |
310c69 |
* Copyright (c) 2020 Red Hat, Inc.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* This program is free software; you can redistribute it and/or
|
|
Packit Service |
310c69 |
* modify it under the terms of the GNU General Public License
|
|
Packit Service |
310c69 |
* as published by the Free Software Foundation; either version 2
|
|
Packit Service |
310c69 |
* of the License, or (at your option) any later version.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* This program is distributed in the hope that it will be useful,
|
|
Packit Service |
310c69 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
310c69 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
310c69 |
* GNU General Public License for more details.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* You should have received a copy of the GNU General Public License
|
|
Packit Service |
310c69 |
* along with this program; if not, write to the Free Software
|
|
Packit Service |
310c69 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
Packit Service |
310c69 |
* 02110-1301, USA.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* $Id: //eng/vdo-releases/aluminum/src/c++/vdo/base/vdoState.c#1 $
|
|
Packit Service |
310c69 |
*/
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#include "vdoState.h"
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#include "permassert.h"
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
static const char *VDO_STATE_NAMES[] = {
|
|
Packit Service |
310c69 |
[VDO_CLEAN] = "CLEAN",
|
|
Packit Service |
310c69 |
[VDO_DIRTY] = "DIRTY",
|
|
Packit Service |
310c69 |
[VDO_FORCE_REBUILD] = "FORCE_REBUILD",
|
|
Packit Service |
310c69 |
[VDO_NEW] = "NEW",
|
|
Packit Service |
310c69 |
[VDO_READ_ONLY_MODE] = "READ_ONLY_MODE",
|
|
Packit Service |
310c69 |
[VDO_REBUILD_FOR_UPGRADE] = "REBUILD_FOR_UPGRADE",
|
|
Packit Service |
310c69 |
[VDO_RECOVERING] = "RECOVERING",
|
|
Packit Service |
310c69 |
[VDO_REPLAYING] = "REPLAYING",
|
|
Packit Service |
310c69 |
};
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**********************************************************************/
|
|
Packit Service |
310c69 |
const char *getVDOStateName(VDOState state)
|
|
Packit Service |
310c69 |
{
|
|
Packit Service |
310c69 |
// Catch if a state has been added without updating the name array.
|
|
Packit Service |
310c69 |
STATIC_ASSERT(COUNT_OF(VDO_STATE_NAMES) == VDO_STATE_COUNT);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
int result = ASSERT(state < COUNT_OF(VDO_STATE_NAMES),
|
|
Packit Service |
310c69 |
"VDOState value %u must have a registered name", state);
|
|
Packit Service |
310c69 |
if (result != UDS_SUCCESS) {
|
|
Packit Service |
310c69 |
return "INVALID VDO STATE CODE";
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
return VDO_STATE_NAMES[state];
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**********************************************************************/
|
|
Packit Service |
310c69 |
const char *describeVDOState(VDOState state)
|
|
Packit Service |
310c69 |
{
|
|
Packit Service |
310c69 |
// These strings should all fit in the 15 chars of VDOStatistics.mode.
|
|
Packit Service |
310c69 |
switch (state) {
|
|
Packit Service |
310c69 |
case VDO_RECOVERING:
|
|
Packit Service |
310c69 |
return "recovering";
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
case VDO_READ_ONLY_MODE:
|
|
Packit Service |
310c69 |
return "read-only";
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
default:
|
|
Packit Service |
310c69 |
return "normal";
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
}
|