2013-04-12 20:55:45 +00:00
|
|
|
/*
|
|
|
|
* virtpm.c: TPM support
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 IBM Corporation
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Author: Stefan Berger <stefanb@linux.vnet.ibm.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
2013-04-03 10:36:23 +00:00
|
|
|
#include "virstring.h"
|
2013-04-12 20:55:45 +00:00
|
|
|
#include "virerror.h"
|
|
|
|
#include "virtpm.h"
|
|
|
|
|
|
|
|
#define VIR_FROM_THIS VIR_FROM_NONE
|
|
|
|
|
|
|
|
/**
|
|
|
|
* virTPMCreateCancelPath:
|
|
|
|
* @devpath: Path to the TPM device
|
|
|
|
*
|
|
|
|
* Create the cancel path given the path to the TPM device
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
virTPMCreateCancelPath(const char *devpath)
|
|
|
|
{
|
|
|
|
char *path = NULL;
|
|
|
|
const char *dev;
|
|
|
|
|
|
|
|
if (devpath) {
|
|
|
|
dev = strrchr(devpath, '/');
|
|
|
|
if (dev) {
|
|
|
|
dev++;
|
|
|
|
if (virAsprintf(&path, "/sys/class/misc/%s/device/cancel",
|
2013-07-04 10:17:18 +00:00
|
|
|
dev) < 0)
|
2013-04-12 20:55:45 +00:00
|
|
|
goto cleanup;
|
|
|
|
} else {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("TPM device path %s is invalid"), devpath);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("Missing TPM device path"));
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
return path;
|
|
|
|
}
|