]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/bluestore_tool: use boost::filesystem as an alternative
authorKefu Chai <kchai@redhat.com>
Fri, 21 May 2021 04:10:50 +0000 (04:10 +0000)
committerKefu Chai <kchai@redhat.com>
Fri, 21 May 2021 10:51:00 +0000 (18:51 +0800)
the libstdc++ shipped with GCC 7.5 does not have good support of
std::filesystem, among other things, it does not offer
std::filesystem::weakly_canonical(). but boost::filesystem does.
and boost::filesystem is compatible with std::filesystem to some
degree. so let's use it if <filesystem> is not available, we can
take it as a signal that std::filesystem is not quite ready yet.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/os/CMakeLists.txt
src/os/bluestore/bluestore_tool.cc

index 9008f2ed8c04ed56dcb8967d20141c52c4810c9a..522d572967acb70b9e26933f6aec2d70fc203e70 100644 (file)
@@ -106,6 +106,11 @@ if(WITH_BLUESTORE)
     bluestore/bluestore_tool.cc)
   target_link_libraries(ceph-bluestore-tool
     os global)
+  # TODO: drop this linkage once we don't need to build on bionic
+  if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0)
+    target_link_libraries(ceph-bluestore-tool
+      Boost::filesystem)
+  endif()
   install(TARGETS ceph-bluestore-tool
     DESTINATION bin)
 endif()
index 2eeae694d60285ce0403cf0e73b508425c74b725..8064d395c9aa29a66ce07be66cf6cb5d275e33d3 100644 (file)
@@ -9,9 +9,9 @@
 #if __has_include(<filesystem>)
 #include <filesystem>
 namespace fs = std::filesystem;
-#elif __has_include(<experimental/filesystem>)
-#include <experimental/filesystem>
-namespace fs = std::experimental::filesystem;
+#else
+#include <boost/filesystem.hpp>
+namespace fs = boost::filesystem;
 #endif
 #include <iostream>
 #include <fstream>
@@ -249,8 +249,8 @@ static void bluefs_import(
 
   BlueFS::FileWriter *h;
   fs::path file_path(dest_file);
-  const string dir = file_path.parent_path();
-  const string file_name = file_path.filename();
+  const string dir = file_path.parent_path().native();
+  const string file_name = file_path.filename().native();
   bs->open_for_write(dir, file_name, &h, false);
   uint64_t max_block = 4096;
   char buf[max_block];