]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
src/common/version: append vendor release to ceph version(s) output 67299/head
authorNaveen Naidu <naveennaidu479@gmail.com>
Wed, 11 Feb 2026 08:48:34 +0000 (08:48 +0000)
committerNaveen Naidu <naveennaidu479@gmail.com>
Thu, 26 Feb 2026 06:09:04 +0000 (11:39 +0530)
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 <value>`. 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 <naveen.naidu@ibm.com>
src/common/version.cc

index 5e41921339a4c8e5459121b227c1013d48c7a555..c45faba6491b2a5f736217651dd0d95637c4f66b 100644 (file)
 
 #include <stdlib.h>
 #include <sstream>
+#include <fstream>
+#include <string>
+#include <iterator>
+
 
 #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<char>(file), std::istreambuf_iterator<char>());
+  } 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();
 }