Seastar
High performance C++ framework for concurrent servers
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
uname.hh
1/*
2 * This file is open source software, licensed to you under the terms
3 * of the Apache License, Version 2.0 (the "License"). See the NOTICE file
4 * distributed with this work for additional information regarding copyright
5 * ownership. You may not use this file except in compliance with the License.
6 *
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing,
12 * software distributed under the License is distributed on an
13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 * KIND, either express or implied. See the License for the
15 * specific language governing permissions and limitations
16 * under the License.
17 */
18
19/*
20 * Copyright (C) 2019 ScyllaDB
21 */
22
23#pragma once
24
25#include <seastar/util/modules.hh>
26#ifndef SEASTAR_MODULE
27#include <optional>
28#include <string>
29#include <initializer_list>
30#include <iosfwd>
31#endif
32
33namespace seastar {
34
35namespace internal {
36
37// Representation of a Linux kernel version number
38struct uname_t {
39 int version; // 4 in "4.5"
40 int patchlevel; // 5 in "4.5"
41 std::optional<int> sublevel; // 1 in "4.5.1"
42 std::optional<int> subsublevel; // 33 in "2.6.44.33"
43 std::optional<int> distro_patch; // 957 in "3.10.0-957.5.1.el7.x86_64"
44 std::string distro_extra; // .5.1.el7.x86_64
45
46 bool same_as_or_descendant_of(const uname_t& x) const;
47 bool same_as_or_descendant_of(const char* x) const;
48 bool whitelisted(std::initializer_list<const char*>) const;
49
50 // 3 for "4.5.0", 5 for "5.1.3-33.3.el7"; "el7" doesn't count as a component
51 int component_count() const;
52
53 // The "el7" that wasn't counted in components()
54 bool has_distro_extra(std::string extra) const;
55 friend std::ostream& operator<<(std::ostream& os, const uname_t& u);
56};
57
58uname_t kernel_uname();
59
60uname_t parse_uname(const char* u);
61
62}
63}
Seastar API namespace.
Definition: abort_on_ebadf.hh:26