Commit 99f422c3 authored by Steffen Vogel's avatar Steffen Vogel 🎅🏼
Browse files

kernel: partial port to C++

parent 03d9cc61
......@@ -34,9 +34,6 @@
extern "C" {
#endif
/* Forward declarations */
struct version;
#if WITH_CAP
#include <sys/capability.h>
......@@ -66,9 +63,6 @@ int kernel_set_nr_hugepages(int nr);
*/
int kernel_get_cmdline_param(const char *param, char *buf, size_t len);
/** Get the version of the kernel. */
int kernel_get_version(struct version *v);
/** Checks if a kernel module is loaded
*
* @param module the name of the module
......
/** Linux kernel related functions.
*
* @file
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
* @copyright 2017-2018, Institute for Automation of Complex Power Systems, EONERC
* @license GNU General Public License (version 3)
*
* VILLAScommon
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
#pragma once
#include <villas/version.hpp>
namespace villas {
namespace kernel {
/** Get the version of the kernel. */
utils::Version getVersion();
} // namespace villas
} // namespace kernel
......@@ -28,7 +28,6 @@
#include <inttypes.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <sys/types.h>
#include <sys/wait.h>
......@@ -121,19 +120,6 @@ int kernel_module_loaded(const char *module)
return ret;
}
int kernel_get_version(struct version *v)
{
struct utsname uts;
if (uname(&uts) < 0)
return -1;
if (version_parse(uts.release, v))
return -1;
return 0;
}
int kernel_get_cmdline_param(const char *param, char *buf, size_t len)
{
int ret;
......
/** Linux kernel related functions.
*
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
* @copyright 2017-2018, Institute for Automation of Complex Power Systems, EONERC
* @license GNU General Public License (version 3)
*
* VILLAScommon
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
#include <sys/utsname.h>
#include <villas/kernel/kernel.hpp>
#include <villas/exceptions.hpp>
using namespace villas::utils;
Version villas::kernel::getVersion()
{
struct utsname uts;
if (uname(&uts) < 0)
throw new SystemError("Failed to retrieve system identification");
std::string rel = uts.release;
/* Remove release part. E.g. 4.9.93-linuxkit-aufs */
auto sep = rel.find('-');
auto ver = rel.substr(0, sep - 1);
return Version(ver);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment