|
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/statusCodes.c#3 $
|
|
Packit Service |
310c69 |
*/
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#include "statusCodes.h"
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#include "errors.h"
|
|
Packit Service |
310c69 |
#include "permassert.h"
|
|
Packit Service |
310c69 |
#include "threadOnce.h"
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
const struct errorInfo vdoStatusList[] = {
|
|
Packit Service |
310c69 |
{ "VDO_NOT_IMPLEMENTED", "Not implemented" },
|
|
Packit Service |
310c69 |
{ "VDO_OUT_OF_RANGE", "Out of range" },
|
|
Packit Service |
310c69 |
{ "VDO_REF_COUNT_INVALID", "Reference count would become invalid" },
|
|
Packit Service |
310c69 |
{ "VDO_NO_SPACE", "Out of space" },
|
|
Packit Service |
310c69 |
{ "VDO_UNEXPECTED_EOF", "Unexpected EOF on block read" },
|
|
Packit Service |
310c69 |
{ "VDO_BAD_CONFIGURATION", "Bad configuration option" },
|
|
Packit Service |
310c69 |
{ "VDO_SOCKET_ERROR", "Socket error" },
|
|
Packit Service |
310c69 |
{ "VDO_BAD_ALIGNMENT", "Mis-aligned block reference" },
|
|
Packit Service |
310c69 |
{ "VDO_COMPONENT_BUSY", "Prior operation still in progress" },
|
|
Packit Service |
310c69 |
{ "VDO_BAD_PAGE", "Corrupt or incorrect page" },
|
|
Packit Service |
310c69 |
{ "VDO_UNSUPPORTED_VERSION", "Unsupported component version" },
|
|
Packit Service |
310c69 |
{ "VDO_INCORRECT_COMPONENT", "Component id mismatch in decoder" },
|
|
Packit Service |
310c69 |
{ "VDO_PARAMETER_MISMATCH", "Parameters have conflicting values" },
|
|
Packit Service |
310c69 |
{ "VDO_BLOCK_SIZE_TOO_SMALL", "The block size is too small" },
|
|
Packit Service |
310c69 |
{ "VDO_UNKNOWN_PARTITION", "No partition exists with a given id" },
|
|
Packit Service |
310c69 |
{ "VDO_PARTITION_EXISTS", "A partition already exists with a given id"},
|
|
Packit Service |
310c69 |
{ "VDO_NOT_READ_ONLY", "The device is not in read-only mode" },
|
|
Packit Service |
310c69 |
{ "VDO_INCREMENT_TOO_SMALL", "Physical block growth of too few blocks" },
|
|
Packit Service |
310c69 |
{ "VDO_CHECKSUM_MISMATCH", "Incorrect checksum" },
|
|
Packit Service |
310c69 |
{ "VDO_RECOVERY_JOURNAL_FULL", "The recovery journal is full" },
|
|
Packit Service |
310c69 |
{ "VDO_LOCK_ERROR", "A lock is held incorrectly" },
|
|
Packit Service |
310c69 |
{ "VDO_READ_ONLY", "The device is in read-only mode" },
|
|
Packit Service |
310c69 |
{ "VDO_SHUTTING_DOWN", "The device is shutting down" },
|
|
Packit Service |
310c69 |
{ "VDO_CORRUPT_JOURNAL", "Recovery journal entries corrupted" },
|
|
Packit Service |
310c69 |
{ "VDO_TOO_MANY_SLABS", "Exceeds maximum number of slabs supported" },
|
|
Packit Service |
310c69 |
{ "VDO_INVALID_FRAGMENT", "Compressed block fragment is invalid" },
|
|
Packit Service |
310c69 |
{ "VDO_RETRY_AFTER_REBUILD", "Retry operation after rebuilding finishes" },
|
|
Packit Service |
310c69 |
{ "VDO_UNKNOWN_COMMAND", "The extended command is not known" },
|
|
Packit Service |
310c69 |
{ "VDO_COMMAND_ERROR", "Bad extended command parameters" },
|
|
Packit Service |
310c69 |
{ "VDO_CANNOT_DETERMINE_SIZE", "Cannot determine config sizes to fit" },
|
|
Packit Service |
310c69 |
{ "VDO_BAD_MAPPING", "Invalid page mapping" },
|
|
Packit Service |
310c69 |
{ "VDO_READ_CACHE_BUSY", "Read cache has no free slots" },
|
|
Packit Service |
310c69 |
{ "VDO_BIO_CREATION_FAILED", "Bio creation failed" },
|
|
Packit Service |
310c69 |
{ "VDO_BAD_MAGIC", "Bad magic number" },
|
|
Packit Service |
310c69 |
{ "VDO_BAD_NONCE", "Bad nonce" },
|
|
Packit Service |
310c69 |
{ "VDO_JOURNAL_OVERFLOW", "Journal sequence number overflow" },
|
|
Packit Service |
310c69 |
{ "VDO_INVALID_ADMIN_STATE", "Invalid operation for current state" },
|
|
Packit Service |
310c69 |
};
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#ifndef __KERNEL__
|
|
Packit Service |
310c69 |
static OnceState vdoStatusCodesRegistered = ONCE_STATE_INITIALIZER;
|
|
Packit Service |
310c69 |
static int statusCodeRegistrationResult;
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**********************************************************************/
|
|
Packit Service |
310c69 |
static void doStatusCodeRegistration(void)
|
|
Packit Service |
310c69 |
{
|
|
Packit Service |
310c69 |
STATIC_ASSERT((VDO_STATUS_CODE_LAST - VDO_STATUS_CODE_BASE)
|
|
Packit Service |
310c69 |
== COUNT_OF(vdoStatusList));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
int result = registerErrorBlock("VDO Status",
|
|
Packit Service |
310c69 |
VDO_STATUS_CODE_BASE,
|
|
Packit Service |
310c69 |
VDO_STATUS_CODE_BLOCK_END,
|
|
Packit Service |
310c69 |
vdoStatusList,
|
|
Packit Service |
310c69 |
sizeof(vdoStatusList));
|
|
Packit Service |
310c69 |
/*
|
|
Packit Service |
310c69 |
* The following test handles cases where libvdo is statically linked
|
|
Packit Service |
310c69 |
* against both the test modules and the test driver (because multiple
|
|
Packit Service |
310c69 |
* instances of this module call their own copy of this function
|
|
Packit Service |
310c69 |
* once each, resulting in multiple calls to registerErrorBlock which
|
|
Packit Service |
310c69 |
* is shared in libuds).
|
|
Packit Service |
310c69 |
*/
|
|
Packit Service |
310c69 |
if (result == UDS_DUPLICATE_NAME) {
|
|
Packit Service |
310c69 |
result = UDS_SUCCESS;
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
statusCodeRegistrationResult
|
|
Packit Service |
310c69 |
= (result == UDS_SUCCESS) ? VDO_SUCCESS : result;
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
#endif
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**********************************************************************/
|
|
Packit Service |
310c69 |
int registerStatusCodes(void)
|
|
Packit Service |
310c69 |
{
|
|
Packit Service |
310c69 |
#ifdef __KERNEL__
|
|
Packit Service |
310c69 |
return VDO_SUCCESS;
|
|
Packit Service |
310c69 |
#else
|
|
Packit Service |
310c69 |
performOnce(&vdoStatusCodesRegistered, doStatusCodeRegistration);
|
|
Packit Service |
310c69 |
return statusCodeRegistrationResult;
|
|
Packit Service |
310c69 |
#endif
|
|
Packit Service |
310c69 |
}
|