From: Naveen Naidu Date: Wed, 11 Feb 2026 08:48:34 +0000 (+0000) Subject: src/common/version: append vendor release to ceph version(s) output X-Git-Tag: v21.0.0~135^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=541439b290001e1bb15dc9b2b40671671c2b85c4;p=ceph.git src/common/version: append vendor release to ceph version(s) output Introduce a build-time mechanism to allow vendors or downstream distributions to append their release/version metadata to the output of ceph version and ceph versions. The release string is read from the file `/etc/ceph_version` and appends it to the version string as `release `. If no value is supplied or the file is empty, the version output remains unchanged. Example: If the `/etc/ceph_version` file has "8.1.0" as string then, ceph version 8d7daada90 (98d7daada90c6585c6724f69793e804a5e23cb24) tentacle (dev - Debug) release 8.1.0 Signed-off-by: Naveen Naidu --- diff --git a/src/common/version.cc b/src/common/version.cc index 5e41921339a4..c45faba6491b 100644 --- a/src/common/version.cc +++ b/src/common/version.cc @@ -17,6 +17,10 @@ #include #include +#include +#include +#include + #include "ceph_ver.h" #include "common/ceph_strings.h" @@ -44,6 +48,29 @@ const char *git_version_to_str(void) return STRINGIFY(CEPH_GIT_VER); } +static std::string read_vendor_release_file() +{ + auto filename = "/etc/ceph_version"; + std::ifstream file(filename); + + if(!file.is_open()){ + return ""; + } + + std::string content; + try { + content.assign(std::istreambuf_iterator(file), std::istreambuf_iterator()); + } catch (const std::exception &e) { + return ""; + } + if (!content.empty()) { + return std::string(" release ") + content; + } + + return ""; + +} + std::string const pretty_version_to_str(void) { std::ostringstream oss; @@ -55,6 +82,7 @@ std::string const pretty_version_to_str(void) #ifdef WITH_CRIMSON << " (crimson)" #endif + << read_vendor_release_file() ; return oss.str(); }